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

To reply to this bug, email your comments to 64048 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 14:30:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 13 Jun 2023 14:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; global-display-line-numbers-mode has no easy way to set
 modes where it is enabled
Date: Tue, 13 Jun 2023 14:33:39 +0000
Hi,

global-display-line-numbers-mode is defined as

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

Which unconditionally enables it when `display-line-numbers--turn-on'
returns t.

Wouldn't it be nicer to have something like

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

that will also define `display-line-numbers-modes' variable that
controls where the global mode is enabled/disabled?

Maybe it should even be the default in `define-globalized-minor-mode'
when :predicate is not defined.

WDYT?

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 15:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: 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 18:50:47 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Date: Tue, 13 Jun 2023 14:33:39 +0000
> 
> global-display-line-numbers-mode is defined as
> 
> (define-globalized-minor-mode global-display-line-numbers-mode
>   display-line-numbers-mode display-line-numbers--turn-on)
> 
> Which unconditionally enables it when `display-line-numbers--turn-on'
> returns t.
> 
> Wouldn't it be nicer to have something like
> 
> (define-globalized-minor-mode global-display-line-numbers-mode
>   display-line-numbers-mode display-line-numbers--turn-on
>   :predicate #'display-line-numbers--turn-on)
> 
> that will also define `display-line-numbers-modes' variable that
> controls where the global mode is enabled/disabled?
> 
> Maybe it should even be the default in `define-globalized-minor-mode'
> when :predicate is not defined.
> 
> WDYT?

I think it's too late for such changes, because it will definitely
break someone's setup.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 16:05:02 GMT) Full text and rfc822 format available.

Message #11 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: 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 16:09:30 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> that will also define `display-line-numbers-modes' variable that
>> controls where the global mode is enabled/disabled?
>> 
>> Maybe it should even be the default in `define-globalized-minor-mode'
>> when :predicate is not defined.
>
> I think it's too late for such changes, because it will definitely
> break someone's setup.

May you please elaborate?

IMHO, the only way honouring `global-foo-modes' variable will break
someone's setup is when somebody sets `global-foo-modes' (which has no
effect now) and expects that there will be no effect in future as well.

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 16:50:01 GMT) Full text and rfc822 format available.

Message #14 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: 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:49:48 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: 64048 <at> debbugs.gnu.org
> Date: Tue, 13 Jun 2023 16:09:30 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> that will also define `display-line-numbers-modes' variable that
> >> controls where the global mode is enabled/disabled?
> >> 
> >> Maybe it should even be the default in `define-globalized-minor-mode'
> >> when :predicate is not defined.
> >
> > I think it's too late for such changes, because it will definitely
> > break someone's setup.
> 
> May you please elaborate?
> 
> IMHO, the only way honouring `global-foo-modes' variable will break
> someone's setup is when somebody sets `global-foo-modes' (which has no
> effect now) and expects that there will be no effect in future as well.

I have enough gray hair to know that any such changes break something.

This mode has been with us since Emacs 26, so we cannot make such
changes after so much time.  Especially since the problem, if there is
a problem, is minor at best.

Sorry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 17:17:02 GMT) Full text and rfc822 format available.

