Skip to content

Commit

Permalink
transient-infix: Support using a function as CHOICES
Browse files Browse the repository at this point in the history
Closes #212.
  • Loading branch information
tarsius committed Oct 26, 2023
1 parent 74b0d74 commit beaa3ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/transient.org
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,10 @@ They are defined here anyway to allow sharing certain methods.
function that takes the object as the only argument and which
returns a prompt string.

- ~choices~ A list of valid values. How exactly that is used depends on
the class of the object.
- ~choices~ A list of valid values, or a function that returns such a
list. The latter is not implemented for ~transient-switches~, because
I couldn't think of a use-case. How exactly the choices are used
varies depending on the class of the suffix.

*** Slots of ~transient-variable~
:PROPERTIES:
Expand Down
6 changes: 4 additions & 2 deletions docs/transient.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2191,8 +2191,10 @@ function that takes the object as the only argument and which
returns a prompt string.

@item
@code{choices} A list of valid values. How exactly that is used depends on
the class of the object.
@code{choices} A list of valid values, or a function that returns such a
list. The latter is not implemented for @code{transient-switches}, because
I couldn't think of a use-case. How exactly the choices are used
varies depending on the class of the suffix.
@end itemize

@anchor{Slots of @code{transient-variable}}
Expand Down
1 change: 1 addition & 0 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -2961,6 +2961,7 @@ it\", in which case it is pointless to preserve history.)"
(oset obj value nil)
(let* ((enable-recursive-minibuffers t)
(reader (oref obj reader))
(choices (if (functionp choices) (funcall choices) choices))
(prompt (transient-prompt obj))
(value (if multi-value (mapconcat #'identity value ",") value))
(history-key (or (oref obj history-key)
Expand Down

0 comments on commit beaa3ca

Please sign in to comment.