Next: , Previous: , Up: Defining New Commands   [Contents][Index]


4.5 Using Infix Arguments

The functions and the variables described below allow suffix commands to access the value of the transient from which they were invoked; which is the value of its infix arguments. These variables are set when the user invokes a suffix command that exits the transient, but before actually calling the command.

When returning to the command-loop after calling the suffix command, the arguments are reset to nil (which causes the function to return nil too).

Like for Emacs’s prefix arguments, it is advisable, but not mandatory, to access the infix arguments inside the command’s interactive form. The preferred way of doing that is to call the transient-args function, which for infix arguments serves about the same purpose as prefix-arg serves for prefix arguments.

Function: transient-args prefix

This function returns the value of the transient prefix command PREFIX.

If the current command was invoked from the transient prefix command PREFIX, then it returns the active infix arguments. If the current command was not invoked from PREFIX, then it returns the set, saved or default value for PREFIX.

Function: transient-arg-value arg args

This function return the value of ARG as it appears in ARGS.

For a switch a boolean is returned. For an option the value is returned as a string, using the empty string for the empty value, or nil if the option does not appear in ARGS.

Function: transient-suffixes prefix

This function returns the suffixes of the transient prefix command PREFIX. This is a list of objects. This function should only be used if you need the objects (as opposed to just their values) and if the current command is not being invoked from PREFIX.

Variable: transient-current-suffixes

The suffixes of the transient from which this suffix command was invoked. This is a list of objects. Usually it is sufficient to instead use the function transient-args, which returns a list of values. In complex cases it might be necessary to use this variable instead, i.e., if you need access to information beside the value.

Variable: transient-current-command

The transient from which this suffix command was invoked. The returned value is a symbol, the transient prefix command.

Variable: transient-current-prefix

The transient from which this suffix command was invoked. The returned value is a transient-prefix object, which holds information associated with the transient prefix command.

Function: transient-active-prefix

This function returns the active transient object. Return nil if there is no active transient, if the transient buffer isn’t shown, and while the active transient is suspended (e.g., while the minibuffer is in use).

Unlike transient-current-prefix, which is only ever non-nil in code that is run directly by a command that is invoked while a transient is current, this function is also suitable for use in asynchronous code, such as timers and callbacks (this function’s main use-case).

If optional PREFIXES is non-nil, it must be a prefix command symbol or a list of symbols, in which case the active transient object is only returned if it matches one of the PREFIXES.


Next: Transient State, Previous: Defining Suffix and Infix Commands, Up: Defining New Commands   [Contents][Index]