Message #17 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: 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 17:21:30 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> May you please elaborate?
>> 
>> IMHO, the only way honouring `global-foo-modes' variable will break
>> someone's setup is when somebody sets `global-foo-modes' (which has no
>> effect now) and expects that there will be no effect in future as well.
>
> I have enough gray hair to know that any such changes break something.
>
> This mode has been with us since Emacs 26, so we cannot make such
> changes after so much time.

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 see not how adding a new feature can break anything here.
If a normal minor mode is made into global, it is a given that it can be
activated independently in arbitrary number of buffers. So, extra
predicate (in addition to the mode's own) should not create any problem.

> ...  Especially since the problem, if there is
> a problem, is minor at best.

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.

And then we have non-standard variables like
`dabbrev-ignored-buffer-modes', `hi-lock-exclude-modes',
`which-func-modes' - all with different conventions.

I can also tell you that a question about disabling global minor modes
in some buffers re-surfaces regularly in reddit discussions and IRC.

We even have FAQ entries like https://www.emacswiki.org/emacs/LineNumbers#h5o-10
And the suggested solution is re-defunning "turn-on" function - do we
really want to say that it is the way to go?

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 18:19:02 GMT) Full text and rfc822 format available.

Message #20 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: 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 21:19:00 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: 64048 <at> debbugs.gnu.org
> Date: Tue, 13 Jun 2023 17:21:30 +0000
> 
> 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.

> 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.

> And then we have non-standard variables like
> `dabbrev-ignored-buffer-modes', `hi-lock-exclude-modes',
> `which-func-modes' - all with different conventions.
> 
> I can also tell you that a question about disabling global minor modes
> in some buffers re-surfaces regularly in reddit discussions and IRC.
> 
> We even have FAQ entries like https://www.emacswiki.org/emacs/LineNumbers#h5o-10
> And the suggested solution is re-defunning "turn-on" function - do we
> really want to say that it is the way to go?

You are preaching to the choir, really.  There's nothing wrong with
using :predicate when introducing a new globalized minor mode.  I only
objected to doing that in a mode that exists for such a long time
without any conditions.

(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.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Tue, 13 Jun 2023 19:32:02 GMT) Full text and rfc822 format available.

Message #23 received at 64048 <at> debbugs.gnu.org (full text, mbox):

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Wed, 14 Jun 2023 11:59:01 GMT) Full text and rfc822 format available.

Message #26 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Wed, 14 Jun 2023 14:58:36 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: 64048 <at> debbugs.gnu.org
> Date: Tue, 13 Jun 2023 19:36:14 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > (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)

This change is probably harmless, but OTOH what does it give you that
the current code doesn't?  AFAIU, you still cannot customize the modes
where line numbers will be off.

IOW, :predicate is not a means for user customizations of the modes
where the minor mode will be turned on.  Or am I missing something?

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

It does?  Where is this documented?

> 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.

Is this behavior documented anywhere?  What I see in the docs (both
the doc string and the ELisp manual) is that the argument of
:predicate determines _statically_ which modes will activate the minor
mode.  The variable created by :predicate can be used to query Emacs
which modes are those, but cannot be used to change which modes do and
which don't.

If this is not what happens, we have a major mis-documentation on our
hands.

> >> 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.

You can either disable it selectively (which is very obvious to me,
FWIW), or you can selectively enable it.  Both approaches are not
rocket science, IMO.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Wed, 14 Jun 2023 12:45:01 GMT) Full text and rfc822 format available.

Message #29 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Wed, 14 Jun 2023 12:48:54 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> 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)
>
> This change is probably harmless, but OTOH what does it give you that
> the current code doesn't?  AFAIU, you still cannot customize the modes
> where line numbers will be off.
>
> IOW, :predicate is not a means for user customizations of the modes
> where the minor mode will be turned on.  Or am I missing something?

>> :predicate defines the default value of
>> `global-display-line-numbers-modes' variable.
>
> It does?  Where is this documented?

Yup. It is not documented on API level, but when :predicate is non-nil,
`define-globalized-minor-mode' does the following:

(setq turn-on-function
      `(lambda ()
         (require 'easy-mmode)
         (when (easy-mmode--globalized-predicate-p ,MODE-predicate)
           (funcall ,turn-on-function))))

;; Minor mode docstring:
(if predicate
    (concat
     "\n\n"
     (internal--format-docstring-line
      "`%s' is used to control which modes this minor mode is used in."
      MODE-predicate)) ;; <global-mode-name>-modes
  "")

,(when predicate
          `(defcustom ,MODE-predicate ,(car predicate)
             ,(format "Which major modes `%s' is switched on in.
This variable can be either t (all major modes), nil (no major modes),
or a list of modes and (not modes) to switch use this minor mode or
not.  For instance

  (c-mode (not message-mode mail-mode) text-mode)

means \"use this mode in all modes derived from `c-mode', don't use in
modes derived from `message-mode' or `mail-mode', but do use in other
modes derived from `text-mode'\".  An element with value t means \"use\"
and nil means \"don't use\".  There's an implicit nil at the end of the
list."
                      mode)
             :type '(repeat sexp)
             ,@group))

>> 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.
>
> You can either disable it selectively (which is very obvious to me,
> FWIW), or you can selectively enable it.  Both approaches are not
> rocket science, IMO.

I partially agree, and I also find the approach obvious once I see it.
But the variable is easier (requires less Elisp knowledge) and is
already used in _some_ global minor modes. IMHO, controlling global
minor modes is one of the basic features that should be better exposed to
newbie users who use customize interface and do not know Elisp.

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 07:47:02 GMT) Full text and rfc822 format available.

Message #32 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64048 <at> debbugs.gnu.org
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 10:46:05 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 64048 <at> debbugs.gnu.org
> Date: Wed, 14 Jun 2023 12:48:54 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> 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)
> >
> > This change is probably harmless, but OTOH what does it give you that
> > the current code doesn't?  AFAIU, you still cannot customize the modes
> > where line numbers will be off.
> >
> > IOW, :predicate is not a means for user customizations of the modes
> > where the minor mode will be turned on.  Or am I missing something?
> 
> >> :predicate defines the default value of
> >> `global-display-line-numbers-modes' variable.
> >
> > It does?  Where is this documented?
> 
> Yup. It is not documented on API level, but when :predicate is non-nil,
> `define-globalized-minor-mode' does the following:
> 
> (setq turn-on-function
>       `(lambda ()
>          (require 'easy-mmode)
>          (when (easy-mmode--globalized-predicate-p ,MODE-predicate)
>            (funcall ,turn-on-function))))
> 
> ;; Minor mode docstring:
> (if predicate
>     (concat
>      "\n\n"
>      (internal--format-docstring-line
>       "`%s' is used to control which modes this minor mode is used in."
>       MODE-predicate)) ;; <global-mode-name>-modes
>   "")
> 
> ,(when predicate
>           `(defcustom ,MODE-predicate ,(car predicate)
>              ,(format "Which major modes `%s' is switched on in.
> This variable can be either t (all major modes), nil (no major modes),
> or a list of modes and (not modes) to switch use this minor mode or
> not.  For instance
> 
>   (c-mode (not message-mode mail-mode) text-mode)
> 
> means \"use this mode in all modes derived from `c-mode', don't use in
> modes derived from `message-mode' or `mail-mode', but do use in other
> modes derived from `text-mode'\".  An element with value t means \"use\"
> and nil means \"don't use\".  There's an implicit nil at the end of the
> list."
>                       mode)
>              :type '(repeat sexp)
>              ,@group))

Stefan, is our current documentation of :predicate incomplete?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 18:31:02 GMT) Full text and rfc822 format available.

Message #35 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> posteo.net>
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 14:30:30 -0400
> Stefan, is our current documentation of :predicate incomplete?

I'm not really familiar with that argument (AFAICT it was implemented
by Lars in commit b8b18cf34a04a).  The whole feature puts me off a bit
because of its name: in my world a "predicate" is a kind of function,
so I think it's a poor name for a variable containing some list-based
description of a set of modes.

But indeed, it seems the docstring forgets to mention that the
`:predicate MODES` argument causes the introduction of a new variable
called `MINOR-MODE-predicate` and whose default value is MODES.


        Stefan "who'd rename the `:predicate` arg to something like
                `:modes` and the `MODE-predicate` variable to something
                like `MODE-modes`."





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 18:59:01 GMT) Full text and rfc822 format available.

Message #38 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64048 <at> debbugs.gnu.org, yantar92 <at> posteo.net
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 21:58:04 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Ihor Radchenko <yantar92 <at> posteo.net>,  64048 <at> debbugs.gnu.org
> Date: Sat, 17 Jun 2023 14:30:30 -0400
> 
> > Stefan, is our current documentation of :predicate incomplete?
> 
> I'm not really familiar with that argument (AFAICT it was implemented
> by Lars in commit b8b18cf34a04a).  The whole feature puts me off a bit
> because of its name: in my world a "predicate" is a kind of function,
> so I think it's a poor name for a variable containing some list-based
> description of a set of modes.
> 
> But indeed, it seems the docstring forgets to mention that the
> `:predicate MODES` argument causes the introduction of a new variable
> called `MINOR-MODE-predicate` and whose default value is MODES.

That's mostly already documented.  What is NOT documented is that by
giving that variable a non-default value one can affect in which modes
this minor mode will be turned on and in which it will be turned off.
IOW, the fact that this variable can be used for user customizations
is not documented at all.  And your answer just hints on whether the
above is true.

>         Stefan "who'd rename the `:predicate` arg to something like
>                 `:modes` and the `MODE-predicate` variable to something
>                 like `MODE-modes`."

I guess it's too late for renaming this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 19:00:02 GMT) Full text and rfc822 format available.

Message #41 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64048 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 19:04:07 +0000
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> But indeed, it seems the docstring forgets to mention that the
> `:predicate MODES` argument causes the introduction of a new variable
> called `MINOR-MODE-predicate` and whose default value is MODES.

Not `MINOR-MODE-predicate', `MINOR-MODE-modes':

(MODE-predicate (intern (concat (replace-regexp-in-string
                                          "-mode\\'" "" global-mode-name)
                                         "-modes")))

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 19:02:02 GMT) Full text and rfc822 format available.

Message #44 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64048 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 19:06:39 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>>         Stefan "who'd rename the `:predicate` arg to something like
>>                 `:modes` and the `MODE-predicate` variable to something
>>                 like `MODE-modes`."
>
> I guess it's too late for renaming this?

It can be done in backwards-compatible way, so why not?
Just keep :predicate in the code as internal compatibility alias.
This is for the argument.

The defined customization does not need to be renamed. It already has
MODE-modes symbol name.

-- 
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>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64048; Package emacs. (Sat, 17 Jun 2023 19:19:02 GMT) Full text and rfc822 format available.

Message #47 received at 64048 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 64048 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#64048: 30.0.50; global-display-line-numbers-mode has no
 easy way to set modes where it is enabled
Date: Sat, 17 Jun 2023 15:18:42 -0400
>> But indeed, it seems the docstring forgets to mention that the
>> `:predicate MODES` argument causes the introduction of a new variable
>> called `MINOR-MODE-predicate` and whose default value is MODES.
>
> Not `MINOR-MODE-predicate', `MINOR-MODE-modes':
>
> (MODE-predicate (intern (concat (replace-regexp-in-string
>                                           "-mode\\'" "" global-mode-name)
>                                          "-modes")))

Ha!  Great minds do think alike after all!


        Stefan





This bug report was last modified 321 days ago.

Previous Next


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