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

10. Minor Modes

Like Emacs, StumpWM has the concept of minor modes. These are defined by the macro DEFINE-MINOR-MODE. Defining a minor mode creates a class and a set of methods specializing upon it. Minor modes are scoped to a window, head, group, or screen, or they may be unscoped. In addition to this minor modes may be local or global. When a minor mode is global all new instances of the scope object will be created with the minor mode already active in them. Minor modes define their own top level and root level keymaps, as well as hooks that are run upon enabling or disabling the minor mode, and a lighter to display in the mode line.

Minor modes are mixins that get added to the appropriate scope object when enabled. As such minor modes allow the augmenting, modifying, and overriding of default StumpWM behavior by defining methods for the generic functions of the scope object. For example, a minor mode may be scoped to a window and define a method for the generic function UPDATE-DECORATION to change how window decoration is handled for the windows it is enabled in.

Macro: define-minor-mode mode superclasses slots &rest options

Define a minor mode as a class to be instantiated when the minor mode is activated. Minor modes are dynamically mixed in to and out of the appropriate object when they are enabled or disabled.

If SUPERCLASSES is not provided a default superclass of MINOR-MODE will be provided. OPTIONS may include all normal options when defining a class, with the addition of the following options:

Example:

(define-minor-mode evil-mode () ()
  (:scope :unscoped)
  (:top-map '(("j" . "move-focus down")
              ("k" . "move-focus up")
              ("h" . "move-focus left")
              ("l" . "move-focus right")
              ("x" . *exchange-window-map*)
              ("C-m b" . "evil-echo")))
  (:lighter "EVIL")
  (:lighter-make-clickable nil))

(define-evil-mode-command evil-echo () ()
  (run-commands "echo"))

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

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