[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat b4f38aa5ab 55/84: Copy if-let/if-let* definition
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat b4f38aa5ab 55/84: Copy if-let/if-let* definitions into if-let/when-let |
Date: |
Tue, 3 Jan 2023 08:57:35 -0500 (EST) |
branch: externals/compat
commit b4f38aa5abb750ad2ffab96ad50902277edb2089
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Copy if-let/if-let* definitions into if-let/when-let
---
compat-25.el | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/compat-25.el b/compat-25.el
index d0df7d8a96..339de654ce 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -155,7 +155,16 @@ with an old syntax that accepted only one binding."
(not (listp (car spec))))
;; Adjust the single binding case
(setq spec (list spec)))
- `(compat--if-let* ,spec ,then ,(macroexp-progn else)))
+ (let ((empty (make-symbol "s"))
+ (last t) list)
+ (dolist (var spec)
+ (push `(,(if (cdr var) (car var) empty)
+ (and ,last ,(or (cadr var) (car var))))
+ list)
+ (when (or (cdr var) (consp (car var)))
+ (setq last (caar list))))
+ `(let* ,(nreverse list)
+ (if ,(caar list) ,then ,@else))))
(compat-defmacro when-let (spec &rest body)
"Bind variables according to SPEC and conditionally evaluate BODY.
@@ -167,7 +176,20 @@ The variable list SPEC is the same as in `if-let'."
(debug ([&or (symbolp form)
(&rest [&or symbolp (symbolp form) (form)])]
body)))
- `(compat--if-let ,spec ,(macroexp-progn body)))
+ (when (and (<= (length spec) 2)
+ (not (listp (car spec))))
+ ;; Adjust the single binding case
+ (setq spec (list spec)))
+ (let ((empty (make-symbol "s"))
+ (last t) list)
+ (dolist (var spec)
+ (push `(,(if (cdr var) (car var) empty)
+ (and ,last ,(or (cadr var) (car var))))
+ list)
+ (when (or (cdr var) (consp (car var)))
+ (setq last (caar list))))
+ `(let* ,(nreverse list)
+ (if ,(caar list) ,(macroexp-progn body)))))
;;;; Defined in subr-x.el
- [elpa] externals/compat 518067a7d6 58/84: Copy edebug specification for and-let* from if-let*, (continued)
- [elpa] externals/compat 518067a7d6 58/84: Copy edebug specification for and-let* from if-let*, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 8e397fee78 66/84: Ignore all .patch files, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 18152ca068 76/84: Fix edge-case of binding nil in if-let* and related macros, ELPA Syncer, 2023/01/03
- [elpa] externals/compat bb25d50b6c 78/84: Fix test skip condition for 'compat-ref-define-key', ELPA Syncer, 2023/01/03
- [elpa] externals/compat 043e3d71b5 79/84: Always load compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 62ec50bdd1 83/84: Merge branch 'emacs-29.1', ELPA Syncer, 2023/01/03
- [elpa] externals/compat accc689c7e 20/84: Remove nonsensical file-parent-directory test comment, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 8b3d3ea5c8 32/84: Merge branch 'master' into emacs-29.1, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 5c0c55c20d 47/84: Document missing functionality from compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 26cf72e36a 49/84: Explicitly denote subr-x functions with :feature, ELPA Syncer, 2023/01/03
- [elpa] externals/compat b4f38aa5ab 55/84: Copy if-let/if-let* definitions into if-let/when-let,
ELPA Syncer <=
- [elpa] externals/compat 9e14c2f2df 56/84: Remove realname for if-let, ELPA Syncer, 2023/01/03
- [elpa] externals/compat c96aa66fb4 57/84: Remove realname for if-let*, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 3bd425a0d6 67/84: Prevent compat-macs.el from being byte compiled, ELPA Syncer, 2023/01/03
- [elpa] externals/compat e96cd14210 72/84: Have Makefile targets rebuild .elc files not .el, ELPA Syncer, 2023/01/03
- [elpa] externals/compat c0d5634570 80/84: Simplify loading procedure, ELPA Syncer, 2023/01/03
- [elpa] externals/compat be4595fec8 84/84: Update README to reflect the move from SourceHut to GitHub, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 6aad62a6b8 77/84: Split plain unit tests into "ref" (real) and "impl" (compat) tests, ELPA Syncer, 2023/01/03