diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-04-11 15:10:51 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-04-11 15:10:51 -0400 |
commit | 6a480c830bc8d313ca3052570487a65411c937c2 (patch) | |
tree | 37fb9665e32576097d3c28ddea81af877924e9ee /lisp/emacs-lisp | |
parent | d6338f8a6a5670d7d7075aa277896d9f74723c7a (diff) | |
download | emacs-6a480c830bc8d313ca3052570487a65411c937c2.tar.gz emacs-6a480c830bc8d313ca3052570487a65411c937c2.tar.bz2 emacs-6a480c830bc8d313ca3052570487a65411c937c2.zip |
* lisp/emacs-lisp/macroexp.el (macroexp-let2*): Allow common shorthand
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/macroexp.el | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index e91b302af10..e4bc2df2803 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -567,12 +567,20 @@ cases where EXP is a constant." (defmacro macroexp-let2* (test bindings &rest body) "Multiple binding version of `macroexp-let2'. -BINDINGS is a list of elements of the form (SYM EXP). Each EXP -can refer to symbols specified earlier in the binding list." +BINDINGS is a list of elements of the form (SYM EXP) or just SYM, +which then stands for (SYM SYM). +Each EXP can refer to symbols specified earlier in the binding list. + +TEST has to be a symbol, and if it is nil it can be omitted." (declare (indent 2) (debug (sexp (&rest (sexp form)) body))) + (when (consp test) ;; `test' was omitted. + (push bindings body) + (setq bindings test) + (setq test nil)) (pcase-exhaustive bindings ('nil (macroexp-progn body)) - (`((,var ,exp) . ,tl) + (`(,(or `(,var ,exp) (and (pred symbolp) var (let exp var))) + . ,tl) `(macroexp-let2 ,test ,var ,exp (macroexp-let2* ,test ,tl ,@body))))) |