[slime-cvs] CVS slime

CVS User nsiivola nsiivola at common-lisp.net
Fri Jun 10 16:13:29 UTC 2011


Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv5654

Modified Files:
	ChangeLog swank.lisp 
Log Message:
swank: better macro-indentation

  lisp-indent-259 didn't handle complex destructuring right: &whole
  nested in &whole wasn't working properly. Now it hopefully
  does. (But the whole indentation spec walking really deserves a
  rewrite.)

  Derived indentation:

  * Walk the entire macro lambda-list instead of just looking for
    &BODY in the toplevel.

  * Set the base indentation to 4 in macro-indentation only for the
    first level of destructuring -- use 1 later.

  now

    (defmacro foo (x (&rest args) &body body)
      ...)

  gives

    (foo (bar quux
              zot)
        (a b
         c d)
      ...)

  instead of the old

    (foo (bar quux
              zot)
       (a b
          c d)
      ...)

  While this change may turn out to be controversial, I feel that
  since FOO and (&REST FOO) are semantically equivalent as long as the
  corresponding argument is not an atom, it seems most natural to
  treat them as indentation hints instead.

  Complaints to the usual address...


--- /project/slime/cvsroot/slime/ChangeLog	2011/06/09 17:48:47	1.2197
+++ /project/slime/cvsroot/slime/ChangeLog	2011/06/10 16:13:28	1.2198
@@ -1,3 +1,9 @@
+2011-06-10  Nikodemus Siivola  <nikodemus at random-state.net>
+
+	* swank.lisp (macro-indentation): Walk the lambda-list
+	to construct a better indentation spec instead of just
+	looking for &BODY.
+
 2011-06-09  Nikodemus Siivola  <nikodemus at random-state.net>
 
 	* swank-sbcl.lisp (execv): Stupid SBCL hackers breaking backwards
--- /project/slime/cvsroot/slime/swank.lisp	2011/06/09 16:35:09	1.744
+++ /project/slime/cvsroot/slime/swank.lisp	2011/06/10 16:13:28	1.745
@@ -3944,9 +3944,20 @@
       nil))
 
 (defun macro-indentation (arglist)
-  (if (well-formed-list-p arglist)
-      (position '&body (remove '&optional (clean-arglist arglist)))
-      nil))
+  (labels ((walk (list &optional base)
+             (when (consp list)
+               (let ((head (car list))
+                     (n (if base 4 1)))
+                 (cond ((consp head)
+                        (let ((indent (walk head)))
+                          (cons (list* "&whole" n indent) (walk (cdr list) base))))
+                       ((eq '&body head)
+                        '("&body"))
+                       ((member head lambda-list-keywords)
+                        '("&rest" 1))
+                       (t
+                        (cons n (walk (cdr list) base))))))))
+    (walk arglist t)))
 
 (defun clean-arglist (arglist)
   "Remove &whole, &enviroment, and &aux elements from ARGLIST."





More information about the slime-cvs mailing list