[slime-cvs] CVS slime/contrib

CVS User nsiivola nsiivola at common-lisp.net
Mon Nov 28 18:38:34 UTC 2011


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

Modified Files:
	ChangeLog slime-cl-indent-test.txt slime-cl-indent.el 
Log Message:
slime-indentation: still more work on loop indentation

  (loop
    repeat 1000
    do ;; This is the
       ;; beginning
       (foo))

  (loop repeat 100 ;; This too
                   ;; is a beginning
        do (foo))


--- /project/slime/cvsroot/slime/contrib/ChangeLog	2011/11/28 12:46:56	1.510
+++ /project/slime/cvsroot/slime/contrib/ChangeLog	2011/11/28 18:38:34	1.511
@@ -1,5 +1,16 @@
 2011-11-28  Nikodemus Siivola  <nikodemus at random-state.net>
 
+	* slime-cl-indent.el (common-lisp-trailing-comment): New function.
+	Returns the column of a trailing comment.
+	(common-lisp-loop-part-indentation)
+	(common-lisp-indent-loop-macro-1): fix indentation of multiline
+	comments starting from a trailing position.
+
+
+	* slime-cl-indent-test.txt: Add tests 68 and 69.
+
+2011-11-28  Nikodemus Siivola  <nikodemus at random-state.net>
+
 	* slime-cl-indent.el: fix DEFCLASS and DEFINE-CONDITION superclass-list
 	indentation.
 
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt	2011/11/28 12:46:56	1.14
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt	2011/11/28 18:38:34	1.15
@@ -706,3 +706,33 @@
      xoo)
   ()
   (:metaclass foo-class))
+
+
+;;; Test: 68
+;;
+;; lisp-loop-indent-subclauses: nil
+
+(progn
+  (loop
+    repeat 1000
+    do ;; This is the
+       ;; beginning
+       (foo))
+  (loop repeat 100 ;; This too
+                   ;; is a beginning
+        do (foo)))
+
+;;; Test: 69
+;;
+;; lisp-loop-indent-subclauses: t
+
+(progn
+  (loop
+    repeat 1000
+    do ;; This is the
+       ;; beginning
+       (foo))
+  (loop repeat 100 ;; This too
+                   ;; is a beginning
+        do (foo)))
+
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/11/28 12:46:56	1.56
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/11/28 18:38:34	1.57
@@ -611,6 +611,16 @@
            'simple/split
          'simple)))))
 
+(defun common-lisp-trailing-comment ()
+  (ignore-errors
+    ;; If we had a trailing comment just before this, find it.
+    (save-excursion
+      (backward-sexp)
+      (forward-sexp)
+      (when (looking-at "\\s-*;")
+        (search-forward ";")
+        (1- (current-column))))))
+
 (defun common-lisp-loop-part-indentation (indent-point state type)
   "Compute the indentation of loop form constituents."
   (let* ((loop-start (elt state 1))
@@ -639,7 +649,12 @@
            (list indent loop-start))
           ;; Keyword-style or comment outside body
           ((or lisp-loop-indent-forms-like-keywords (looking-at re) (looking-at ";"))
-           (list (+ loop-indentation 6) loop-start))
+           (if (and (looking-at ";")
+                    (let ((p (common-lisp-trailing-comment)))
+                      (when p
+                        (setq loop-indentation p))))
+               (list loop-indentation loop-start)
+             (list (+ loop-indentation 6) loop-start)))
           ;; Form-style
           (t
            (list (+ loop-indentation 9) loop-start)))))
@@ -1378,7 +1393,8 @@
             ;; vanilla clause.
             (if loop-body-p
                 loop-body-indentation
-              default-value))
+              (or (and (looking-at ";") (common-lisp-trailing-comment))
+                  default-value)))
            ((looking-at common-lisp-indent-indented-loop-macro-keyword)
             indented-clause-indentation)
            ((looking-at common-lisp-indent-clause-joining-loop-macro-keyword)
@@ -1681,6 +1697,6 @@
 ;;;   (common-lisp-run-indentation-tests t)
 ;;;
 ;;; Run specific test:
-;;;   (common-lisp-run-indentation-tests 17)
+;;;   (common-lisp-run-indentation-tests 69)
 
 ;;; cl-indent.el ends here





More information about the slime-cvs mailing list