GNU bug report logs - #55451
28.1.50; Executing (jit-lock-mode -1) does not disable jit-lock-mode

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> gmail.com>

Date: Mon, 16 May 2022 14:01:01 UTC

Severity: normal

Found in version 28.1.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55451 in the body.
You can then email your comments to 55451 AT debbugs.gnu.org in the normal way.

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#55451; Package emacs. (Mon, 16 May 2022 14:01:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 16 May 2022 14:01:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1.50; Executing (jit-lock-mode -1) does not disable jit-lock-mode
Date: Mon, 16 May 2022 22:00:58 +0800
Hi,

I recently tried to disable jit-lock-mode using the usual syntax
(jit-lock-mode -1)

However, the mode was not disabled, which is unexpected.
I believe that the problem is caused by

....
If you need to debug code run from jit-lock, see `jit-lock-debug-mode'."
  (setq jit-lock-mode arg) ;; <- this sets jit-lock-mode to non-nil even if I pass -1 argument
  (cond
   ((and (buffer-base-buffer)
....

Best,
Ihor




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Mon, 16 May 2022 15:54:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50;
 Executing (jit-lock-mode -1) does not disable jit-lock-mode
Date: Mon, 16 May 2022 18:53:06 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Mon, 16 May 2022 22:00:58 +0800
> 
> I recently tried to disable jit-lock-mode using the usual syntax
> (jit-lock-mode -1)

jit-lock-mode is not a minor mode, so the usual syntax doesn't work
with it, and isn't documented to work.  Set it to nil to disable.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Tue, 17 May 2022 18:04:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ihor Radchenko <yantar92 <at> gmail.com>, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Tue, 17 May 2022 20:03:44 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> jit-lock-mode is not a minor mode, so the usual syntax doesn't work
> with it, and isn't documented to work.  Set it to nil to disable.

The doc string could do with some explicit text about this, so I've
added that to Emacs 29.  But since this is working as intended, I'm
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 55451 <at> debbugs.gnu.org and Ihor Radchenko <yantar92 <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 17 May 2022 18:04:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Wed, 18 May 2022 11:47:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Wed, 18 May 2022 19:46:35 +0800
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> jit-lock-mode is not a minor mode, so the usual syntax doesn't work
>> with it, and isn't documented to work.  Set it to nil to disable.
>
> The doc string could do with some explicit text about this, so I've
> added that to Emacs 29.  But since this is working as intended, I'm
> closing this bug report.

Thanks! It certainly improves the situation.
However, I am confused why it is impossible to follow +1/-1 convention.
Looking through jit-lock.el I do not see any place where any value other
than non-nil/nil is considered.

A possible patch is attached.

Best,
Ihor

[0001-jit-lock-mode-Treat-1-and-1-ARG-as-other-normal-mino.patch (text/x-patch, inline)]
From a9da60ba42f6745f4bbdb305e057639c40f8d34e Mon Sep 17 00:00:00 2001
Message-Id: <a9da60ba42f6745f4bbdb305e057639c40f8d34e.1652874345.git.yantar92 <at> gmail.com>
From: Ihor Radchenko <yantar92 <at> gmail.com>
Date: Wed, 18 May 2022 19:44:25 +0800
Subject: [PATCH] jit-lock-mode: Treat +1 and -1 ARG as other normal minor
 modes

* lisp/jit-lock.el (jit-lock-mode): Recognise +1/-1 arguments using
minor mode conventions.
---
 lisp/jit-lock.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index 20c1202474..224223fc7e 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -218,7 +218,12 @@ jit-lock-mode
 the variable `jit-lock-stealth-nice'.
 
 If you need to debug code run from jit-lock, see `jit-lock-debug-mode'."
-  (setq jit-lock-mode arg)
+  (setq jit-lock-mode
+        (pcase arg
+          (`+1 t)
+          (`-1 nil)
+          (`nil nil)
+          (val val)))
   (cond
    ((and (buffer-base-buffer)
          jit-lock-mode)
-- 
2.35.1


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Wed, 18 May 2022 17:29:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Wed, 18 May 2022 19:27:58 +0200
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> However, I am confused why it is impossible to follow +1/-1 convention.
> Looking through jit-lock.el I do not see any place where any value other
> than non-nil/nil is considered.

It would be incompatible -- all non-nil values switch jit-lock on
presently, including -1.

It's pretty unlikely that anybody's using -1 to switch it on, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Wed, 18 May 2022 17:42:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: yantar92 <at> gmail.com, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Wed, 18 May 2022 20:41:05 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  55451 <at> debbugs.gnu.org
> Date: Wed, 18 May 2022 19:27:58 +0200
> 
> Ihor Radchenko <yantar92 <at> gmail.com> writes:
> 
> > However, I am confused why it is impossible to follow +1/-1 convention.
> > Looking through jit-lock.el I do not see any place where any value other
> > than non-nil/nil is considered.
> 
> It would be incompatible -- all non-nil values switch jit-lock on
> presently, including -1.

Yes.  Moreover, it's hardly worth the hassle: who would switch off
jit-lock, except for debugging jit-lock?  Most people will never do,
which is very unlike every minor mode out there -- those are switched
on and off all the time.  It isn't an accident that we don't have the
"M-x jit-lock-mode" command.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Thu, 19 May 2022 13:49:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Thu, 19 May 2022 21:49:21 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,  55451 <at> debbugs.gnu.org
>> Date: Wed, 18 May 2022 19:27:58 +0200
>> 
>> Ihor Radchenko <yantar92 <at> gmail.com> writes:
>> 
>> > However, I am confused why it is impossible to follow +1/-1 convention.
>> > Looking through jit-lock.el I do not see any place where any value other
>> > than non-nil/nil is considered.
>> 
>> It would be incompatible -- all non-nil values switch jit-lock on
>> presently, including -1.
>
> Yes.  Moreover, it's hardly worth the hassle: who would switch off
> jit-lock, except for debugging jit-lock?  Most people will never do,
> which is very unlike every minor mode out there -- those are switched
> on and off all the time.  It isn't an accident that we don't have the
> "M-x jit-lock-mode" command.

That's exactly the situation I had:
1. Tried M-x jit-lock-mode. Did not work. Understandable - special minor
   mode.
2. M-: (jit-lock-mode -1). No error. Executed.
3. Tried to debug something assuming that jit-lock is disabled.
4. After several minutes, realised that jit-lock is still working.

So, similar to other Elisp conventions, I do expect everything called
minor mode to follow the calling convention with +1/-1. Not doing so is
a surprise. Not doing so without a clear indication (like an error) is a
recipe for confusion.

I would not expect users to read minor mode docstring every time to
check if the usual convention is broken. There should be some kind of
indication at least, be it an unusual symbol name, a user error, or
something similarly noticeable.

Best,
Ihor






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Thu, 19 May 2022 14:01:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: larsi <at> gnus.org, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Thu, 19 May 2022 17:00:36 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,  55451 <at> debbugs.gnu.org
> Date: Thu, 19 May 2022 21:49:21 +0800
> 
> > Yes.  Moreover, it's hardly worth the hassle: who would switch off
> > jit-lock, except for debugging jit-lock?  Most people will never do,
> > which is very unlike every minor mode out there -- those are switched
> > on and off all the time.  It isn't an accident that we don't have the
> > "M-x jit-lock-mode" command.
> 
> That's exactly the situation I had:
> 1. Tried M-x jit-lock-mode. Did not work. Understandable - special minor
>    mode.
> 2. M-: (jit-lock-mode -1). No error. Executed.
> 3. Tried to debug something assuming that jit-lock is disabled.
> 4. After several minutes, realised that jit-lock is still working.

But the doc string already caters to your use case:

  If you need to debug code run from jit-lock, see `jit-lock-debug-mode'

> I would not expect users to read minor mode docstring every time to
> check if the usual convention is broken.

Users don't need to turn off jit-lock.  People who want to debug it,
OTOH, _are_ expected to read the doc string.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Thu, 19 May 2022 23:14:02 GMT) Full text and rfc822 format available.

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

From: Richard Stallman <rms <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, yantar92 <at> gmail.com, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50;
 Executing (jit-lock-mode -1) does not disable jit-lock-mode
Date: Thu, 19 May 2022 19:13:43 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Yes.  Moreover, it's hardly worth the hassle: who would switch off
  > jit-lock, except for debugging jit-lock?  Most people will never do,
  > which is very unlike every minor mode out there -- those are switched
  > on and off all the time.  It isn't an accident that we don't have the
  > "M-x jit-lock-mode" command.

I don't think I have ever turned off Jit-Lock mode _as such_, but I
turn off Font-Lock mode in some major modes.  I don't know whether
that is that pertinent to this issue; I mention it just in case.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Fri, 20 May 2022 06:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: rms <at> gnu.org
Cc: larsi <at> gnus.org, yantar92 <at> gmail.com, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50;
 Executing (jit-lock-mode -1) does not disable jit-lock-mode
Date: Fri, 20 May 2022 09:55:31 +0300
> From: Richard Stallman <rms <at> gnu.org>
> Cc: larsi <at> gnus.org, yantar92 <at> gmail.com, 55451 <at> debbugs.gnu.org
> Date: Thu, 19 May 2022 19:13:43 -0400
> 
>   > Yes.  Moreover, it's hardly worth the hassle: who would switch off
>   > jit-lock, except for debugging jit-lock?  Most people will never do,
>   > which is very unlike every minor mode out there -- those are switched
>   > on and off all the time.  It isn't an accident that we don't have the
>   > "M-x jit-lock-mode" command.
> 
> I don't think I have ever turned off Jit-Lock mode _as such_, but I
> turn off Font-Lock mode in some major modes.  I don't know whether
> that is that pertinent to this issue

It isn't, AFAIU.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55451; Package emacs. (Fri, 20 May 2022 08:14:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, 55451 <at> debbugs.gnu.org
Subject: Re: bug#55451: 28.1.50; Executing (jit-lock-mode -1) does not
 disable jit-lock-mode
Date: Fri, 20 May 2022 16:13:58 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> That's exactly the situation I had:
>> 1. Tried M-x jit-lock-mode. Did not work. Understandable - special minor
>>    mode.
>> 2. M-: (jit-lock-mode -1). No error. Executed.
>> 3. Tried to debug something assuming that jit-lock is disabled.
>> 4. After several minutes, realised that jit-lock is still working.
>
> But the doc string already caters to your use case:
>
>   If you need to debug code run from jit-lock, see `jit-lock-debug-mode'

To clarify, I was trying to debug race condition in font-lock itself.
jit-lock made things even more complex and I just wanted to quickly
disable it. I did not want to debug jit-lock behaviour at all.

>> I would not expect users to read minor mode docstring every time to
>> check if the usual convention is broken.
>
> Users don't need to turn off jit-lock.  People who want to debug it,
> OTOH, _are_ expected to read the doc string.

I understand. I do not consider the described issue critical. However,
from a perspective of Elisp developer, minor mode docstrings rarely
contain low-level information. Rather general minor mode description +
standard boilerplate generated by define-minor-mode. That boilerplate is
well-known an is usually not worth checking out multiple times:

>>> This is a minor mode.  If called interactively, toggle the
>>> Org-Indent mode mode.  If the prefix argument is positive,
>>> enable the mode, and if it is zero or negative, disable the mode.
>>> 
>>> If called from Lisp, toggle the mode if ARG is toggle.  Enable
>>> the mode if ARG is nil, omitted, or is a positive number.
>>> Disable the mode if ARG is a negative number.
>>> 
>>> To check whether the minor mode is enabled in the current buffer,
>>> evaluate ...

So, I would not expect that habituated developers actually check out the
docstring regarding enabling/disabling the mode. At least I did not
until I realised that something is strange and jit-lock-mode was not
disabled after M-: (jit-lock-mode -1)

Again, it is just my perspective consisting of a single personal
datapoint. If you think that the current state is ok, feel free to
disregard my complaint.

Best,
Ihor





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 17 Jun 2022 11:24:07 GMT) Full text and rfc822 format available.

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

Previous Next


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