emacs-devel
[Top][All Lists]
Advanced

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

lisp/emacs-lisp/cl-indent.el: prog indentation context


From: Madhu
Subject: lisp/emacs-lisp/cl-indent.el: prog indentation context
Date: Sun, 27 Mar 2016 15:07:46 +0530 (IST)

* lisp/emacs-lisp/cl-indent.el (lisp-indent-259): handle (&rest function)
specs correctly.

The appended patch kludges a bug that has existed forever, wherein
prog forms were never indented correctly. (cf. final comment on prog
in that file)

(get 'prog 'common-lisp-indent-function)
;; => (&lambda &rest lisp-indent-tagbody)

However lisp-indent-259 does not handle the &rest spec as expected: in
the following example, it indents the 3rd element of the prog sexp
with lisp-indent-tagbody, and the remaining elements (the tail) with
normal-indent.

;; -*- Mode: Lisp; lisp-indent-function: common-lisp-indent-function; -*-

;; ..., so we get:

(prog ()
 nil
 (foo  bar)
 nil
 (barf))

;; instead of the expected:

(prog ()
 nil
   (foo  bar)
 nil
   (barf))

This fix makes sure that if the item after `&rest' in the indentation
spec is a symbol (indicating a function to be called), then we dont
handle the tail as above (i.e. as normal-indent), but instead end up
using the indicated function---Madhu


--- a/lisp/emacs-lisp/cl-indent.el
+++ b/lisp/emacs-lisp/cl-indent.el
@@ -608,7 +608,9 @@ lisp-indent-259
                        normal-indent)))
                 ((eq tem '&rest)
                  ;; this pattern holds for all remaining forms
-                 (setq tail (> n 0)
+                 (setq tail (and (> n 0)
+                                (not (and (symbolp (cadr method))
+                                          (null (cddr method)))))
                        n 0
                        method (cdr method)))
                 ((> n 0)



reply via email to

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