GNU bug report logs - #64048
30.0.50; global-display-line-numbers-mode has no easy way to set modes where it is enabled

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Tue, 13 Jun 2023 14:30:03 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org
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 <at> 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>




This bug report was last modified 1 year and 363 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.