Previous: , Up: Defining Prefix and Suffix Commands   [Contents]

3.2 Defining Suffix Commands

Commands intended to be invoked from a particular popup should determine the currently effective arguments by calling the function SHORTNAME-arguments inside their interactive form. This function is created by the magit-define-popup macro. For a popup named prefix-foo-popup the name of this function is prefix-foo-arguments.

When the command was invoked as an action in the respective popup, then this function returns the arguments that were set in the popup. Otherwise when the command was invoked as the default of the popup (by calling the popup command with a prefix argument), or without using the popup command at all, then this function returns the buffer-local or global value of the variable SHORTNAME-arguments.

Internally arguments are handled as a list of strings. This might not be appropriate for the intended use inside commands, or it might be necessary to manipulate that list somehow, i.e. to split "–ARG=VAL" into "–ARG""VAL". This should be done by advising or redefining the function SHORTNAME-arguments.

Internally SHORNAME-arguments used following variables and function. Except when redefining the former, you should not use these directly.

Variable: magit-current-popup

The popup from which this editing command was invoked.

Variable: magit-current-popup-args

The value of the popup arguments for this editing command.

If the current command was invoked from a popup, then this is a list of strings of all the set switches and options. This includes arguments which are set by default not only those explicitly set during this invocation.

When the value is nil, then that can be because no argument is set, or because the current command wasn’t invoked from a popup at all.

Function: magit-current-popup-args &rest args

This function returns the value of the popup arguments for this editing command. The value is the same as that of the variable by the same name, except that FILTER is applied. FILTER is a list of regexps; only arguments that match one of them are returned. The first element of FILTER may also be :not in which case only arguments that don’t match any of the regexps are returned, or :only which doesn’t change the behavior.

Previous: , Up: Defining Prefix and Suffix Commands   [Contents]