[slime-cvs] CVS slime/contrib

CVS User nsiivola nsiivola at common-lisp.net
Sun May 15 17:13:28 UTC 2011


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

Modified Files:
	ChangeLog slime-cl-indent.el 
Log Message:
slime-indentation: handle both split and unsplit loops

 A "split" loop is one where the body does not start on the same
 line as the opening parenthesis:

   (loop
     for x in ...)

 Replace extended-loop-p with common-lisp-loop-type, returning
 either 'simple, 'extended, or 'extended/split.

 Adjust indentation in common-lisp-loop-part-indentation
 based on that.

 Since previously loop customization variables were mostly
 for picking either the split or the unsplit style, remove
 them except for lisp-simple-loop-indentation: old settings
 for the others would not produce the intended results anymore.

 Now both

   (loop for x in list1
         for y in ...)

 and

   (loop
     for x in list1
     for y in ...)

 styles work out of the box.


--- /project/slime/cvsroot/slime/contrib/ChangeLog	2011/05/15 17:11:25	1.440
+++ /project/slime/cvsroot/slime/contrib/ChangeLog	2011/05/15 17:13:28	1.441
@@ -1,5 +1,17 @@
 2011-05-10  Nikodemus Siivola  <nikodemus at random-state.net>
 
+	* slime-cl-indent.el (common-lisp-loop-type): New function,
+	replaces extended-loop-p.
+	(common-lisp-loop-part-indentation): Use common-lisp-loop-type to
+	decide how to indent, supporting both "split" and "unsplit" styles.
+	(lisp-loop-keyword-indentation, lisp-loop-forms-indentation):
+	Deleted: pointless now that both split and unsplit styles work
+	automatically.
+	(extended-loop-p): Deleted.
+	(lisp-simple-loop-indentation): Change default to 2.
+
+2011-05-10  Nikodemus Siivola  <nikodemus at random-state.net>
+
 	* slime-cl-indent.el (common-lisp-loop-part-indentation): Return
 	(<indent> <loop-start>) instead of <indent> for non-simple loops.
 	This lets calculate-lisp-indent know that the following lines of
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/15 17:11:25	1.6
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/15 17:13:28	1.7
@@ -69,20 +69,7 @@
   :type 'boolean
   :group 'lisp-indent)
 
-
-(defcustom lisp-loop-keyword-indentation 3
-  "Indentation of loop keywords in extended loop forms."
-  :type 'integer
-  :group 'lisp-indent)
-
-
-(defcustom lisp-loop-forms-indentation 5
-  "Indentation of forms in extended loop forms."
-  :type 'integer
-  :group 'lisp-indent)
-
-
-(defcustom lisp-simple-loop-indentation 3
+(defcustom lisp-simple-loop-indentation 2
   "Indentation of forms in simple loop forms."
   :type 'integer
   :group 'lisp-indent)
@@ -137,32 +124,43 @@
 This applies when the value of the `common-lisp-indent-function' property
 is set to `defun'.") 
 
-
-(defun extended-loop-p (loop-start)
-  "True if an extended loop form starts at LOOP-START."
+(defun common-lisp-loop-type (loop-start)
+  "Returns the type of the loop form at LOOP-START.
+Possible types are SIMPLE, EXTENDED, and EXTENDED/SPLIT.
+EXTENDED/SPLIT refers to extended loops whose body does
+not start on the same line as the opening parenthesis of
+the loop."
   (condition-case ()
       (save-excursion
-	(goto-char loop-start)
-	(forward-char 1)
-	(forward-sexp 2)
-	(backward-sexp 1)
-	(looking-at "\\sw"))
-    (error t)))
+        (goto-char loop-start)
+        (let ((line (line-number-at-pos)))
+          (forward-char 1)
+          (forward-sexp 2)
+          (backward-sexp 1)
+          (if (looking-at "\\sw")
+              (if (= line (line-number-at-pos))
+                  'extended
+                'extended/split)
+            'simple)))
+    (error 'simple)))
 
 (defun common-lisp-loop-part-indentation (indent-point state)
   "Compute the indentation of loop form constituents."
   (let* ((loop-start (elt state 1))
+         (type (common-lisp-loop-type loop-start))
          (loop-indentation (save-excursion
 			     (goto-char loop-start)
-			     (current-column))))
+			     (if (eq 'extended/split type)
+                                 (- (current-column) 4)
+                               (current-column)))))
     (goto-char indent-point)
     (beginning-of-line)
-    (cond ((not (extended-loop-p loop-start))
+    (cond ((eq 'simple type)
            (+ loop-indentation lisp-simple-loop-indentation))
           ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)")
-           (list (+ loop-indentation lisp-loop-keyword-indentation) loop-start))
+           (list (+ loop-indentation 6) loop-start))
           (t
-           (list (+ loop-indentation lisp-loop-forms-indentation) loop-start)))))
+           (list (+ loop-indentation 9) loop-start)))))
 
 
 ;;;###autoload





More information about the slime-cvs mailing list