emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat 9b069be47a 4/7: Move if-let* and when-let* to co


From: ELPA Syncer
Subject: [elpa] externals/compat 9b069be47a 4/7: Move if-let* and when-let* to compat-26
Date: Wed, 20 Apr 2022 04:57:33 -0400 (EDT)

branch: externals/compat
commit 9b069be47a9369965f0c1ba349a5ecc4b657fe6a
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Move if-let* and when-let* to compat-26
    
    It is not quite clear to me whether or not if/when-let are intended to
    be supported at all (the git logs mention deprecation a number of
    times), but it is clear that these two macros do not appear before
    the release of 26.1, and hence have to be moved so that they actually
    get defined.
---
 MANUAL       |  4 ++--
 compat-25.el | 28 ----------------------------
 compat-26.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 compat.texi  | 16 ++++++++--------
 4 files changed, 57 insertions(+), 40 deletions(-)

diff --git a/MANUAL b/MANUAL
index 501b7b9c3a..1650c8acc4 100644
--- a/MANUAL
+++ b/MANUAL
@@ -183,8 +183,6 @@ provided by Compat by default:
 - Function: string-greaterp :: See [[info:elisp#Text Comparison][(elisp) Text 
Comparison]].
 - Macro: with-file-modes :: See [[info:elisp#Changing Files][(elisp) Changing 
Files]].
 - Function: alist-get :: See [[info:elisp#Association Lists][(elisp) 
Association Lists]].
-- Macro: if-let* :: Defined in ~subr-x.el~.
-- Macro: when-let* :: Defined in ~subr-x.el~.
 - Macro: if-let :: Defined in ~subr-x.el~.
 - Macro: when-let :: Defined in ~subr-x.el~.
 - Macro: thread-first :: Defined in ~subr-x.el~.
@@ -245,6 +243,8 @@ provided by Compat by default:
 - Function: make-nearby-temp-file :: See [[info:elisp#Unique File 
Names][(elisp) Unique File Names]].
 - Variable: mounted-file-systems ::  Defined in ~files.el~.
 - Function: temporary-file-directory :: See [[info:elisp#Unique File 
Names][(elisp) Unique File Names]].
+- Macro: if-let* :: Defined in ~subr-x.el~.
+- Macro: when-let* :: Defined in ~subr-x.el~.
 - Macro: and-let* :: Defined in ~subr-x.el~.
 - Function: file-local-name :: See [[info:elisp#Magic File Names][(elisp) 
Magic File Names]].
 - Function: file-name-quoted-p :: See [[info:elisp#File Name 
Expansion][(elisp) File Name Expansion]].
diff --git a/compat-25.el b/compat-25.el
index 8703a89fb2..d31b13372a 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -127,34 +127,6 @@ Equality with KEY is tested by TESTFN, defaulting to `eq'."
 
 ;;;; Defined in subr-x.el
 
-(compat-defmacro if-let* (varlist then &rest else)
-  "Bind variables according to VARLIST and evaluate THEN or ELSE.
-This is like `if-let' but doesn't handle a VARLIST of the form
-\(SYMBOL SOMETHING) specially."
-  :realname compat--if-let*
-  :feature 'subr-x
-  (declare (indent 2)
-           (debug ((&rest [&or symbolp (symbolp form) (form)])
-                   body)))
-  (let ((empty (make-symbol "s"))
-        (last t) list)
-    (dolist (var varlist)
-      (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* (varlist &rest body)
-  "Bind variables according to VARLIST and conditionally evaluate BODY.
-This is like `when-let' but doesn't handle a VARLIST of the form
-\(SYMBOL SOMETHING) specially."
-  :feature 'subr-x
-  (declare (indent 1) (debug if-let*))
-  `(compat--if-let* ,varlist ,(macroexp-progn body)))
-
 (compat-defmacro if-let (spec then &rest else)
   "Bind variables according to SPEC and evaluate THEN or ELSE.
 Evaluate each binding in turn, as in `let*', stopping if a
diff --git a/compat-26.el b/compat-26.el
index b3fbd14c80..6476f311a8 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -424,14 +424,59 @@ the variable `temporary-file-directory' is returned."
 
 ;;;; Defined in subr-x.el
 
-(declare-function compat--when-let* "compat-25" (varlist &rest body))
+(compat-defmacro if-let* (varlist then &rest else)
+  "Bind variables according to VARLIST and evaluate THEN or ELSE.
+This is like `if-let' but doesn't handle a VARLIST of the form
+\(SYMBOL SOMETHING) specially."
+  :realname compat--if-let*
+  :feature 'subr-x
+  (declare (indent 2)
+           (debug ((&rest [&or symbolp (symbolp form) (form)])
+                   body)))
+  (let ((empty (make-symbol "s"))
+        (last t) list)
+    (dolist (var varlist)
+      (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* (varlist &rest body)
+  "Bind variables according to VARLIST and conditionally evaluate BODY.
+This is like `when-let' but doesn't handle a VARLIST of the form
+\(SYMBOL SOMETHING) specially."
+  ;; :feature 'subr-x
+  (declare (indent 1) (debug if-let*))
+  (let ((empty (make-symbol "s"))
+        (last t) list)
+    (dolist (var varlist)
+      (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)
+       (when ,(caar list) ,@body))))
+
 (compat-defmacro and-let* (varlist &rest body)
   "Bind variables according to VARLIST and conditionally evaluate BODY.
 Like `when-let*', except if BODY is empty and all the bindings
 are non-nil, then the result is non-nil."
   :feature 'subr-x
   (declare (indent 1) (debug if-let*))
-  `(compat--when-let* ,varlist ,@(or body '(t))))
+  (let ((empty (make-symbol "s"))
+        (last t) list)
+    (dolist (var varlist)
+      (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 image.el
 
diff --git a/compat.texi b/compat.texi
index f696c8127e..61f173db01 100644
--- a/compat.texi
+++ b/compat.texi
@@ -379,14 +379,6 @@ See @ref{Changing Files,(elisp) Changing Files,,elisp,}.
 See @ref{Association Lists,(elisp) Association Lists,,elisp,}.
 @end defun
 
-@defmac if-let*
-Defined in @code{subr-x.el}.
-@end defmac
-
-@defmac when-let*
-Defined in @code{subr-x.el}.
-@end defmac
-
 @defmac if-let
 Defined in @code{subr-x.el}.
 @end defmac
@@ -519,6 +511,14 @@ Defined in @code{files.el}.
 See @ref{Unique File Names,(elisp) Unique File Names,,elisp,}.
 @end defun
 
+@defmac if-let*
+Defined in @code{subr-x.el}.
+@end defmac
+
+@defmac when-let*
+Defined in @code{subr-x.el}.
+@end defmac
+
 @defmac and-let*
 Defined in @code{subr-x.el}.
 @end defmac



reply via email to

[Prev in Thread] Current Thread [Next in Thread]