[slime-cvs] CVS slime/contrib

CVS User nsiivola nsiivola at common-lisp.net
Thu May 19 18:25:41 UTC 2011


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

Modified Files:
	ChangeLog slime-cl-indent.el 
Log Message:
slime-indentation: support for turning off lambda-list indentation

 By request.

   (setq lisp-lambda-list-indentation nil)

 and lambda-lists will be more boring than ever before.


--- /project/slime/cvsroot/slime/contrib/ChangeLog	2011/05/18 21:48:04	1.457
+++ /project/slime/cvsroot/slime/contrib/ChangeLog	2011/05/19 18:25:40	1.458
@@ -3,6 +3,9 @@
 	* slime-cl-indent.el (common-lisp-indent-function-1)
 	(lisp-align-keywords-in-calls): Support for aligning keyword
 	arguments in calls.
+	(lisp-lambda-list-indentation, lisp-indent-lambda-list)
+	(run-lisp-indent-tests): Support for turning off the
+	fancy lambda-list indentation.
 
 2011-05-18  Nikodemus Siivola  <nikodemus at solipsist>
 
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/18 21:48:04	1.24
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/19 18:25:40	1.25
@@ -102,6 +102,22 @@
   :type 'boolean
   :group 'lisp-indent)
 
+(defcustom lisp-lambda-list-indentation t
+  "Whether to indent lambda-lists specially. Defaults to t. Setting this to
+nil makes `lisp-lambda-list-keyword-alignment',
+`lisp-lambda-list-keyword-parameter-alignment', and
+`lisp-lambda-list-keyword-parameter-indentation' meaningless, causing
+lambda-lists to be indented as if they were data:
+
+\(defun example (a b &optional o1 o2
+                o3 o4
+                &rest r
+                &key k1 k2
+                k3 k4)
+  #|...|#)"
+  :type 'boolean
+  :group 'lisp-indent)
+
 (defcustom lisp-lambda-list-keyword-alignment nil
   "Whether to vertically align lambda-list keywords together.
 If nil (the default), keyworded lambda-list parts are aligned
@@ -480,60 +496,62 @@
 
 (defun lisp-indent-lambda-list
     (indent-point sexp-column containing-form-start)
-  (let (limit)
-    (cond ((save-excursion
-             (goto-char indent-point)
-	     (back-to-indentation)
-             (setq limit (point))
-             (looking-at lisp-indent-lambda-list-keywords-regexp))
-           ;; We're facing a lambda-list keyword.
-           (if lisp-lambda-list-keyword-alignment
-               ;; Align to the first keyword if any, or to the beginning of
-               ;; the lambda-list.
-               (save-excursion
-                 (goto-char containing-form-start)
-                 (down-list)
-                 (let ((key-indent nil)
-                       (next t))
-                   (while (and next (< (point) indent-point))
-                     (if (looking-at lisp-indent-lambda-list-keywords-regexp)
-                         (setq key-indent (current-column)
-                               next nil)
-                       (setq next (ignore-errors (forward-sexp) t))
-                       (if next
-                           (ignore-errors
-                             (forward-sexp)
-                             (backward-sexp)))))
-                   (or key-indent
-                       (1+ sexp-column))))
+  (if (not lisp-lambda-list-indentation)
+      (1+ sexp-column)
+    (let (limit)
+      (cond ((save-excursion
+               (goto-char indent-point)
+               (back-to-indentation)
+               (setq limit (point))
+               (looking-at lisp-indent-lambda-list-keywords-regexp))
+             ;; We're facing a lambda-list keyword.
+             (if lisp-lambda-list-keyword-alignment
+                 ;; Align to the first keyword if any, or to the beginning of
+                 ;; the lambda-list.
+                 (save-excursion
+                   (goto-char containing-form-start)
+                   (down-list)
+                   (let ((key-indent nil)
+                         (next t))
+                     (while (and next (< (point) indent-point))
+                       (if (looking-at lisp-indent-lambda-list-keywords-regexp)
+                           (setq key-indent (current-column)
+                                 next nil)
+                         (setq next (ignore-errors (forward-sexp) t))
+                         (if next
+                             (ignore-errors
+                               (forward-sexp)
+                               (backward-sexp)))))
+                     (or key-indent
+                         (1+ sexp-column))))
                ;; Align to the beginning of the lambda-list.
                (1+ sexp-column)))
-          (t
-           ;; Otherwise, align to the first argument of the last lambda-list
-           ;; keyword, the keyword itself, or the beginning of the
-           ;; lambda-list.
-           (save-excursion
-             (goto-char indent-point)
-             (let ((indent nil)
-                   (next t))
-               (while (and next (> (point) containing-form-start))
-                 (setq next (ignore-errors (backward-sexp) t))
-                 (let* ((col (current-column))
-                        (pos
-                         (save-excursion
-                           (ignore-errors (forward-sexp))
-                           (skip-chars-forward " \t")
-                           (if (eolp)
-                               (+ col lisp-lambda-list-keyword-parameter-indentation)
-                             col))))
-                   (if (looking-at lisp-indent-lambda-list-keywords-regexp)
-                       (setq indent (if lisp-lambda-list-keyword-parameter-alignment
-                                        (or indent pos)
-                                      (+ col
-                                         lisp-lambda-list-keyword-parameter-indentation))
-                             next nil)
-                     (setq indent col))))
-               (or indent (1+ sexp-column))))))))
+            (t
+             ;; Otherwise, align to the first argument of the last lambda-list
+             ;; keyword, the keyword itself, or the beginning of the
+             ;; lambda-list.
+             (save-excursion
+               (goto-char indent-point)
+               (let ((indent nil)
+                     (next t))
+                 (while (and next (> (point) containing-form-start))
+                   (setq next (ignore-errors (backward-sexp) t))
+                   (let* ((col (current-column))
+                          (pos
+                           (save-excursion
+                             (ignore-errors (forward-sexp))
+                             (skip-chars-forward " \t")
+                             (if (eolp)
+                                 (+ col lisp-lambda-list-keyword-parameter-indentation)
+                               col))))
+                     (if (looking-at lisp-indent-lambda-list-keywords-regexp)
+                         (setq indent (if lisp-lambda-list-keyword-parameter-alignment
+                                          (or indent pos)
+                                        (+ col
+                                           lisp-lambda-list-keyword-parameter-indentation))
+                               next nil)
+                       (setq indent col))))
+                 (or indent (1+ sexp-column)))))))))
 
 ;; Blame the crufty control structure on dynamic scoping
 ;;  -- not on me!
@@ -1347,7 +1365,15 @@
        (((lisp-align-keywords-in-calls nil))
         "
     (make-instance 'foo :bar t quux t
-                   :zot t)"))))
+                   :zot t)")
+       (((lisp-lambda-list-indentation nil))
+        "
+      (defun example (a b &optional o1 o2
+                      o3 o4
+                      &rest r
+                      &key k1 k2
+                      k3 k4)
+        'hello)"))))
 
 
 





More information about the slime-cvs mailing list