dsemy.com swsw [Home]

Previous: , Up: Customization   [Contents][Index]


4.2 Window commands

Window commands are used to perform operations on specific windows, chosen by their ID (or the next window, if less than swsw-minimum (3 by default) windows are currently in scope). Alternatively, other commands available in swsw-command-map can be chosen. Not all commands in swsw-command-map are window commands (by default). For more information about included window commands, See Usage.

Window commands can easily be defined using swsw-define-window-command. For more complex use cases, the lower level swsw-run-window-command can be used.

User Option: swsw-minimum

Minimum number of tracked windows for which interactive selection occurs when using window commands. In practice, only window commands defined using swsw-define-window-command automatically adhere to this rule.

Variable: swsw--id-map

Key map which is populated automatically with elements corresponding to all tracked windows. The ID of each window is converted to a vector (to serve as a key sequence), and is bound to a command which calls last-command with the window corresponding to the ID as the sole argument. There should be no reason to modify it directly; it is reset whenever window configuration is updated.

Variable: swsw-command-map

Key map which holds bindings to window commands. This key map is set as the parent of swsw--id-map, so all window commands are available when it’s active (unless they are shadowed by a window ID).

Variable: swsw-window-count

Amount of windows currently tracked, including the minibuffer (if it’s active). It can be used to change the behavior of window commands (or display functions, See ID display).

Macro: swsw-define-window-command name (window [prefix] [minibuffer]) docstring body...

Define NAME as a window command with DOCSTRING as its documentation string. PREFIX (a symbol) is passed as an argument to the command (when not omitted or nil), with it’s value being the raw prefix argument.

BODY is used as the body of an anonymous function which receives WINDOW (a symbol) as an argument, with its value being a selected window. If there are less than swsw-minimum (3 by default) windows in the current scope (See Customization), the function is called with the window returned by next-window. In this case, if MINIBUFFER is non-nil, it can be selected if it’s active. Otherwise, the function is run using swsw-run-window-command.

Function: swsw-run-window-command fun

Run FUN as a window command. Run swsw-before-command-hook, set this-command to FUN, and set swsw--id-map as a transient map which runs swsw-after-command-hook on exit. The hooks run by this function are expected by swsw to run for any window command which requires ID selection; they should be manually added even if this function isn’t used when defining a new window command.


Previous: ID display, Up: Customization   [Contents][Index]


Copyright © Daniel Semyonov 2020-2022