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


5.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: define-suffix-command 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. Use the function transient-args or the low-level variable current-transient-suffixes if the former does not give you all the required details. This should, but does not necessarily have to be, done inside the interactive form; just like for prefix-arg and current-prefix-arg.

Macro: define-infix-command 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 definitions 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-suffix-command to define the infix command and use t as the value of the :transient keyword.

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

This macro defines NAME as a transient infix command.

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


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