stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minor Modes


From: szos
Subject: Minor Modes
Date: Tue, 28 Jun 2022 10:24:06 +0000

Hello,

One of the issues I have seen with StumpWM is a lack of ability to
extend the default behavior without modifying functions directly. So I
implemented a minor mode framework based upon dynamic mixins which
attempts to address this. This framework has been merged into the master
branch, and is ready for use (and abuse). I would greatly appreciate
people kicking the tires of this framework, or otherwise identifying
weak points in its design or implementation. 

Outside of this framework, the variables *CUSTOM-COMMAND-FILTERS* and
*MINOR-MODE-MAPS* have been added. *CUSTOM-COMMAND-FILTERS* allows
commands to "specialize" upon more than just group type when determining
if they should be enabled, and *MINOR-MODE-MAPS* allows users to add
their own top level keymaps without binding to *TOP-MAP*.

The rest of this email will be a small introduction, for a more in depth
walkthrough see the attached pdf, which is an (overly) verbose
walkthrough of reimplementing swm-gaps using this framework.

The framework itself allows users to define minor modes with a handy
little macro DEFINE-MINOR-MODE. As a simple example, heres a basic evil
mode immitation:

(define-minor-mode swm-evil-mode () ()
  (:scope :unscoped)
  (:interactive toggle-evil-mode)
  (:top-map '(("i" . "toggle-evil-mode")
              ("j" . "move-focus down")
              ("k" . "move-focus up")
              ;; other top-level keybindings
              ("g" . *groups-map*)
              ("x" . *exchange-window-map*)))
  (:lighter "EVIL"))

However, the main appeal of minor modes is that they are mixins, and
allow generic functions to be overridden or otherwise augmented by
defining methods that specialize upon the minor mode itself. The library
dynamic-mixins has been leveraged to allow mixing and unmixin on the fly
(dont worry, it has been vendored so you dont need to pull in a new
dependency from quicklisp). For example one can define a minor mode
which is scoped (mixed in) to windows and augments the generic function
update-decoration to change the decoration as desired.

While there arent currently any minor modes defined with this framework
(it did just get merged a couple days ago), I've implemented a frame
mode line (ie a mode line per frame)[0] which is compatible with the
gaps implementation provided in the attached pdf. (side note, this frame
mode line could possibly be adapted to provide the tabs feature
requested here a while back).

I hope people can make use of this, and do consider reading through the
attached PDF for a more in depth look at what happens when you define a
minor mode, and there is also a new section in the manual dedicated to
minor modes and minor mode scopes.

Cheers,
Szos

[0] https://gist.github.com/szos/b5d678d2ad057b631df0e187797978fd.

Attachment: minor-modes-post.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]