[slime-cvs] CVS slime/contrib

CVS User nsiivola nsiivola at common-lisp.net
Tue Jun 14 09:33:39 UTC 2011


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

Modified Files:
	ChangeLog slime-cl-indent-test.txt slime-cl-indent.el 
Log Message:
slime-indentation: even better defmethod indentation

  Fix indentation of non-toplevel defmethods, and Handle qualifiers in
  defgeneric :methods as well.


--- /project/slime/cvsroot/slime/contrib/ChangeLog	2011/06/11 19:24:36	1.480
+++ /project/slime/cvsroot/slime/contrib/ChangeLog	2011/06/14 09:33:39	1.481
@@ -1,3 +1,11 @@
+2011-06-14  Nikodemus Siivola  <nikodemus at random-state.net>
+
+	* slime-cl-indent.el (lisp-beginning-of-defmethod): New function.
+	(lisp-indent-defmethod): Extend to work with non-toplevel defmethods,
+	and method definitions inside defgenerics.
+
+	* slime-cl-indent-test.txt: Tests 40-43.
+
 2011-06-11  Nikodemus Siivola  <nikodemus at random-state.net>
 
 	* slime-cl-indent.el (common-lisp-style-names): XEmacs doesn't
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt	2011/06/10 20:03:33	1.5
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt	2011/06/14 09:33:39	1.6
@@ -435,3 +435,43 @@
   zot
   fii)
 
+;;; Test: 40
+;;
+;; lisp-lambda-list-keyword-parameter-alignment: t
+;; lisp-lambda-list-keyword-alignment: t
+
+(defmethod foo :around (zot &key x
+                                 y)
+  (list zot))
+
+;;; Test: 41
+;;
+;; lisp-lambda-list-keyword-parameter-alignment: t
+;; lisp-lambda-list-keyword-alignment: t
+
+(progn
+  (defmethod foo :around (fii &key x
+                                   y)
+    (list fii)))
+
+;;; Test: 42
+;;
+;; lisp-lambda-list-keyword-parameter-alignment: t
+;; lisp-lambda-list-keyword-alignment: t
+
+(progn
+  (defgeneric foo (x y &optional a
+                                 b)
+    (:method :around (a b &optional x
+                                    y)
+      (list a b x y))))
+
+;;; Test: 43
+;;
+;; lisp-lambda-list-keyword-parameter-alignment: t
+;; lisp-lambda-list-keyword-alignment: t
+
+(defgeneric foo (x &optional a b)
+  (:method (x y &optional a
+                          b)
+    (list x y a b)))
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/06/11 19:24:36	1.43
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/06/14 09:33:39	1.44
@@ -1153,28 +1153,33 @@
           (t 2)))))
    (elt state 1)))
 
+(defun lisp-beginning-of-defmethod ()
+  (let ((regexp "(defmethod\\|(DEFMETHOD\\|(:method\\|(:METHOD")
+        (ok nil))
+    (while (and (not (setq ok (looking-at regexp)))
+                (ignore-errors (backward-up-list) t)))
+    ok))
+
 ;; LISP-INDENT-DEFMETHOD now supports the presence of more than one method
 ;; qualifier and indents the method's lambda list properly. -- dvl
 (defun lisp-indent-defmethod
     (path state indent-point sexp-column normal-indent)
   (lisp-indent-259
-   (let ((nqual 0))
-     (if (and (>= (car path) 3)
-              (save-excursion
-                (beginning-of-defun)
-                (forward-char 1)
-                (forward-sexp 2)
-                (skip-chars-forward " \t\n")
-                (while (looking-at "\\sw\\|\\s_")
-                  (incf nqual)
-                  (forward-sexp)
-                  (skip-chars-forward " \t\n"))
-                (> nqual 0)))
-         (append '(4) (make-list nqual 4) '(&lambda &body))
+   (let ((nskip 0))
+     (if (save-excursion
+           (when (lisp-beginning-of-defmethod)
+             (forward-char)
+             (forward-sexp 1)
+             (skip-chars-forward " \t\n")
+             (while (looking-at "\\sw\\|\\s_")
+               (incf nskip)
+               (forward-sexp)
+               (skip-chars-forward " \t\n"))
+             t))
+         (append (make-list nskip 4) '(&lambda &body))
        (common-lisp-get-indentation 'defun)))
    path state indent-point sexp-column normal-indent))
 
-
 (defun lisp-indent-function-lambda-hack (path state indent-point
                                          sexp-column normal-indent)
   ;; indent (function (lambda () <newline> <body-forms>)) kludgily.
@@ -1501,7 +1506,7 @@
            (restart-bind (as let))
            (locally 1)
            (loop           lisp-indent-loop)
-           (:method (&lambda &body)) ; in `defgeneric'
+           (:method        lisp-indent-defmethod) ; in `defgeneric'
            (multiple-value-bind ((&whole 6 &rest 1) 4 &body))
            (multiple-value-call (4 &body))
            (multiple-value-prog1 1)





More information about the slime-cvs mailing list