[slime-cvs] CVS slime/contrib
CVS User nsiivola
nsiivola at common-lisp.net
Wed Apr 4 12:04:42 UTC 2012
Update of /project/slime/cvsroot/slime/contrib
In directory tiger.common-lisp.net:/tmp/cvs-serv3344/contrib
Modified Files:
ChangeLog slime-cl-indent-test.txt slime-cl-indent.el
Log Message:
slime-indentation: identify initial-value-forms in lambda-lists
...and indent them as regular code, not as lambda-lists.
--- /project/slime/cvsroot/slime/contrib/ChangeLog 2012/03/30 10:40:21 1.539
+++ /project/slime/cvsroot/slime/contrib/ChangeLog 2012/04/04 12:04:42 1.540
@@ -1,3 +1,12 @@
+2012-04-04 Nikodemus Siivola <nikodemus at random-state.net>
+
+ * slime-cl-indent.el (common-lisp-lambda-list-initial-value-form-p): New function.
+ Identifies initial-value-forms from lambda-lists, allowing them to be indented
+ as regular code.
+ (lisp-indent-259): Use the previous when indenting using &lambda to punt to
+ normal indentation when approriate.
+ * slime-cl-indent-test.txt (Test 87): Test indentation of initial-value forms.
+
2012-03-19 Stas Boukarev <stassats at gmail.com>
* swank-arglists.lisp (compute-enriched-decoded-arglist): Add
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt 2012/03/30 10:40:21 1.19
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent-test.txt 2012/04/04 12:04:42 1.20
@@ -910,3 +910,19 @@
(foo (
bar quux
zor))
+
+;;; Test: 87
+;;
+;; lisp-lambda-list-keyword-parameter-alignment: t
+;; lisp-lambda-list-keyword-alignment: t
+
+(defmacro foo ((foo &optional (opt1 (or (this)
+ (that)))
+ (opt2 (the-default)
+ opt2-p)
+ (opt3
+ (the-default (foo)
+ (bar)))
+ &rest rest))
+ (list foo opt1 opt2
+ rest))
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2012/03/30 10:40:21 1.63
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2012/04/04 12:04:42 1.64
@@ -950,6 +950,7 @@
(setq depth (1+ depth)))
(error
(setq depth lisp-indent-maximum-backtracking))))))
+
(or calculated tentative-calculated
;; Fallback.
;;
@@ -1088,9 +1089,45 @@
(+ col
lisp-lambda-list-keyword-parameter-indentation))
next nil)
- (setq indent col))))
+ (progn
+ (setq indent col)))))
(or indent (1+ sexp-column)))))))))
+(defun common-lisp-lambda-list-initial-value-form-p (point)
+ (let ((state 'x)
+ (point (save-excursion
+ (goto-char point)
+ (back-to-indentation)
+ (point))))
+ (save-excursion
+ (backward-sexp)
+ (down-list 1)
+ (while (and point (< (point) point))
+ (cond ((or (looking-at "&key") (looking-at "&optional"))
+ (setq state 'key))
+ ((looking-at lisp-indent-lambda-list-keywords-regexp)
+ (setq state 'x)))
+ (if (not (ignore-errors (forward-sexp) t))
+ (setq point nil)
+ (ignore-errors
+ (forward-sexp)
+ (backward-sexp))
+ (cond ((> (point) point)
+ (backward-sexp)
+ (when (eq state 'var)
+ (setq state 'x))
+ (or (ignore-errors
+ (down-list 1)
+ (cond ((> (point) point)
+ (backward-up-list))
+ ((eq 'key state)
+ (setq state 'var)))
+ t)
+ (setq point nil)))
+ ((eq state 'var)
+ (setq state 'form))))))
+ (eq 'form state)))
+
;; Blame the crufty control structure on dynamic scoping
;; -- not on me!
(defun lisp-indent-259
@@ -1148,16 +1185,20 @@
normal-indent
(list normal-indent containing-form-start))))
((eq tem '&lambda)
- (throw 'exit
- (cond ((null p)
- (list (+ sexp-column 4) containing-form-start))
- (t
- ;; Indentation within a lambda-list. -- dvl
- (list (lisp-indent-lambda-list
- indent-point
- sexp-column
- containing-form-start)
- containing-form-start)))))
+ (if (common-lisp-lambda-list-initial-value-form-p indent-point)
+ (throw 'exit (if (consp normal-indent)
+ normal-indent
+ (list normal-indent containing-form-start)))
+ (throw 'exit
+ (cond ((null p)
+ (list (+ sexp-column 4) containing-form-start))
+ (t
+ ;; Indentation within a lambda-list. -- dvl
+ (list (lisp-indent-lambda-list
+ indent-point
+ sexp-column
+ containing-form-start)
+ containing-form-start))))))
((integerp tem)
(throw 'exit
(if (null p) ;not in subforms
More information about the slime-cvs
mailing list