Skip to content

Commit

Permalink
transient--expand-define-args: Make available at compile-time
Browse files Browse the repository at this point in the history
That makes it possible to use `transient-define-' in "transient.el"
itself; as we started to do in the previous commit.
  • Loading branch information
tarsius committed Oct 27, 2023
1 parent faa3d09 commit a882987
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a882987

Please sign in to comment.