From a8829875b25c0dc8cbd7163b6617c436365897b5 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Fri, 27 Oct 2023 23:21:24 +0200 Subject: [PATCH] transient--expand-define-args: Make available at compile-time That makes it possible to use `transient-define-' in "transient.el" itself; as we started to do in the previous commit. --- lisp/transient.el | 49 ++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/lisp/transient.el b/lisp/transient.el index ca8e8cce..0795bcd0 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1002,30 +1002,31 @@ example, sets a variable, use `transient-define-infix' instead. (put 'transient--default-infix-command 'interactive-only t) (put 'transient--default-infix-command 'command-modes (list 'not-a-mode)) -(defun transient--expand-define-args (args &optional arglist) - (unless (listp arglist) - (error "Mandatory ARGLIST is missing")) - (let (class keys suffixes docstr) - (when (stringp (car args)) - (setq docstr (pop args))) - (while (keywordp (car args)) - (let ((k (pop args)) - (v (pop args))) - (if (eq k :class) - (setq class v) - (push k keys) - (push v keys)))) - (while (let ((arg (car args))) - (or (vectorp arg) - (and arg (symbolp arg)))) - (push (pop args) suffixes)) - (list (if (eq (car-safe class) 'quote) - (cadr class) - class) - (nreverse keys) - (nreverse suffixes) - docstr - args))) +(eval-and-compile + (defun transient--expand-define-args (args &optional arglist) + (unless (listp arglist) + (error "Mandatory ARGLIST is missing")) + (let (class keys suffixes docstr) + (when (stringp (car args)) + (setq docstr (pop args))) + (while (keywordp (car args)) + (let ((k (pop args)) + (v (pop args))) + (if (eq k :class) + (setq class v) + (push k keys) + (push v keys)))) + (while (let ((arg (car args))) + (or (vectorp arg) + (and arg (symbolp arg)))) + (push (pop args) suffixes)) + (list (if (eq (car-safe class) 'quote) + (cadr class) + class) + (nreverse keys) + (nreverse suffixes) + docstr + args)))) (defun transient--parse-child (prefix spec) (cl-etypecase spec