Taking inspiration from regular prefix commands and prefix arguments, this library implements a similar abstraction; a new kind of prefix command that is associated with a specific set of infix arguments and suffix commands.
Invoking such a prefix command displays a popup buffer which lists the associated infix arguments and suffix commands. In that buffer each argument is prefixed with the key sequence that can be used to toggle it or change its value. Likewise each suffix command is prefixed with the key used to invoke it. Such a popup buffer might look like this:
,----------------------------------------- |Switches | -l Show graph (--graph) | -d Show refnames (--decorate) | |Options | =m Search messages (--grep="popup") | =p Search patches (-G) | |Action | l Show log for current branch | o Show log for another branch '-----------------------------------------
The user could then for example type -l
to toggle the --graph
switch
(when it is on then it is shown in green, otherwise in gray), or =m
to
change the value of the option --grep
.
Once all arguments are as desired one invokes a suffix command, which
causes the popup buffer to disappear. The suffix command should then
retrieve the infix arguments in its interactive
form like this is done
for prefix arguments.
While such "prefix-infix-suffix" combos were inspired by regular prefix commands and prefix arguments, they are also quite different. This should illustrate the most basic differences:
/- command1 prefix --- command2 \- command3
/- command1 C-u ... --- command2 \- well any command
/- argument1 -\ /- suffix1 prefix----- argument2 --+-- suffix2 ^ \- argument3 -/ | | '--------' (refresh buffer)
This library was written as a replacement for magit-key-mode
, which
was used in Magit releases before 2.1.0. It is used to implement all
"popups" in the current Magit release but a future release will switch
to yet another implementation.
This library does not depend on any other Magit libraries and it is distributed as a separate package, which makes it possible to use it in packages that are not related to Magit. But keep in mind that it will be deprecated eventually.