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

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

[elpa] externals/transient 152b93e602 5/7: transient--mapn: New function


From: Jonas Bernoulli
Subject: [elpa] externals/transient 152b93e602 5/7: transient--mapn: New function
Date: Tue, 2 Jul 2024 18:25:54 -0400 (EDT)

branch: externals/transient
commit 152b93e602d1c776fa01659aaee0cab23ea3d4ab
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient--mapn: New function
---
 lisp/transient.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/transient.el b/lisp/transient.el
index a84e40ecb3..440c704151 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -4501,6 +4501,17 @@ we stop there."
       (push (funcall function (car acc) elt) acc))
     (nreverse acc)))
 
+(defun transient--mapn (function &rest lists)
+  "Apply FUNCTION to elements of LISTS.
+Like `cl-mapcar' but while that stops when the shortest list
+is exhausted, continue until the longest list is, using nil
+as stand-in for elements of exhausted lists."
+  (let (result)
+    (while (catch 'more (mapc (lambda (l) (and l (throw 'more t))) lists) nil)
+      (push (apply function (mapcar #'car-safe lists)) result)
+      (setq lists (mapcar #'cdr lists)))
+    (nreverse result)))
+
 ;;; Font-Lock
 
 (defconst transient-font-lock-keywords



reply via email to

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