4.3 Defining Suffix and Infix Commands

Note that an infix is a special kind of suffix. Depending on context “suffixes” means “suffixes (including infixes)” or “non-infix suffixes”.

Macro: transient-define-suffix name arglist [docstring] [keyword value]… body…

This macro defines NAME as a transient suffix command.

ARGLIST are the arguments that the command takes. DOCSTRING is the documentation string and is optional.

These arguments can optionally be followed by keyword-value pairs. Each keyword has to be a keyword symbol, either :class or a keyword argument supported by the constructor of that class. The transient-suffix class is used if the class is not specified explicitly.

The BODY must begin with an interactive form that matches ARGLIST. The infix arguments are usually accessed by using transient-args inside interactive.

Macro: transient-define-infix name arglist [docstring] [keyword value]…

This macro defines NAME as a transient infix command.

ARGLIST is always ignored (but mandatory never-the-less) and reserved for future use. DOCSTRING is the documentation string and is optional.

The keyword-value pairs are mandatory. All transient infix commands are equal to each other (but not eq), so it is meaningless to define an infix command without also setting at least :class and one other keyword (which it is depends on the used class, usually :argument or :variable).

Each keyword has to be a keyword symbol, either :class or a keyword argument supported by the constructor of that class. The transient-switch class is used if the class is not specified explicitly.

The function definition is always:

(lambda ()
  (interactive)
  (let ((obj (transient-suffix-object)))
    (transient-infix-set obj (transient-infix-read obj)))
  (transient--show))

transient-infix-read and transient-infix-set are generic functions. Different infix commands behave differently because the concrete methods are different for different infix command classes. In rare cases the above command function might not be suitable, even if you define your own infix command class. In that case you have to use transient-define-suffix to define the infix command and use t as the value of the :transient keyword.

Macro: transient-define-argument name arglist [docstring] [keyword value]…

This macro defines NAME as a transient infix command.

This is an alias for transient-define-infix. Only use this alias to define an infix command that actually sets an infix argument. To define an infix command that, for example, sets a variable, use transient-define-infix instead.