diff options
| author | Stefan Monnier | 2021-05-22 10:21:59 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2021-05-22 10:21:59 -0400 |
| commit | 84e207c81187ff46fb94775ccb24d9b76b80db9c (patch) | |
| tree | 2d61869fc98242e662333617fbcbf9f4022199c9 | |
| parent | 43fd13770a8ac8452669e4de3281e9189cb36c5a (diff) | |
| download | emacs-84e207c81187ff46fb94775ccb24d9b76b80db9c.tar.gz emacs-84e207c81187ff46fb94775ccb24d9b76b80db9c.zip | |
* 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.
| -rw-r--r-- | lisp/emacs-lisp/subr-x.el | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 72406df0ff7..1c13c398dde 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el | |||
| @@ -127,7 +127,7 @@ This is like `if-let' but doesn't handle a VARLIST of the form | |||
| 127 | \(SYMBOL SOMETHING) specially." | 127 | \(SYMBOL SOMETHING) specially." |
| 128 | (declare (indent 2) | 128 | (declare (indent 2) |
| 129 | (debug ((&rest [&or symbolp (symbolp form) (form)]) | 129 | (debug ((&rest [&or symbolp (symbolp form) (form)]) |
| 130 | form body))) | 130 | body))) |
| 131 | (if varlist | 131 | (if varlist |
| 132 | `(let* ,(setq varlist (internal--build-bindings varlist)) | 132 | `(let* ,(setq varlist (internal--build-bindings varlist)) |
| 133 | (if ,(caar (last varlist)) | 133 | (if ,(caar (last varlist)) |
| @@ -139,18 +139,14 @@ This is like `if-let' but doesn't handle a VARLIST of the form | |||
| 139 | "Bind variables according to VARLIST and conditionally evaluate BODY. | 139 | "Bind variables according to VARLIST and conditionally evaluate BODY. |
| 140 | This is like `when-let' but doesn't handle a VARLIST of the form | 140 | This is like `when-let' but doesn't handle a VARLIST of the form |
| 141 | \(SYMBOL SOMETHING) specially." | 141 | \(SYMBOL SOMETHING) specially." |
| 142 | (declare (indent 1) | 142 | (declare (indent 1) (debug if-let*)) |
| 143 | (debug ((&rest [&or symbolp (symbolp form) (form)]) | ||
| 144 | body))) | ||
| 145 | (list 'if-let* varlist (macroexp-progn body))) | 143 | (list 'if-let* varlist (macroexp-progn body))) |
| 146 | 144 | ||
| 147 | (defmacro and-let* (varlist &rest body) | 145 | (defmacro and-let* (varlist &rest body) |
| 148 | "Bind variables according to VARLIST and conditionally evaluate BODY. | 146 | "Bind variables according to VARLIST and conditionally evaluate BODY. |
| 149 | Like `when-let*', except if BODY is empty and all the bindings | 147 | Like `when-let*', except if BODY is empty and all the bindings |
| 150 | are non-nil, then the result is non-nil." | 148 | are non-nil, then the result is non-nil." |
| 151 | (declare (indent 1) | 149 | (declare (indent 1) (debug if-let*)) |
| 152 | (debug ((&rest [&or symbolp (symbolp form) (form)]) | ||
| 153 | body))) | ||
| 154 | (let (res) | 150 | (let (res) |
| 155 | (if varlist | 151 | (if varlist |
| 156 | `(let* ,(setq varlist (internal--build-bindings varlist)) | 152 | `(let* ,(setq varlist (internal--build-bindings varlist)) |
| @@ -178,7 +174,7 @@ with an old syntax that accepted only one binding." | |||
| 178 | (declare (indent 2) | 174 | (declare (indent 2) |
| 179 | (debug ([&or (symbolp form) ; must be first, Bug#48489 | 175 | (debug ([&or (symbolp form) ; must be first, Bug#48489 |
| 180 | (&rest [&or symbolp (symbolp form) (form)])] | 176 | (&rest [&or symbolp (symbolp form) (form)])] |
| 181 | form body))) | 177 | body))) |
| 182 | (when (and (<= (length spec) 2) | 178 | (when (and (<= (length spec) 2) |
| 183 | (not (listp (car spec)))) | 179 | (not (listp (car spec)))) |
| 184 | ;; Adjust the single binding case | 180 | ;; Adjust the single binding case |
| @@ -192,10 +188,7 @@ Evaluate each binding in turn, stopping if a binding value is nil. | |||
| 192 | If all are non-nil, return the value of the last form in BODY. | 188 | If all are non-nil, return the value of the last form in BODY. |
| 193 | 189 | ||
| 194 | The variable list SPEC is the same as in `if-let'." | 190 | The variable list SPEC is the same as in `if-let'." |
| 195 | (declare (indent 1) | 191 | (declare (indent 1) (debug if-let)) |
| 196 | (debug ([&or (symbolp form) ; must be first, Bug#48489 | ||
| 197 | (&rest [&or symbolp (symbolp form) (form)])] | ||
| 198 | body))) | ||
| 199 | (list 'if-let spec (macroexp-progn body))) | 192 | (list 'if-let spec (macroexp-progn body))) |
| 200 | 193 | ||
| 201 | (defsubst hash-table-empty-p (hash-table) | 194 | (defsubst hash-table-empty-p (hash-table) |