9bead8a9b435

More lispindent shit
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 20 Apr 2016 17:18:27 +0000
parents 08965030b28b
children 86bde83af492
branches/tags (none)
files lispwords roswell/lispindent.ros

Changes

--- 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)
--- 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)