help-gnu-emacs
[Top][All Lists]
Advanced

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

Differentiate minor mode and global minor mode


From: Joost Kremers
Subject: Differentiate minor mode and global minor mode
Date: Thu, 16 Apr 2020 14:13:40 +0200
User-agent: mu4e 1.3.10; emacs 27.0.90

Hi list,

I was wondering if there's a proper way to determine if a minor mode is being turned on locally or globally?

Specifically, I'm running into an issue with my package `writeroom-mode`, which defines a minor mode (activated with `writeroom-mode`) and a globalized version (`global-writeroom-mode`). The globalized mode is defined with `define-globalized-minor-mode`, so `global-writeroom-mode` calls a function `turn-on-writeroom-mode`, which in turn calls `writeroom-mode`. In the body of `writeroom-mode`,[1] I want to be able to be able to distinguish whether `writeroom-mode` is turned on locally in a buffer or globally.

Obviously, I could just set some global variable in `turn-on-writeroom-mode` to signal to `writeroom-mode`[2] that the mode is turned on globally,[3] but perhaps there's a canonical way of doing this that I'm not aware of?

TIA

Joost



Footnotes:
[1] The minor mode is defined with `define-minor-mode`, so `writeroom-mode` is generated. `define-minor-mode` just calls a function `writeroom--enable`, so I really want to distinguish between a local and global use of `writeroom-mode` in this function.

[2]  Specifically, `writeroom--enable`.

[3] Alternatively, I guess I could call `writeroom--enable` directly in `turn-on-writeroom-mode` and pass an argument.

--
Joost Kremers
Life has its moments



reply via email to

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