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>

To reply to this bug, email your comments to 79412 AT debbugs.gnu.org.
There is no need to reopen the bug first.

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#79412; Package emacs. (Tue, 09 Sep 2025 02:01:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to inet0 <at> qq.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 09 Sep 2025 02:01:04 GMT) Full text and rfc822 format available.

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

From: inet0 <at> qq.com
To: bug-gnu-emacs <at> gnu.org
Subject: 30.2; `define-globalized-minor-mode' does not respect `:variable'
Date: Tue, 09 Sep 2025 03:40:36 +0800
Hi there,

I am using Emacs as a GUI application on Android (distributed by F-Droid
if that matters) so `emacs -Q' is not an option, but the symptoms should
be reproduced by

(1) evaluating the program segments below, then

(2) typing `C-c b' twice.

(define-minor-mode bidi-display-reordering-mode
  nil
  :variable bidi-display-reordering)

(define-globalized-minor-mode global-bidi-display-reordering-mode
  bidi-display-reordering-mode
  (lambda () (bidi-display-reordering-mode 1))
  :variable bidi-display-reordering)

(keymap-global-set "C-c b" 'global-bidi-display-reordering-mode)

Buffer *Messages*:

Loading gnus...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Global Bidi-Display-Reordering mode enabled
if: Symbol’s value as variable is void: bidi-display-reordering-mode

Buffer *Backtrace*:

Debugger entered--Lisp error: (void-variable bidi-display-reordering-mode)
  (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1)))
  (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1))))
  (save-current-buffer (set-buffer buf) (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1)))))
  (let ((buf (car tail))) (save-current-buffer (set-buffer buf) (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1))))) (setq tail (cdr tail)))
  (while tail (let ((buf (car tail))) (save-current-buffer (set-buffer buf) (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1))))) (setq tail (cdr tail))))
  (let ((tail (buffer-list))) (while tail (let ((buf (car tail))) (save-current-buffer (set-buffer buf) (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1))))) (setq tail (cdr tail)))))
  (let ((last-message (current-message))) (progn (set-default 'global-bidi-display-reordering-mode (cond ((eq arg 'toggle) (not (default-value 'global-bidi-display-reordering-mode))) ((and (numberp arg) (< arg 1)) nil) (t t)))) (if (boundp 'global-minor-modes) (progn (setq global-minor-modes (delq 'global-bidi-display-reordering-mode global-minor-modes)) (if (default-value 'global-bidi-display-reordering-mode) (progn (setq global-minor-modes (cons 'global-bidi-display-reordering-mode global-minor-modes)))))) (if global-bidi-display-reordering-mode (add-hook 'after-change-major-mode-hook #'global-bidi-display-reordering-mode-enable-in-buffer) (remove-hook 'after-change-major-mode-hook #'global-bidi-display-reordering-mode-enable-in-buffer)) (let ((tail (buffer-list))) (while tail (let ((buf (car tail))) (save-current-buffer (set-buffer buf) (if global-bidi-display-reordering-mode (bidi-display-reordering-mode 1) (if bidi-display-reordering-mode (progn (bidi-display-reordering-mode -1))))) (setq tail (cdr tail))))) (run-hooks 'global-bidi-display-reordering-mode-hook (if (default-value 'global-bidi-display-reordering-mode) 'global-bidi-display-reordering-mode-on-hook 'global-bidi-display-reordering-mode-off-hook)) (if (called-interactively-p 'any) (progn (customize-mark-as-set 'global-bidi-display-reordering-mode) (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local "")) (message "%s %sabled%s" "Global Bidi-Display-Reordering mode" (if (default-value 'global-bidi-display-reordering-mode) "en" "dis") local))))))
  global-bidi-display-reordering-mode(toggle)
  funcall-interactively(global-bidi-display-reordering-mode toggle)
  call-interactively(global-bidi-display-reordering-mode nil nil)
  command-execute(global-bidi-display-reordering-mode)

One would expect a line `Global Glyphless-Display mode disabled' in
buffer *Messages*, but Emacs only complains about the variable
`bidi-display-reordering-mode' being void, and the corresponding
buffer-local mode is not disabled either.

After searching on the Internet and on the GNU Bug Tracker, I came
across this related bug report:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29081

Notice the use of keyword `:variable' in the form
`define-globalized-minor-mode' whose paired value, according to info
node `(elisp)Defining Minor Modes', should match that of the same
keyword in the corresponding form `define-minor-mode'.

With that in mind, I suspect that the buffer-local mode name is
mistakenly referenced instead of the name specified by keyword
`:variable', thus causing a void-variable error. 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'!

As an aside, the docstring of `define-globalized-minor-mode' is a bit
off the description in the ELisp manual. (Jumping between `C-h f' and
`C-h i m el i' is annoying, isn't it?)

The manual says:

     By default, the buffer-local minor mode variable that says whether
     the mode is switched on or off is the same as the name of the mode
     itself.  Use ‘:variable VARIABLE’ if that’s not the case–some minor
     modes use a different variable to store this state information.

While in docstring:

Other keywords have the same meaning as in ‘define-minor-mode’,
which see.

Clearly, `:variable' in `define-globalized-minor-mode' does not have the
same meaning as in `define-minor-mode', otherwise you would be
specifying the mode variable of the global mode, which is not the case.


In GNU Emacs 30.2 (build 1, aarch64-unknown-linux-android22) of
 2025-08-18 built on bookworm
Repository revision: 636f166cfc86aa90d63f592fd99f3fdd9ef95ebd
Repository branch: HEAD
Windowing system distributor 'Xiaomi', version 33.0.0
System Description: Redmi/alioth/alioth:13/TKQ1.220829.002/V14.0.8.0.TKHCNXM:user/release-keys

Configured using:
 'configure --with-png=yes --with-webp=yes --with-gif=yes
 --with-jpeg=yes --with-xml2=yes --with-sqlite3=yes --with-gnutls=yes
 --with-tiff=yes --with-selinux=yes --with-modules=yes
 --with-tree-sitter=yes --with-imagemagick=no --with-lcms2=yes
 --with-mailutils= --with-pop=no-by-default --with-harfbuzz=yes
 --with-threads=yes --with-rsvg=yes --enable-check-lisp-object-type=
 'CFLAGS= -Werror=implicit-function-declaration''

Configured features:
GIF GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP THREADS TIFF TREE_SITTER WEBP ZLIB

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  cursor-sensor-mode: t
  gnus-undo-mode: t
  server-mode: t
  glyphless-display-mode: t
  global-glyphless-display-mode: t
  bidi-display-reordering: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort gnus-cite mail-extr emacsbug cursor-sensor nndraft nnmh
utf-7 network-stream nsm nnfolder nnnil gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime
smime gnutls dig nntp gnus-cache gnus-sum shr pixel-fill kinsoku
url-file svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml
gnus-cloud nnimap nnmail browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util url-parse auth-source cl-seq eieio eieio-core json map byte-opt
bytecomp byte-compile url-vars mail-source utf7 nnoo parse-time iso8601
gnus-spec gnus-int gnus-range gnus-win noutline outline server cl-macs
message sendmail mailcap yank-media puny dired dired-loaddefs rfc822 mml
mml-sec password-cache epa derived epg rfc6068 epg-config mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus nnheader gnus-util
text-property-search time-date subr-x mail-utils range mm-util
mail-prsvr cus-edit pp cus-load icons wid-edit cl-loaddefs cl-lib
disp-table glyphless-mode gv easy-mmode china-util rmc iso-transl
tooltip cus-start cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel android-win term/common-win
touch-screen ls-lisp tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads inotify android multi-tty move-toolbar make-network-process
emacs)

Memory information:
((conses 16 142708 12432) (symbols 48 15036 1) (strings 32 43127 1451)
 (string-bytes 1 1143115) (vectors 16 25917)
 (vector-slots 8 306696 18106) (floats 8 210 4) (intervals 56 578 0)
 (buffers 992 16))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Tue, 09 Sep 2025 09:32:02 GMT) Full text and rfc822 format available.

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

From: inet0 <at> qq.com
To: 79412 <at> debbugs.gnu.org
Subject: Re: 30.2; `define-globalized-minor-mode' does not respect `:variable'
Date: Tue, 09 Sep 2025 17:30:57 +0800
I forgot to mention that it is not working too when the paired value of
keyword `:variable' takes the form `(GET . SET)':

(define-minor-mode text-conversion-mode
  nil
  :variable (text-conversion-style . set-text-conversion-style))

(define-globalized-minor-mode global-text-conversion-mode
  text-conversion-mode
  (lambda () (text-conversion-mode 1))
  :variable text-conversion-style)

(keymap-global-set "C-c a" 'global-text-conversion-mode)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Tue, 09 Sep 2025 12:04:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: inet0 <at> qq.com, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2;
 `define-globalized-minor-mode' does not respect `:variable'
Date: Tue, 09 Sep 2025 15:02:56 +0300
> Date: Tue, 09 Sep 2025 03:40:36 +0800
> From: inet0--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> I am using Emacs as a GUI application on Android (distributed by F-Droid
> if that matters) so `emacs -Q' is not an option, but the symptoms should
> be reproduced by
> 
> (1) evaluating the program segments below, then
> 
> (2) typing `C-c b' twice.
> 
> (define-minor-mode bidi-display-reordering-mode
>   nil
>   :variable bidi-display-reordering)
> 
> (define-globalized-minor-mode global-bidi-display-reordering-mode
>   bidi-display-reordering-mode
>   (lambda () (bidi-display-reordering-mode 1))
>   :variable bidi-display-reordering)
> 
> (keymap-global-set "C-c b" 'global-bidi-display-reordering-mode)
> 
> Buffer *Messages*:
> 
> Loading gnus...done
> For information about GNU Emacs and the GNU system, type C-h C-a.
> Global Bidi-Display-Reordering mode enabled
> if: Symbol’s value as variable is void: bidi-display-reordering-mode

The ELisp manual says about ':variable':

     ‘:variable PLACE’
          This replaces the default variable MODE, used to store the
          state of the mode.  If you specify this, the MODE variable is
          not defined, and any INIT-VALUE argument is unused.

What this means is that using :variable leaves the mode variable, in
this case bidi-display-reordering-mode, undefined.  Therefore, I think
you must define some non-trivial BODY for your minor mode, because the
default body will try to reference bidi-display-reordering-mode, and
will fail, as this backtrace shows:

> Buffer *Backtrace*:
> 
> Debugger entered--Lisp error: (void-variable bidi-display-reordering-mode)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> With that in mind, I suspect that the buffer-local mode name is
> mistakenly referenced instead of the name specified by keyword
> `:variable', thus causing a void-variable error.

I don't think this is accurate.  A globalized minor mode works by
walking the list of all the buffers and turning on the local minor
mode in each one of them.

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

> As an aside, the docstring of `define-globalized-minor-mode' is a bit
> off the description in the ELisp manual. (Jumping between `C-h f' and
> `C-h i m el i' is annoying, isn't it?)
> 
> The manual says:
> 
>      By default, the buffer-local minor mode variable that says whether
>      the mode is switched on or off is the same as the name of the mode
>      itself.  Use ‘:variable VARIABLE’ if that’s not the case–some minor
>      modes use a different variable to store this state information.
> 
> While in docstring:
> 
> Other keywords have the same meaning as in ‘define-minor-mode’,
> which see.
> 
> Clearly, `:variable' in `define-globalized-minor-mode' does not have the
> same meaning as in `define-minor-mode', otherwise you would be
> specifying the mode variable of the global mode, which is not the case.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Tue, 09 Sep 2025 22:17:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: inet0 <at> qq.com, 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
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.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Thu, 11 Sep 2025 15:30:02 GMT) Full text and rfc822 format available.

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

From: inet0 <at> qq.com
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Thu, 11 Sep 2025 23:29:18 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> What this means is that using :variable leaves the mode variable, in
> this case bidi-display-reordering-mode, undefined.  Therefore, I think
> you must define some non-trivial BODY for your minor mode, because the
> default body will try to reference bidi-display-reordering-mode, and
> will fail, as this backtrace shows:

Did you mean to add back the variable `bidi-display-reordering-mode'
like this? It does eliminate the bug for now:

(define-minor-mode bidi-display-reordering-mode
  nil
  :variable bidi-display-reordering
  (setq-local bidi-display-reordering-mode bidi-display-reordering))

Actually my intention is to "mode-ify" those plain buffer-local
variables such that they can be easily toggled on and off (either on a
per-buffer basis or globally). I had tried utilizing `define-minor-mode'
and `define-globalized-minor-mode' without appealing to `:variable', but
as my code got complicated I doubted whether I was on the right track.

(defvar-local binding-bidi-display-reordering nil)

(define-minor-mode bidi-display-reordering-mode
  nil
  :ignored ignored
  (if (not binding-bidi-display-reordering)
    (dlet ((binding-bidi-display-reordering t))
      (setq bidi-display-reordering bidi-display-reordering-mode))))

(add-variable-watcher 'bidi-display-reordering
  (lambda (sym val op buf)
    (if (not (null buf))
      (with-current-buffer buf
        (if (not binding-bidi-display-reordering)
          (dlet ((binding-bidi-display-reordering t))
            (bidi-display-reordering-mode (if val 1 0))))))))

(define-globalized-minor-mode global-bidi-display-reordering-mode
  bidi-display-reordering-mode
  (lambda () (bidi-display-reordering-mode 1)))

(setq-default bidi-display-reordering nil)

(global-bidi-display-reordering-mode 1)

(keymap-global-set "C-c b" 'global-bidi-display-reordering-mode)

Or should I stop playing with modes and just `set-all' everything?

(defun set-all (variable value)
  (set-default variable value)
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (if (local-variable-p variable)
        (set variable value)))))

Any thoughts are appreciated!





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Sat, 13 Sep 2025 09:58:01 GMT) Full text and rfc822 format available.

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

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: Re: 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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Sat, 13 Sep 2025 16:16:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: inet0 <at> qq.com, 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Sat, 13 Sep 2025 12:14:53 -0400
> 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

No, like

    (when ,MODE-variable (,mode -1))


- Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Sat, 13 Sep 2025 16:20:02 GMT) Full text and rfc822 format available.

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

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: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Sat, 13 Sep 2025 19:18:44 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: inet0 <at> qq.com,  79412 <at> debbugs.gnu.org
> Date: Sat, 13 Sep 2025 12:14:53 -0400
> 
> > 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
> 
> No, like
> 
>     (when ,MODE-variable (,mode -1))

And what about 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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Sat, 13 Sep 2025 17:46:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: inet0 <at> qq.com, 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Sat, 13 Sep 2025 13:45:26 -0400
>> No, like
>> 
>>     (when ,MODE-variable (,mode -1))
>
> And what about 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)

It needs the same change, yes: `mode` should be used only as the name of
a function, not as the name of a variable.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79412; Package emacs. (Sat, 13 Sep 2025 17:52:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: inet0 <at> qq.com, 79412 <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Sat, 13 Sep 2025 13:50:25 -0400
>> > 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
>> 
>> No, like
>> 
>>     (when ,MODE-variable (,mode -1))
>
> And what about 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)

Hmm... actually this is the same as the one further above.
AFAICT there's only one such piece of code in `easy-mmode.el`.


        Stefan





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 13 Sep 2025 19:25:01 GMT) Full text and rfc822 format available.

Notification sent to inet0 <at> qq.com:
bug acknowledged by developer. (Sat, 13 Sep 2025 19:25:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: inet0 <at> qq.com, 79412-done <at> debbugs.gnu.org
Subject: Re: bug#79412: 30.2; `define-globalized-minor-mode' does not
 respect `:variable'
Date: Sat, 13 Sep 2025 22:24:25 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: inet0 <at> qq.com,  79412 <at> debbugs.gnu.org
> Date: Sat, 13 Sep 2025 13:50:25 -0400
> 
> >> > 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
> >> 
> >> No, like
> >> 
> >>     (when ,MODE-variable (,mode -1))
> >
> > And what about 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)
> 
> Hmm... actually this is the same as the one further above.
> AFAICT there's only one such piece of code in `easy-mmode.el`.

Thanks, I hope I've fixed this now.




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.