mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-07 06:50:23 -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:
parent
43fd13770a
commit
84e207c811
1 changed files with 5 additions and 12 deletions
|
|
@ -127,7 +127,7 @@ This is like `if-let' but doesn't handle a VARLIST of the form
|
||||||
\(SYMBOL SOMETHING) specially."
|
\(SYMBOL SOMETHING) specially."
|
||||||
(declare (indent 2)
|
(declare (indent 2)
|
||||||
(debug ((&rest [&or symbolp (symbolp form) (form)])
|
(debug ((&rest [&or symbolp (symbolp form) (form)])
|
||||||
form body)))
|
body)))
|
||||||
(if varlist
|
(if varlist
|
||||||
`(let* ,(setq varlist (internal--build-bindings varlist))
|
`(let* ,(setq varlist (internal--build-bindings varlist))
|
||||||
(if ,(caar (last 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.
|
"Bind variables according to VARLIST and conditionally evaluate BODY.
|
||||||
This is like `when-let' but doesn't handle a VARLIST of the form
|
This is like `when-let' but doesn't handle a VARLIST of the form
|
||||||
\(SYMBOL SOMETHING) specially."
|
\(SYMBOL SOMETHING) specially."
|
||||||
(declare (indent 1)
|
(declare (indent 1) (debug if-let*))
|
||||||
(debug ((&rest [&or symbolp (symbolp form) (form)])
|
|
||||||
body)))
|
|
||||||
(list 'if-let* varlist (macroexp-progn body)))
|
(list 'if-let* varlist (macroexp-progn body)))
|
||||||
|
|
||||||
(defmacro and-let* (varlist &rest body)
|
(defmacro and-let* (varlist &rest body)
|
||||||
"Bind variables according to VARLIST and conditionally evaluate BODY.
|
"Bind variables according to VARLIST and conditionally evaluate BODY.
|
||||||
Like `when-let*', except if BODY is empty and all the bindings
|
Like `when-let*', except if BODY is empty and all the bindings
|
||||||
are non-nil, then the result is non-nil."
|
are non-nil, then the result is non-nil."
|
||||||
(declare (indent 1)
|
(declare (indent 1) (debug if-let*))
|
||||||
(debug ((&rest [&or symbolp (symbolp form) (form)])
|
|
||||||
body)))
|
|
||||||
(let (res)
|
(let (res)
|
||||||
(if varlist
|
(if varlist
|
||||||
`(let* ,(setq varlist (internal--build-bindings varlist))
|
`(let* ,(setq varlist (internal--build-bindings varlist))
|
||||||
|
|
@ -178,7 +174,7 @@ with an old syntax that accepted only one binding."
|
||||||
(declare (indent 2)
|
(declare (indent 2)
|
||||||
(debug ([&or (symbolp form) ; must be first, Bug#48489
|
(debug ([&or (symbolp form) ; must be first, Bug#48489
|
||||||
(&rest [&or symbolp (symbolp form) (form)])]
|
(&rest [&or symbolp (symbolp form) (form)])]
|
||||||
form body)))
|
body)))
|
||||||
(when (and (<= (length spec) 2)
|
(when (and (<= (length spec) 2)
|
||||||
(not (listp (car spec))))
|
(not (listp (car spec))))
|
||||||
;; Adjust the single binding case
|
;; 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.
|
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'."
|
The variable list SPEC is the same as in `if-let'."
|
||||||
(declare (indent 1)
|
(declare (indent 1) (debug if-let))
|
||||||
(debug ([&or (symbolp form) ; must be first, Bug#48489
|
|
||||||
(&rest [&or symbolp (symbolp form) (form)])]
|
|
||||||
body)))
|
|
||||||
(list 'if-let spec (macroexp-progn body)))
|
(list 'if-let spec (macroexp-progn body)))
|
||||||
|
|
||||||
(defsubst hash-table-empty-p (hash-table)
|
(defsubst hash-table-empty-p (hash-table)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue