[slime-cvs] CVS slime/contrib
CVS User nsiivola
nsiivola at common-lisp.net
Sun May 15 17:18:52 UTC 2011
Update of /project/slime/cvsroot/slime/contrib
In directory common-lisp.net:/tmp/cvs-serv1717/contrib
Modified Files:
ChangeLog slime-cl-indent.el
Log Message:
slime-indentation: sexp-based traversal for lambda-list indentation
Fixes indentation of destructuring lambda-lists.
Not:
(defmacro with-foo ((foo &rest args)
&body body)
...)
but:
(defmacro with-foo ((foo &rest args)
&body body)
...)
--- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:21 1.444
+++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:52 1.445
@@ -1,3 +1,11 @@
+2011-05-12 Nikodemus Siivola <nikodemus at random-state.net>
+
+ * slime-cl-indent.el (lisp-indent-lambda-list): Use sexp-based
+ traversal instead of regular expressions to figure out how to
+ indent lambda-lists. Allows indenting destructuring lambda-lists correctly:
+ previously we could align to a keyword in a previous sublist, instead
+ of the sublist itself.
+
2011-05-11 Nikodemus Siivola <nikodemus at random-state.net>
* slime-cl-indent.el (common-lisp-indent-function-1): Handle
--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:21 1.10
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:52 1.11
@@ -445,13 +445,19 @@
;; the lambda-list.
(save-excursion
(goto-char containing-form-start)
- (save-match-data
- (if (re-search-forward
- lisp-indent-lambda-list-keywords-regexp
- limit t)
- (progn
- (goto-char (match-beginning 0))
- (current-column))
+ (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)))
@@ -461,26 +467,26 @@
;; lambda-list.
(save-excursion
(goto-char indent-point)
- (forward-line -1)
- (end-of-line)
- (save-match-data
- (if (re-search-backward lisp-indent-lambda-list-keywords-regexp
- containing-form-start t)
- (let* ((keyword-posn
- (progn
- (goto-char (match-beginning 0))
- (current-column)))
- (indented-keyword-posn
- (+ keyword-posn
- lisp-lambda-list-keyword-parameter-indentation)))
- (goto-char (match-end 0))
- (skip-chars-forward " \t")
- (if (eolp)
- indented-keyword-posn
- (if lisp-lambda-list-keyword-parameter-alignment
- (current-column)
- indented-keyword-posn)))
- (1+ sexp-column))))))))
+ (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!
More information about the slime-cvs
mailing list