[email protected]
[Top] [All Lists]

Bug#459488: marked as forwarded (Better list indentation.)

Subject: Bug#459488: marked as forwarded Better list indentation.
From: Debian Bug Tracking System
Date: Fri, 15 Feb 2008 12:06:04 +0000
Your message dated Fri, 15 Feb 2008 13:05:11 +0100
with message-id <[email protected]>
has caused the $gProject $gBug report #$ref,
regarding Better list indentation.
to be marked as having been forwarded to the upstream software
author(s) [email protected]

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]

459488: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=459488
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Subject: [Daniel Burrows] Bug#459488: Better list indentation.
From: Petr Rockai
Date: Fri, 15 Feb 2008 13:05:11 +0100

roughly the same story as with the previous report. Again, in case you
reply, please keep [email protected] in the CC
list. Thanks.


--- Begin Message ---
Subject: Bug#459488: Better list indentation.
From: Daniel Burrows
Date: Sun, 06 Jan 2008 12:51:01 -0800
Package: haskell-mode
Version: 2.3-1
Severity: wishlist

  Haskell-mode's default list indentation often seems to me do to the
wrong thing.  Just to take a few examples:

module Test(name1,

  here haskell-mode wants to indent name2 to match the comma after
name1.  It does produce the "correct" indentation on the second cycle,
but there's no reason to produce the incorrect one at all.

x = [elt, elt2,
     elt3, elt4]

  As before, elt3 would get indented to match the comma after "elt".

x = [elt, elt2,

  This one happens because my modus operandi for entering lists is to
type "[]", then start filling the list in.  haskell-mode indents the
closing brace to match the opening brace, rather than placing the cursor
where the next list item goes as I would expect.

x = [ (n * 2, n) | n <- [1..],


  Hitting Tab on the empty line here gives me three choices: indent to
match [1..], add a second pipe matching the first pipe, or indent to
match the open paren of the tuple.  None of these indentations make any
sense in the current syntactic context (except if I'm using the ghc
extension for parallel list comprehensions, but I think haskell-mode is
blindly treating the pipe as starting a guard expression).

x = [ (n * 2, n) | n <- [1..],
                   n > 50 ]

  haskell-mode tries to indent "n > 50" to match either "[1..]" or the
open paren of the tuple.  As before, neither of these makes sense in the
current context; the only sensible indentation is the one I've provided

  As far as I can tell from the code, the root cause of these problems
is that haskell-mode doesn't have any notion that ending a line with a
list separator (that is, a comma or semicolon) changes the indentation
context.  Commas and semicolons always terminate an expression, so
there's no need to scan back for indentation points.

  I've attached a patch that adds explicit logic for handling the
indentation of items in a delimited list.  In addition to the cases
listed above, this also handles the idiom of placing the list separator
at the front of a line as in (1), and one possible idiom for a newline
after opening a list as in (2).  In the second case, it might be good to
provide alternative behavior in the case of a "hanging" open brace, but
I'm not quite sure how best to acheive that in the code.

  (1): x = [ 1
           , 2]

  (2): x = [

  Note that the patch I've attached also fixes #343248, by not looking
past pipe characters when calculating indent levels.


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages haskell-mode depends on:
ii  emacs [emacsen]              22.1+1-2.3  The GNU Emacs editor (metapackage)
ii  emacs21 [emacsen]            21.4a+1-5.3 The GNU Emacs editor
ii  emacs22-gtk [emacsen]        22.1+1-2.3  The GNU Emacs editor (with GTK use

Versions of packages haskell-mode recommends:
ii  ghc6                      6.6.1-2        GHC - the Glasgow Haskell Compilat
ii  hugs                      98.200609.21-5 A Haskell 98 interpreter

-- no debconf information

Attachment: haskell-indent-in-lists.patch
Description: Text Data

--- End Message ---
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

--- End Message ---
<Prev in Thread] Current Thread [Next in Thread>
  • Bug#459488: marked as forwarded (Better list indentation.), Debian Bug Tracking System <=