all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* lisp/emacs-lisp/cl-indent.el: prog indentation context
@ 2016-03-27  9:37 Madhu
  0 siblings, 0 replies; only message in thread
From: Madhu @ 2016-03-27  9:37 UTC (permalink / raw
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-27  9:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-27  9:37 lisp/emacs-lisp/cl-indent.el: prog indentation context Madhu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.