# HG changeset patch # User Steve Losh # Date 1461172707 0 # Node ID 9bead8a9b4350c57f8a24a8119607a83a9592afe # Parent 08965030b28bb6dc81b109b6e8dc38f77f1a36fa More lispindent shit diff -r 08965030b28b -r 9bead8a9b435 lispwords --- a/lispwords Wed Apr 20 10:38:25 2016 +0000 +++ b/lispwords Wed Apr 20 17:18:27 2016 +0000 @@ -15,6 +15,7 @@ ; defstar (2 defun*) +(1 *let) ; alexandria / utils (1 switch eswitch cswitch) diff -r 08965030b28b -r 9bead8a9b435 roswell/lispindent.ros --- a/roswell/lispindent.ros Wed Apr 20 10:38:25 2016 +0000 +++ b/roswell/lispindent.ros Wed Apr 20 17:18:27 2016 +0000 @@ -33,6 +33,7 @@ (defvar *lisp-keywords* '()) (defvar *labels-keywords* '(labels flet macrolet)) (defvar *lambda-list-keywords* '(defun defmethod)) +(defvar *case-keywords* '(cond case)) (defun define-with-lisp-indent-number (n syms) @@ -149,23 +150,31 @@ :key #'symbol-name :test #'string-equal) (= (lparen-num-processed-subforms target) 0)))) +(defun in-case-p (stack) + (let ((target (car stack))) + (and target + (member (lparen-word target) *case-keywords* + :key #'symbol-name :test #'string-equal)))) + + (defun calc-subindent (stack s i n) (let* ((j (past-next-token s i n)) (num-aligned-subforms 0) (left-indent - (if (= j i) 1 - (let ((w (subseq s i j))) - (if (and (>= i 2) (member (char s (- i 2)) '(#\' #\`))) 1 - (let ((nas (if (in-labels-p stack) - 1 - (lisp-indent-number w)))) - (cond ((in-lambda-list-p stack) 1) - ((>= nas 0) (setq num-aligned-subforms nas) - 2) - ((literal-token-p w) 1) - ((= j n) 2) - (t (+ (- j i) 2))))))))) + (if (= j i) 1 + (let ((w (subseq s i j))) + (if (and (>= i 2) (member (char s (- i 2)) '(#\' #\`))) 1 + (let ((nas (if (in-labels-p stack) + 1 + (lisp-indent-number w)))) + (cond ((or (in-lambda-list-p stack) + (in-case-p stack)) 1) + ((>= nas 0) (setq num-aligned-subforms nas) + 2) + ((literal-token-p w) 1) + ((= j n) 2) + (t (+ (- j i) 2))))))))) (values left-indent num-aligned-subforms (1- j)))) (defun num-leading-spaces (s)