]> git.eshelyaron.com Git - emacs.git/commitdiff
(define-globalized-minor-mode): Fix bug#58888
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 13 Apr 2024 14:10:19 +0000 (10:10 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sun, 14 Apr 2024 17:11:14 +0000 (19:11 +0200)
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode) <MODE-cmhh>:
Try and detect well-behaved modes so they're not affected by
those which require the cmhh hack.

(cherry picked from commit 3f7e26e2bed4ee7adab3a5d2bfa289517499e4c8)

lisp/emacs-lisp/easy-mmode.el

index 095bd5faa03bf7e2afdb003ca0cfdb608161baf1..b09466d79fc3ec3e1e188c9512a8f2dea42442ca 100644 (file)
@@ -661,8 +661,12 @@ list."
 
        ;; The function that catches kill-all-local-variables.
        (defun ,MODE-cmhh ()
-        (add-to-list ',MODE-buffers (current-buffer))
-        (add-hook 'post-command-hook #',MODE-check-buffers))
+         ;; If `delay-mode-hooks' is set, it indicates that the current
+         ;; buffer's mode will run `run-mode-hooks' afterwards anyway,
+         ;; so we don't need to keep this buffer in MODE-buffers.
+        (unless delay-mode-hooks
+          (add-to-list ',MODE-buffers (current-buffer))
+          (add-hook 'post-command-hook #',MODE-check-buffers)))
        (put ',MODE-cmhh 'definition-name ',global-mode))))
 
 (defun easy-mmode--globalized-predicate-p (predicate)