4.7 Current Prefix Command

Function: transient-prefix-object

This function returns the current prefix as an object.

While a transient is being setup or refreshed (which involves preparing its suffixes) the variable transient--prefix can be used to access the prefix object. Thus this is what has to be used in suffix methods such as transient-format-description, and in object-specific functions that are stored in suffix slots such as description.

When a suffix command is invoked (i.e., in its interactive form and function body) then the variable transient-current-prefix has to be used instead.

Two distinct variables are needed, because any prefix may itself be used as a suffix of another prefix, and such sub-prefixes have to be able to tell themselves apart from the prefix they were invoked from.

Regular suffix commands, which are not prefixes, do not have to concern themselves with this distinction, so they can use this function instead. In the context of a plain suffix, it always returns the value of the appropriate variable.

Variable: transient-current-prefix

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

Variable: transient-current-command

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

Function: transient-active-prefix &optional prefixes

This function returns the active transient object. It returns 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.