[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Commands

If you’ve used Emacs before you’ll find the distinction between commands and functions familiar. Commands are simply functions that can be bound to keys and executed interactively from StumpWM’s input bar. Whereas, in Emacs, the special "(interactive)" declaration is used to turn a function into a command, in StumpWM commands are made with a separate defcommand or define-interactive-keymap macro.

Once a command is defined, you can call it by invoking the colon command (C-t ;), and typing the name of the command. This may be sufficient for commands that aren’t used very often. To see all the currently-defined commands, invoke the command called commands: ie press C-t ;, type “commands”, and hit return.

Commonly-used commands can also be bound to a keystroke, which is much more convenient. To do this, use the define-key function (see Key Bindings), giving the name of the command as a string. For example:

 
(define-key *root-map* (kbd "d") "exchange-direction")

You cannot give the command name as a symbol, nor can you bind a key to a regular function defined with defun.

If the command takes arguments (see Writing Commands), you can fix those arguments when defining the key-binding, by including the arguments in the same string as the command name, separated by a space. For instance, the exchange-direction command, which is unbound by default, requires a direction in which to exchange windows. If you call exchange-direction directly, it will prompt you for the direction. If you know that you often exchange in left/right directions, and want those actions bound to keys, you can use the following in your customization file:

 
(define-key *root-map* (kbd "[") "exchange-direction left")
(define-key *root-map* (kbd "]") "exchange-direction right")

Multiple arguments can be included by adding them to the command string, separated by spaces. Not all argument types can be represented as strings, but StumpWM will do its best to convert types.

StumpWM does not implement the Emacs concept of prefix arguments.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on February 2, 2024 using texi2html 1.82.