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

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

Re: Defining minor mode with minor-mode condition


From: Emanuel Berg
Subject: Re: Defining minor mode with minor-mode condition
Date: Tue, 04 May 2021 15:01:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier wrote:

> I actually often find it convenient to unconditionally
> "disable" first:
>
>     (define-minor-mode crucibulum-minor-mode
>       "Minor mode for assisting with superior & inferior typeface."
>       :lighter " Crucibulum"
>       (disable-texcom-typeface)
>       (disable-ricci-notation)
>       (when crucibulum-minor-mode
>         (enable-texcom-typeface)
>         (enable-ricci-notation)))
>
> the advantage is to avoid problems where, say,
> `enable-texcom-typeface` is not idempotent, so if you call
> (crucibulum-minor-mode 1) several times you might end up
> with multiple copies of the same thing added to a list.

Good!

What about one function to enable all and one to disable all?

No - then these functions can be called from the outside which
will/can add confusion, and worse, enable some of the minor
mode functionality but not actually enabling the minor
mode itself!

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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