emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in lisp indentation


From: Lennart Staflin
Subject: Re: Bug in lisp indentation
Date: Sun, 15 Jul 2007 16:43:22 +0200
User-agent: Thunderbird 2.0.0.4 (Macintosh/20070604)

Thien-Thi Nguyen wrote:
() Lennart Staflin <address@hidden>
() Thu, 31 May 2007 11:44:46 +0200

   In lisp-mode the indentation of the following expression is wrong:

   (foo
   :bar :a12
   :sie sume )

   If I press TAB at the beginning of the last line I get:

   (foo
   :bar :a12
         :sie sume )

   I think this is wrong, the indentation should be as the first example.
   This was not the behaviour in emacs 21, neither is the beaviour of
   indent-region consistent with TAB.

does the following patch give good results?
here is a description of the change:

        * emacs-lisp/lisp-mode.el (calculate-lisp-indent): Use the
        last sexp that begins a line, instead of the truly last sexp.

can someone suggest a better implementation?

thi

_______________________________________________________________________
diff -c -r1.202 lisp-mode.el
*** lisp-mode.el        6 Jul 2007 17:26:29 -0000       1.202
--- lisp-mode.el        14 Jul 2007 19:48:07 -0000
***************
*** 854,859 ****
--- 854,866 ----
                    (> (setq paren-depth (elt state 0)) 0))
          (setq retry nil)
          (setq calculate-lisp-indent-last-sexp (elt state 2))
+         ;; The last sexp may not be the first sexp on the line
+         ;; where it begins, so find that one, instead.
+         (when calculate-lisp-indent-last-sexp
+           (goto-char calculate-lisp-indent-last-sexp)
+           (beginning-of-line)
+           (skip-chars-forward " \t")
+           (setq calculate-lisp-indent-last-sexp (point)))
          (setq containing-sexp (elt state 1))
          ;; Position following last unclosed open.
          (goto-char (1+ containing-sexp))

This might align the :sie line with the :bar line, but it introduces other indentation bugs. Also the whitespace in the mail is mangled slightly. The :bar line should not be indented under the left paren, but under the foo symbol.

As for a simpler change, I think there is a chunk of code that was added during the pretest to align keyword symbols, that I think is misguided. Removing that code fixes this bug.

//Lennart Staflin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]