GNU bug report logs -
#79198
31.0.50; Problem with multiple global auto-revert modes
Previous Next
To reply to this bug, email your comments to 79198 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
jonas <at> bernoul.li, monnier <at> iro.umontreal.ca, sbaugh <at> janestreet.com, bug-gnu-emacs <at> gnu.org
:
bug#79198
; Package
emacs
.
(Fri, 08 Aug 2025 12:48:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
New bug report received and forwarded. Copy sent to
jonas <at> bernoul.li, monnier <at> iro.umontreal.ca, sbaugh <at> janestreet.com, bug-gnu-emacs <at> gnu.org
.
(Fri, 08 Aug 2025 12:48:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
X-debbugs-cc: jonas <at> bernoul.li, monnier <at> iro.umontreal.ca, sbaugh <at> janestreet.com
Hello,
Currently, between Emacs core and Magit, there are three globalized
versions of auto-revert-mode: global-auto-revert-mode,
magit-auto-revert-mode and the new vc-auto-revert-mode.
global-auto-revert-mode has a custom definition, but
magit-auto-revert-mode and vc-auto-revert-mode both use
define-globalized-minor-mode. That means they both make use of the
variable auto-revert-mode-major-mode. Macroexpanding,
--8<---------------cut here---------------start------------->8---
(defun vc-auto-revert-mode-enable-in-buffer ()
(unless auto-revert-mode-set-explicitly
(unless (eq auto-revert-mode-major-mode major-mode) ; <-- HERE
(if auto-revert-mode
(progn
(auto-revert-mode -1)
(funcall
(function vc-turn-on-auto-revert-mode-for-tracked-files)))
(funcall
(function vc-turn-on-auto-revert-mode-for-tracked-files)))))
(setq auto-revert-mode-major-mode major-mode))
--8<---------------cut here---------------end--------------->8---
and
--8<---------------cut here---------------start------------->8---
(defun magit-auto-revert-mode-enable-in-buffer ()
(unless auto-revert-mode-set-explicitly
(unless (eq auto-revert-mode-major-mode major-mode) ; <-- HERE
(if auto-revert-mode
(progn
(auto-revert-mode -1)
(funcall (function magit-turn-on-auto-revert-mode-if-desired)))
(funcall (function magit-turn-on-auto-revert-mode-if-desired)))))
(setq auto-revert-mode-major-mode major-mode))
--8<---------------cut here---------------end--------------->8---
But now the following problem can occur:
1. Enable magit-auto-revert-mode.
2. *Subsequently*, enable vc-auto-revert-mode.
3. Visit a tracked file in a non-Git VC repository.
Expected behaviour: vc-auto-revert-mode turns on auto-revert-mode
because it's a buffer visiting a VCS-tracked file.
Actual behaviour: magit-auto-revert-mode-enable-in-buffer declines to
enable auto-revert-mode because it's not a Git repository. It sets
auto-revert-mode-major-mode to non-nil. But then
vc-auto-revert-mode-enable-in-buffer thinks it has already been called,
and also does nothing.
I think that the following would fix the problem; how does it look:
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 46c99052090..f2d21d7ef45 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -500,7 +500,8 @@ define-globalized-minor-mode
(intern (concat global-mode-name "-enable-in-buffer")))
(minor-MODE-hook (intern (concat mode-name "-hook")))
(MODE-set-explicitly (intern (concat mode-name "-set-explicitly")))
- (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
+ (MODE-major-mode (intern (concat (symbol-name global-mode)
+ "-major-mode")))
(MODE-predicate (intern (concat (replace-regexp-in-string
"-mode\\'" "" global-mode-name)
"-modes")))
--8<---------------cut here---------------end--------------->8---
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79198
; Package
emacs
.
(Sat, 09 Aug 2025 07:48:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79198 <at> debbugs.gnu.org (full text, mbox):
> I think that the following would fix the problem; how does it look:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
> index 46c99052090..f2d21d7ef45 100644
> --- a/lisp/emacs-lisp/easy-mmode.el
> +++ b/lisp/emacs-lisp/easy-mmode.el
> @@ -500,7 +500,8 @@ define-globalized-minor-mode
> (intern (concat global-mode-name "-enable-in-buffer")))
> (minor-MODE-hook (intern (concat mode-name "-hook")))
> (MODE-set-explicitly (intern (concat mode-name "-set-explicitly")))
> - (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
> + (MODE-major-mode (intern (concat (symbol-name global-mode)
> + "-major-mode")))
> (MODE-predicate (intern (concat (replace-regexp-in-string
> "-mode\\'" "" global-mode-name)
> "-modes")))
> --8<---------------cut here---------------end--------------->8---
I tend to agree and would suggest to put a "--" in there as well, since
it's used internally by the global major mode and is not meant to be
used by other code.
[ Same for the "-set-explicitly" which should be "--set-explicitly". ]
Stefan
Reply sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
You have taken responsibility.
(Sat, 09 Aug 2025 09:45:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
bug acknowledged by developer.
(Sat, 09 Aug 2025 09:45:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 79198-done <at> debbugs.gnu.org (full text, mbox):
Hello,
On Sat 09 Aug 2025 at 03:47am -04, Stefan Monnier wrote:
>> I think that the following would fix the problem; how does it look:
>>
>> --8<---------------cut here---------------start------------->8---
>> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
>> index 46c99052090..f2d21d7ef45 100644
>> --- a/lisp/emacs-lisp/easy-mmode.el
>> +++ b/lisp/emacs-lisp/easy-mmode.el
>> @@ -500,7 +500,8 @@ define-globalized-minor-mode
>> (intern (concat global-mode-name "-enable-in-buffer")))
>> (minor-MODE-hook (intern (concat mode-name "-hook")))
>> (MODE-set-explicitly (intern (concat mode-name "-set-explicitly")))
>> - (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
>> + (MODE-major-mode (intern (concat (symbol-name global-mode)
>> + "-major-mode")))
>> (MODE-predicate (intern (concat (replace-regexp-in-string
>> "-mode\\'" "" global-mode-name)
>> "-modes")))
>> --8<---------------cut here---------------end--------------->8---
>
> I tend to agree and would suggest to put a "--" in there as well, since
> it's used internally by the global major mode and is not meant to be
> used by other code.
> [ Same for the "-set-explicitly" which should be "--set-explicitly". ]
Thanks for reviewing, now done.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79198
; Package
emacs
.
(Sat, 09 Aug 2025 14:58:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 79198-done <at> debbugs.gnu.org (full text, mbox):
Sean Whitton <spwhitton <at> spwhitton.name> writes:
> Hello,
>
> On Sat 09 Aug 2025 at 03:47am -04, Stefan Monnier wrote:
>
>>> I think that the following would fix the problem; how does it look:
>>>
>>> --8<---------------cut here---------------start------------->8---
>>> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
>>> index 46c99052090..f2d21d7ef45 100644
>>> --- a/lisp/emacs-lisp/easy-mmode.el
>>> +++ b/lisp/emacs-lisp/easy-mmode.el
>>> @@ -500,7 +500,8 @@ define-globalized-minor-mode
>>> (intern (concat global-mode-name "-enable-in-buffer")))
>>> (minor-MODE-hook (intern (concat mode-name "-hook")))
>>> (MODE-set-explicitly (intern (concat mode-name "-set-explicitly")))
>>> - (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
>>> + (MODE-major-mode (intern (concat (symbol-name global-mode)
>>> + "-major-mode")))
>>> (MODE-predicate (intern (concat (replace-regexp-in-string
>>> "-mode\\'" "" global-mode-name)
>>> "-modes")))
>>> --8<---------------cut here---------------end--------------->8---
>>
>> I tend to agree and would suggest to put a "--" in there as well, since
>> it's used internally by the global major mode and is not meant to be
>> used by other code.
>> [ Same for the "-set-explicitly" which should be "--set-explicitly". ]
>
> Thanks for reviewing, now done.
Makes sense to me too.
Instead of (symbol-name global-mode) you could use global-mode-name.
Cheers,
Jonas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79198
; Package
emacs
.
(Sun, 10 Aug 2025 09:53:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 79198-done <at> debbugs.gnu.org (full text, mbox):
Hello,
Ah, thanks!
--
Sean Whitton
This bug report was last modified 7 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.