branch: externals/transient commit 152b93e602d1c776fa01659aaee0cab23ea3d4ab Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@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