diff options
| author | Glenn Morris | 2018-12-02 10:32:25 -0800 |
|---|---|---|
| committer | Glenn Morris | 2018-12-02 10:32:25 -0800 |
| commit | e5634aae531ce932ecb8d84243d690c7ca89bec3 (patch) | |
| tree | 9b65030fca17dcb52be481ed229ad4b321cb866e | |
| parent | 5f6d7a4f9d5970e6cb1dfc3bd8cdfa4651cf0678 (diff) | |
| parent | 745c9c02582443680167501b218cc59f1a2d3fb6 (diff) | |
| download | emacs-e5634aae531ce932ecb8d84243d690c7ca89bec3.tar.gz emacs-e5634aae531ce932ecb8d84243d690c7ca89bec3.zip | |
Merge from origin/emacs-26
745c9c0 (origin/emacs-26) Revert "Revert "Fix infloop in GC mark_kboa...
c418c85 Revert "Fix infloop in GC mark_kboards"
8fa0d96 * lisp/emacs-lisp/subr-x.el (if-let, when-let): Doc fix: acti...
| -rw-r--r-- | lisp/emacs-lisp/subr-x.el | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 20eb0d5d05c..3d59af2505d 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el | |||
| @@ -122,7 +122,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol." | |||
| 122 | bindings))) | 122 | bindings))) |
| 123 | 123 | ||
| 124 | (defmacro if-let* (varlist then &rest else) | 124 | (defmacro if-let* (varlist then &rest else) |
| 125 | "Bind variables according to VARLIST and eval THEN or ELSE. | 125 | "Bind variables according to VARLIST and evaluate THEN or ELSE. |
| 126 | This is like `if-let' but doesn't handle a VARLIST of the form | 126 | 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) |
| @@ -136,14 +136,14 @@ This is like `if-let' but doesn't handle a VARLIST of the form | |||
| 136 | `(let* () ,then))) | 136 | `(let* () ,then))) |
| 137 | 137 | ||
| 138 | (defmacro when-let* (varlist &rest body) | 138 | (defmacro when-let* (varlist &rest body) |
| 139 | "Bind variables according to VARLIST and conditionally eval 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) (debug if-let*)) | 142 | (declare (indent 1) (debug if-let*)) |
| 143 | (list 'if-let* varlist (macroexp-progn body))) | 143 | (list 'if-let* varlist (macroexp-progn body))) |
| 144 | 144 | ||
| 145 | (defmacro and-let* (varlist &rest body) | 145 | (defmacro and-let* (varlist &rest body) |
| 146 | "Bind variables according to VARLIST and conditionally eval BODY. | 146 | "Bind variables according to VARLIST and conditionally evaluate BODY. |
| 147 | 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 |
| 148 | are non-nil, then the result is non-nil." | 148 | are non-nil, then the result is non-nil." |
| 149 | (declare (indent 1) | 149 | (declare (indent 1) |
| @@ -157,22 +157,20 @@ are non-nil, then the result is non-nil." | |||
| 157 | `(let* () ,@(or body '(t)))))) | 157 | `(let* () ,@(or body '(t)))))) |
| 158 | 158 | ||
| 159 | (defmacro if-let (spec then &rest else) | 159 | (defmacro if-let (spec then &rest else) |
| 160 | "Bind variables according to SPEC and eval THEN or ELSE. | 160 | "Bind variables according to SPEC and evaluate THEN or ELSE. |
| 161 | Each binding is evaluated in turn, and evaluation stops if a | 161 | Evaluate each binding in turn, stopping if a binding value is nil. |
| 162 | binding value is nil. If all are non-nil, the value of THEN is | 162 | If all are non-nil return the value of THEN, otherwise the last form in ELSE. |
| 163 | returned, or the last form in ELSE is returned. | ||
| 164 | 163 | ||
| 165 | Each element of SPEC is a list (SYMBOL VALUEFORM) which binds | 164 | Each element of SPEC is a list (SYMBOL VALUEFORM) that binds |
| 166 | SYMBOL to the value of VALUEFORM. An element can additionally be | 165 | SYMBOL to the value of VALUEFORM. An element can additionally be |
| 167 | of the form (VALUEFORM), which is evaluated and checked for nil; | 166 | of the form (VALUEFORM), which is evaluated and checked for nil; |
| 168 | i.e. SYMBOL can be omitted if only the test result is of | 167 | i.e. SYMBOL can be omitted if only the test result is of |
| 169 | interest. It can also be of the form SYMBOL, then the binding of | 168 | interest. It can also be of the form SYMBOL, then the binding of |
| 170 | SYMBOL is checked for nil. | 169 | SYMBOL is checked for nil. |
| 171 | 170 | ||
| 172 | As a special case, a SPEC of the form \(SYMBOL SOMETHING) is | 171 | As a special case, interprets a SPEC of the form \(SYMBOL SOMETHING) |
| 173 | interpreted like \((SYMBOL SOMETHING)). This exists for backward | 172 | like \((SYMBOL SOMETHING)). This exists for backward compatibility |
| 174 | compatibility with the old syntax that accepted only one | 173 | with an old syntax that accepted only one binding." |
| 175 | binding." | ||
| 176 | (declare (indent 2) | 174 | (declare (indent 2) |
| 177 | (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) | 175 | (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) |
| 178 | (symbolp form)] | 176 | (symbolp form)] |
| @@ -184,10 +182,9 @@ binding." | |||
| 184 | (list 'if-let* spec then (macroexp-progn else))) | 182 | (list 'if-let* spec then (macroexp-progn else))) |
| 185 | 183 | ||
| 186 | (defmacro when-let (spec &rest body) | 184 | (defmacro when-let (spec &rest body) |
| 187 | "Bind variables according to SPEC and conditionally eval BODY. | 185 | "Bind variables according to SPEC and conditionally evaluate BODY. |
| 188 | Each binding is evaluated in turn, and evaluation stops if a | 186 | Evaluate each binding in turn, stopping if a binding value is nil. |
| 189 | binding value is nil. If all are non-nil, the value of the last | 187 | If all are non-nil, return the value of the last form in BODY. |
| 190 | form in BODY is returned. | ||
| 191 | 188 | ||
| 192 | The variable list SPEC is the same as in `if-let'." | 189 | The variable list SPEC is the same as in `if-let'." |
| 193 | (declare (indent 1) (debug if-let)) | 190 | (declare (indent 1) (debug if-let)) |