[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Differentiate minor mode and global minor mode
From: |
Štěpán Němec |
Subject: |
Re: Differentiate minor mode and global minor mode |
Date: |
Thu, 16 Apr 2020 15:57:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
On Thu, 16 Apr 2020 14:13:40 +0200
Joost Kremers wrote:
> 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?
Same as with any other minor mode, calling `global-writeroom-mode' will
also set the same-named variable to t, so you can just check for that.
--
Štěpán