Hi,

I have received the following report (and few more, which I'll forward
in a bit) against haskell-mode 2.3. The proposed patch should be
attached as well. I haven't noticed anything in 2.4 (which I will
package shortly) that would address the report. I admit to not looking
very closely though.

Please keep [EMAIL PROTECTED] CC'd when you
reply. Thank you.

--- Begin Message ---
Package: haskell-mode
Version: 2.3-1
Severity: wishlist
Tags: patch

  In some circumstances, haskell-mode's indent function will fail with
the message "Containing sexp ends prematurely".  The most frequent, and
annoying, trigger is when writing a list of exports or imports for a
module:

-------------------
module Foo(name1,
           name2,

          )
-------------------

  Placing point on the line after name2 and pressing Tab will fail to
find an indentation.  This happens because several points in the code
try to scan through lists of symbols using forward-sexp, and
forward-sexp fails when called at the end of a pair of parens.  (I
admit that I don't quite follow all the code, but that seems to be
what's happening)

  I've worked up a fix that replaces calls to forward-sexp with a
variant that traps errors and pretends we're at the end point of the
scan region if one occurs.  The haskell-mode code is, um, rather
complex, so I'm not 100% sure I've done the right thing, but it passed
my 10-second test of reindenting random lines in some existing code.

  Daniel

-- 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
--- haskell-indent.el.orig	2008-01-01 09:05:26.000000000 -0800
+++ haskell-indent.el	2008-01-01 09:05:44.000000000 -0800
@@ -422,6 +422,11 @@
        (forward-sexp 1)
        (haskell-indent-skip-blanks-and-newlines-forward end))))
 
+(defun haskell-indent-next-symbol-safe (end)
+  "Puts point to the next following symbol, or to end if there are no more symbols in the sexp."
+  (condition-case errlist (haskell-indent-next-symbol end)
+      (error (goto-char end))))
+
 (defun haskell-indent-separate-valdef (start end)
   "Returns a list of positions for important parts of a valdef."
   (save-excursion
@@ -441,13 +446,13 @@
                   (goto-char (match-end 0)))
               (skip-chars-forward " \t" end)
               (setq valname (point))    ; type = other
-              (haskell-indent-next-symbol end))
+              (haskell-indent-next-symbol-safe end))
             (while (and (< (point) end)
                         (setq type (haskell-indent-type-at-point))
                         (or (memq type '(ident other))))
               (if (null aft-valname)
                   (setq aft-valname (point)))
-              (haskell-indent-next-symbol end))))
+              (haskell-indent-next-symbol-safe end))))
       (if (and (< (point) end) (eq type 'guard)) ; start of a guard
           (progn
             (setq guard (match-beginning 0))
@@ -457,7 +462,7 @@
                         (not (eq type 'rhs)))
               (if (null aft-guard)
                   (setq aft-guard (point)))
-              (haskell-indent-next-symbol end))))
+              (haskell-indent-next-symbol-safe end))))
       (if (and (< (point) end) (eq type 'rhs)) ; start of a rhs
           (progn
             (setq rhs-sign (match-beginning 0))

--- 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

Reply via email to