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

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

bug#64048: 30.0.50; global-display-line-numbers-mode has no easy way to


From: Ihor Radchenko
Subject: bug#64048: 30.0.50; global-display-line-numbers-mode has no easy way to set modes where it is enabled
Date: Tue, 13 Jun 2023 19:36:14 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> May I rephrase is as a feature request then?
>> Like, please add `global-*-modes' customization for modes defined via 
>> `define-globalized-minor-mode'?
>> Or, at least, add `global-display-line-numbers-modes' customization?
>
> I'm not against such a feature, not at all.  My objection was only to
> the particular implementation that you suggested: we cannot suddenly
> add a :predicate to a global mode where previously there wasn't one.
> People who activate this global mode expect it to be active
> everywhere, no questions asked.

> (Btw, I don't think I understand the use of :predicate which you
> proposed: it isn't documented as accepting a function, only nil, t, or
> a list of modes.)

Hmm. You are right, I did not look far enough into the code.

Let me correct my initial suggestion:

(define-globalized-minor-mode global-display-line-numbers-mode
  display-line-numbers-mode display-line-numbers--turn-on
  :predicate t)

:predicate defines the default value of
`global-display-line-numbers-modes' variable.

The above code will not change the existing behaviour, except that
`global-display-line-numbers-modes' will be accounted for, iff
customized by the user.

>> I recall multiple occasions when I tried hard to disable a global mode
>> in some buffers, remembered that there is some special variable for it;
>> just to find out that a specific global minor mode does not support it.
>
> The usual way of enabling a mode selectively is to enable the
> non-global variant of the mode in a mode hook.  I'm sure you know it.

The use case I am talking about is enabling minor mode everywhere,
except certain major modes. It is more tricky.

One can, of course, disable the minor mode selectively in some major
modes from that major mode hooks, but it is surprisingly non-obvious
approach.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

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