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


4.4 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.

At least one key-value pair is required. All transient infix commands are equal to each other (but not eq). It is meaningless to define an infix command, without providing at least one keyword argument (usually :argument or :variable, depending on the class). The suffix class defaults to transient-switch and can be set using the :class keyword.

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.


Next: Using Infix Arguments, Previous: Binding Suffix and Infix Commands, Up: Defining New Commands   [Contents][Index]