1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00

* lisp/emacs-lisp/subr-x.el (if-let*, if-let): Use looser Edebug spec

This makes the same spec work both for `if-let` and `when-let`.

(when-let*, and-let*, when-let): Simplify accordingly.
This commit is contained in:
Stefan Monnier 2021-05-22 10:21:59 -04:00
parent 43fd13770a
commit 84e207c811

View file

@ -127,7 +127,7 @@ This is like `if-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially."
(declare (indent 2)
(debug ((&rest [&or symbolp (symbolp form) (form)])
form body)))
body)))
(if varlist
`(let* ,(setq varlist (internal--build-bindings varlist))
(if ,(caar (last varlist))
@ -139,18 +139,14 @@ This is like `if-let' but doesn't handle a VARLIST of the form
"Bind variables according to VARLIST and conditionally evaluate BODY.
This is like `when-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially."
(declare (indent 1)
(debug ((&rest [&or symbolp (symbolp form) (form)])
body)))
(declare (indent 1) (debug if-let*))
(list 'if-let* varlist (macroexp-progn body)))
(defmacro and-let* (varlist &rest body)
"Bind variables according to VARLIST and conditionally evaluate BODY.
Like `when-let*', except if BODY is empty and all the bindings
are non-nil, then the result is non-nil."
(declare (indent 1)
(debug ((&rest [&or symbolp (symbolp form) (form)])
body)))
(declare (indent 1) (debug if-let*))
(let (res)
(if varlist
`(let* ,(setq varlist (internal--build-bindings varlist))
@ -178,7 +174,7 @@ with an old syntax that accepted only one binding."
(declare (indent 2)
(debug ([&or (symbolp form) ; must be first, Bug#48489
(&rest [&or symbolp (symbolp form) (form)])]
form body)))
body)))
(when (and (<= (length spec) 2)
(not (listp (car spec))))
;; Adjust the single binding case
@ -192,10 +188,7 @@ Evaluate each binding in turn, stopping if a binding value is nil.
If all are non-nil, return the value of the last form in BODY.
The variable list SPEC is the same as in `if-let'."
(declare (indent 1)
(debug ([&or (symbolp form) ; must be first, Bug#48489
(&rest [&or symbolp (symbolp form) (form)])]
body)))
(declare (indent 1) (debug if-let))
(list 'if-let spec (macroexp-progn body)))
(defsubst hash-table-empty-p (hash-table)