branch: elpa/cond-let
commit 87d587fa632b6564b03b8fcdbf8498130dc85c91
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    Improve indentation of cond
    
    Emacs 31.1 adds variable `lisp-indent-local-overrides'.
---
 .dir-locals.el |  2 ++
 cond-let.el    | 64 +++++++++++++++++++++++++++++-----------------------------
 2 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 7c6424f0657..f1fff942652 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,5 +1,7 @@
 ((nil
   (indent-tabs-mode . nil))
+ (emacs-lisp-mode
+  (lisp-indent-local-overrides . ((cond . 0) (interactive . 0))))
  (makefile-mode
   (indent-tabs-mode . t))
  (git-commit-mode
diff --git a/cond-let.el b/cond-let.el
index 6ded949b4cf..8c6411b20b4 100644
--- a/cond-let.el
+++ b/cond-let.el
@@ -92,38 +92,38 @@
   (let (body)
     (dolist (clause (nreverse clauses))
       (cond
-       ((vectorp clause)
-        (setq body
-              `((,(if (and sequential (length> clause 1)) 'let* 'let)
-                 ,(mapcar (lambda (vec) (append vec nil)) clause)
-                 ,@body))))
-       ((let (varlist)
-          (while (vectorp (car clause))
-            (push (append (pop clause) nil) varlist))
-          (push (cond
-                 (varlist
-                  `(,(pcase (list (and body t)
-                                  (and sequential (length> varlist 1)))
-                       ('(t   t ) 'cond-let--when-let*)
-                       (`(t   ,_) 'cond-let--when-let)
-                       ('(nil t ) 'cond-let--and-let*)
-                       (`(nil ,_) 'cond-let--and-let))
-                    ,(nreverse varlist)
-                    ,(if body
-                         `(throw ',tag ,(macroexp-progn clause))
-                       (macroexp-progn clause))))
-                 ((length= clause 1)
-                  (if body
-                      (let ((a (gensym "anon")))
-                        `(let ((,a ,(car clause)))
-                           (when ,a (throw ',tag ,a))))
-                    (car clause)))
-                 ((and (eq (car clause) t) (not body))
-                  (macroexp-progn (cdr clause)))
-                 (t
-                  `(when ,(pop clause)
-                     (throw ',tag ,(macroexp-progn clause)))))
-                body)))))
+        ((vectorp clause)
+         (setq body
+               `((,(if (and sequential (length> clause 1)) 'let* 'let)
+                  ,(mapcar (lambda (vec) (append vec nil)) clause)
+                  ,@body))))
+        ((let (varlist)
+           (while (vectorp (car clause))
+             (push (append (pop clause) nil) varlist))
+           (push (cond
+                   (varlist
+                    `(,(pcase (list (and body t)
+                                    (and sequential (length> varlist 1)))
+                         ('(t   t ) 'cond-let--when-let*)
+                         (`(t   ,_) 'cond-let--when-let)
+                         ('(nil t ) 'cond-let--and-let*)
+                         (`(nil ,_) 'cond-let--and-let))
+                      ,(nreverse varlist)
+                      ,(if body
+                           `(throw ',tag ,(macroexp-progn clause))
+                         (macroexp-progn clause))))
+                   ((length= clause 1)
+                    (if body
+                        (let ((a (gensym "anon")))
+                          `(let ((,a ,(car clause)))
+                             (when ,a (throw ',tag ,a))))
+                      (car clause)))
+                   ((and (eq (car clause) t) (not body))
+                    (macroexp-progn (cdr clause)))
+                   (t
+                    `(when ,(pop clause)
+                       (throw ',tag ,(macroexp-progn clause)))))
+                 body)))))
     body))
 
 (defmacro cond-let* (&rest clauses)

Reply via email to