diff options
| author | Sean Whitton | 2024-11-27 10:36:53 +0800 |
|---|---|---|
| committer | Sean Whitton | 2024-11-27 10:36:53 +0800 |
| commit | e4abb06e5bf982a4688de0638b1eeecf4ff38d95 (patch) | |
| tree | 6e4a7c330ea576179f5294dffd224d6ab274d7de | |
| parent | 0624fe6f8497a677ae354da0a604dbf82e69400a (diff) | |
| download | emacs-e4abb06e5bf982a4688de0638b1eeecf4ff38d95.tar.gz emacs-e4abb06e5bf982a4688de0638b1eeecf4ff38d95.zip | |
* lisp/subr.el (when-let): Reimplement so as to avoid bug#74530.
| -rw-r--r-- | lisp/subr.el | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index a959c6a9810..02cc84c04b7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2699,8 +2699,14 @@ If all are non-nil, return the value of the last form in BODY. | |||
| 2699 | The variable list SPEC is the same as in `if-let'." | 2699 | The variable list SPEC is the same as in `if-let'." |
| 2700 | (declare (indent 1) (debug if-let) | 2700 | (declare (indent 1) (debug if-let) |
| 2701 | (obsolete "use `when-let*' or `and-let*' instead." "31.1")) | 2701 | (obsolete "use `when-let*' or `and-let*' instead." "31.1")) |
| 2702 | `(with-suppressed-warnings ((obsolete if-let)) | 2702 | ;; Previously we expanded to `if-let', and then required a |
| 2703 | (if-let ,spec ,(macroexp-progn body)))) | 2703 | ;; `with-suppressed-warnings' to avoid doubling up the obsoletion |
| 2704 | ;; warnings. But that triggers a bytecompiler bug; see bug#74530. | ||
| 2705 | ;; So for now we reimplement `if-let' here. | ||
| 2706 | (when (and (<= (length spec) 2) | ||
| 2707 | (not (listp (car spec)))) | ||
| 2708 | (setq spec (list spec))) | ||
| 2709 | (list 'if-let* spec (macroexp-progn body))) | ||
| 2704 | 2710 | ||
| 2705 | (defmacro while-let (spec &rest body) | 2711 | (defmacro while-let (spec &rest body) |
| 2706 | "Bind variables according to SPEC and conditionally evaluate BODY. | 2712 | "Bind variables according to SPEC and conditionally evaluate BODY. |