GNU bug report logs - #79412
30.2; `define-globalized-minor-mode' does not respect `:variable'

Previous Next

Package: emacs;

Reported by: inet0 <at> qq.com

Date: Tue, 9 Sep 2025 02:01:03 UTC

Severity: normal

Found in version 30.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: inet0 <at> qq.com, 79412 <at> debbugs.gnu.org
Subject: bug#79412: 30.2; `define-globalized-minor-mode' does not respect `:variable'
Date: Sat, 13 Sep 2025 12:57:29 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: inet0 <at> qq.com,  79412 <at> debbugs.gnu.org
> Date: Tue, 09 Sep 2025 18:16:38 -0400
> 
> >> I have found something suspicious at source code
> >> `lisp/emacs-lisp/easy-mmode.el:569:23':
> >> 
> >> 	 ;; Go through existing buffers.
> >> 	 (dolist (buf (buffer-list))
> >> 	   (with-current-buffer buf
> >>              (if ,global-mode (funcall ,turn-on-function)
> >>                (when ,mode (,mode -1)))))
> >> 
> >> It seems that `mode' at the predicate position of `when' should really
> >> be `MODE-variable'!
> >
> > Adding Stefan in case he has some insights.
> 
> I agree with "inet0 <at> qq.com", here.
> It looks like an oversight in commit e1d54bb638df.

So you mean this:

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index ca92130..de77eb3 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -570,7 +570,7 @@ define-globalized-minor-mode
 	 (dolist (buf (buffer-list))
 	   (with-current-buffer buf
              (if ,global-mode (funcall ,turn-on-function)
-               (when ,mode (,mode -1)))))
+               (when ,mode (,MODE-variable -1)))))
          ,@body)
 
        ,(when predicate

And what about this fragment:

       ;; The function that calls TURN-ON in the current buffer.
       (defun ,MODE-enable-in-buffer ()
         (unless ,MODE-set-explicitly
           (unless (eq ,MODE-major-mode major-mode)
             (if ,MODE-variable
                 (progn
                   (,mode -1)  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                   (funcall ,turn-on-function))
               (funcall ,turn-on-function))))
         (setq ,MODE-major-mode major-mode))
       (put ',MODE-enable-in-buffer 'definition-name ',global-mode))))

And this one:

	 ;; Go through existing buffers.
	 (dolist (buf (buffer-list))
	   (with-current-buffer buf
             (if ,global-mode (funcall ,turn-on-function)
               (when ,mode (,MODE-variable -1)))))
         ,@body)




This bug report was last modified 1 day ago.

Previous Next


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