From 7c6504365bd77f133fc06c3ff03d9999354f85f2 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 21 Jan 2025 17:55:30 +0100 Subject: transient--parse-{group,suffix}: Support ## macro following keyword --- docs/transient.org | 12 ++++++++++++ docs/transient.texi | 13 +++++++++++++ lisp/transient.el | 6 ++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/transient.org b/docs/transient.org index a39136b..f202576 100644 --- a/docs/transient.org +++ b/docs/transient.org @@ -1142,6 +1142,12 @@ constructor of that class. contained in a group are right padded, effectively aligning the descriptions. +- If a keyword argument accepts a function as value, you an use a + ~lambda~ expression. As a special case, the ~##~ macro (which returns a + ~lambda~ expression and is implemented in the ~llama~ package) is also + supported. Inside group specifications, the use of ~##~ is not + supported anywhere but directly following a keyword symbol. + The {{{var(ELEMENT)}}}s are either all subgroups, or all suffixes and strings. (At least currently no group type exists that would allow mixing subgroups with commands at the same level, though in principle there @@ -1252,6 +1258,12 @@ Each keyword has to be a keyword symbol, either ~:class~ or a keyword argument supported by the constructor of that class. See [[*Suffix Slots]]. +If a keyword argument accepts a function as value, you an use a ~lambda~ +expression. As a special case, the ~##~ macro (which returns a ~lambda~ +expression and is implemented in the ~llama~ package) is also supported. +Inside suffix bindings, the use of ~##~ is not supported anywhere but +directly following a keyword symbol. + ** Defining Suffix and Infix Commands #+cindex: defining suffix commands #+cindex: defining infix commands diff --git a/docs/transient.texi b/docs/transient.texi index 46c5a69..395fbd5 100644 --- a/docs/transient.texi +++ b/docs/transient.texi @@ -1318,6 +1318,13 @@ be replaced with an error. The boolean @code{:pad-keys} argument controls whether keys of all suffixes contained in a group are right padded, effectively aligning the descriptions. + +@item +If a keyword argument accepts a function as value, you an use a +@code{lambda} expression. As a special case, the @code{##} macro (which returns a +@code{lambda} expression and is implemented in the @code{llama} package) is also +supported. Inside group specifications, the use of @code{##} is not +supported anywhere but directly following a keyword symbol. @end itemize The @var{ELEMENT}s are either all subgroups, or all suffixes and strings. @@ -1439,6 +1446,12 @@ Finally, details can be specified using optional @var{KEYWORD}-@var{VALUE} pairs Each keyword has to be a keyword symbol, either @code{:class} or a keyword argument supported by the constructor of that class. See @ref{Suffix Slots}. +If a keyword argument accepts a function as value, you an use a @code{lambda} +expression. As a special case, the @code{##} macro (which returns a @code{lambda} +expression and is implemented in the @code{llama} package) is also supported. +Inside suffix bindings, the use of @code{##} is not supported anywhere but +directly following a keyword symbol. + @node Defining Suffix and Infix Commands @section Defining Suffix and Infix Commands diff --git a/lisp/transient.el b/lisp/transient.el index 0fec8df..15ea70f 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1253,7 +1253,8 @@ commands are aliases for." (cond ((eq key :class) (setq class val)) ((or (symbolp val) - (and (listp val) (not (eq (car val) 'lambda)))) + (and (listp val) + (not (memq (car val) (list 'lambda (intern "")))))) (setq args (plist-put args key (macroexp-quote val)))) ((setq args (plist-put args key val)))))) (unless (or spec class (not (plist-get args :setup-children))) @@ -1351,7 +1352,8 @@ commands are aliases for." ((guard (eq (car-safe val) '\,)) (use key (cadr val))) ((guard (or (symbolp val) - (and (listp val) (not (eq (car val) 'lambda))))) + (and (listp val) + (not (memq (car val) (list 'lambda (intern ""))))))) (use key (macroexp-quote val))) (_ (use key val))))) (when spec -- cgit v1.0