emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: change indentation rules for one-dimensional lists in emac


From: akater
Subject: Re: Proposal: change indentation rules for one-dimensional lists in emacs-lisp-mode and lisp-mode
Date: Fri, 01 May 2020 06:26:02 +0000

FWIW, here's a patch that seems to work in emacs-lisp-mode but does not
work in lisp-mode.  It alters a single function, namely
calculate-lisp-indent.

I tested on various expressions; did try with paredit disabled.  For now
I'm baffled as to where the indentation procedures differ.  I'll keep
looking.


--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -947,6 +947,7 @@
           ;; setting this to a number inhibits calling hook
           (desired-indent nil)
           (retry t)
+          whitespace-after-open-paren
           calculate-lisp-indent-last-sexp containing-sexp)
       (cond ((or (markerp parse-start) (integerp parse-start))
              (goto-char parse-start))
@@ -976,6 +977,7 @@
           nil
         ;; Innermost containing sexp found
         (goto-char (1+ containing-sexp))
+        (setq whitespace-after-open-paren (looking-at (rx whitespace)))
         (if (not calculate-lisp-indent-last-sexp)
            ;; indent-point immediately follows open paren.
            ;; Don't call hook.
@@ -990,9 +992,11 @@
                    calculate-lisp-indent-last-sexp)
                 ;; This is the first line to start within the containing sexp.
                 ;; It's almost certainly a function call.
-                (if (= (point) calculate-lisp-indent-last-sexp)
+                (if (or (= (point) calculate-lisp-indent-last-sexp)
+                         whitespace-after-open-paren)
                     ;; Containing sexp has nothing before this line
-                    ;; except the first element.  Indent under that element.
+                    ;; except the first element, or the first element is
+                     ;; preceded by whitespace.  Indent under that element.
                     nil
                   ;; Skip the first element, find start of second (the first
                   ;; argument of the function call) and indent under.



reply via email to

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