From 698a584e92d6ab3a1970ed9c92b1564cc75d9e58 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 21 Oct 2025 15:35:36 -0400 Subject: [PATCH] (define-globalized-minor-mode): Remove `MODE-mode-name` hack (bug#79624) Stop trying to detect when a globalized mode enabled its minor mode "too early". This reverts the core of commit 876daebc8594 since the problem it tried to circumvent has been made almost impossible by commit 17e26cf57e18. * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Remove the `MODE-mode-name` variable, don't remember in which major mode we enabled the minor mode, and don't disable the minor mode before (re)enabling it. --- lisp/emacs-lisp/easy-mmode.el | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index e87b9269188..c5c95a1be20 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -501,7 +501,6 @@ on if the hook has explicitly disabled it. (MODE-set-explicitly (intern (concat mode-name "--set-explicitly"))) (MODE-suppress-set-explicitly (intern (concat mode-name "--suppress-set-explicitly"))) - (MODE-major-mode (intern (concat global-mode-name "--major-mode"))) (MODE-predicate (intern (concat (replace-regexp-in-string "-mode\\'" "" global-mode-name) "-modes"))) @@ -528,7 +527,6 @@ on if the hook has explicitly disabled it. (progn (put ',global-mode 'globalized-minor-mode t) :autoload-end - (defvar-local ,MODE-major-mode nil) ,@(when predicate `((defvar ,MODE-predicate)))) ;; The actual global minor-mode (define-minor-mode ,global-mode @@ -620,8 +618,7 @@ list." ;; The function that calls TURN-ON in the current buffer. (defun ,MODE-enable-in-buffer () - (unless (or ,MODE-set-explicitly - (eq ,MODE-major-mode major-mode)) + (unless ,MODE-set-explicitly (let (;; We are not part of the major mode hook so we don't ;; want to set MODE-set-explicitly to t. ;; In particular this is necessary when there are @@ -629,12 +626,7 @@ list." ;; If one of them declines to turn the minor mode on, ;; that should not mean the others can't. (,MODE-suppress-set-explicitly t)) - (if (bound-and-true-p ,MODE-variable) - (progn - (,mode -1) - (funcall ,turn-on-function)) - (funcall ,turn-on-function)))) - (setq ,MODE-major-mode major-mode)) + (funcall ,turn-on-function)))) (put ',MODE-enable-in-buffer 'definition-name ',global-mode)))) (defun easy-mmode--globalized-predicate-p (predicate)