mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-05 11:49:37 +00:00
Avoid turning on the global-minor-mode recursively
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Clear the buffer-list inside MODE-enable-in-buffers to avoid enabling the mode recursively. (Bug#31793)
This commit is contained in:
parent
51bf4e4650
commit
35e0305dc2
1 changed files with 16 additions and 12 deletions
|
@ -457,7 +457,12 @@ See `%s' for more information on %s."
|
||||||
|
|
||||||
;; The function that calls TURN-ON in each buffer.
|
;; The function that calls TURN-ON in each buffer.
|
||||||
(defun ,MODE-enable-in-buffers ()
|
(defun ,MODE-enable-in-buffers ()
|
||||||
(dolist (buf ,MODE-buffers)
|
(let ((buffers ,MODE-buffers))
|
||||||
|
;; Clear MODE-buffers to avoid scanning the same list of
|
||||||
|
;; buffers in recursive calls to MODE-enable-in-buffers.
|
||||||
|
;; Otherwise it could lead to infinite recursion.
|
||||||
|
(setq ,MODE-buffers nil)
|
||||||
|
(dolist (buf buffers)
|
||||||
(when (buffer-live-p buf)
|
(when (buffer-live-p buf)
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(unless ,MODE-set-explicitly
|
(unless ,MODE-set-explicitly
|
||||||
|
@ -467,12 +472,11 @@ See `%s' for more information on %s."
|
||||||
(,mode -1)
|
(,mode -1)
|
||||||
(funcall #',turn-on))
|
(funcall #',turn-on))
|
||||||
(funcall #',turn-on))))
|
(funcall #',turn-on))))
|
||||||
(setq ,MODE-major-mode major-mode)))))
|
(setq ,MODE-major-mode major-mode))))))
|
||||||
(put ',MODE-enable-in-buffers 'definition-name ',global-mode)
|
(put ',MODE-enable-in-buffers 'definition-name ',global-mode)
|
||||||
|
|
||||||
(defun ,MODE-check-buffers ()
|
(defun ,MODE-check-buffers ()
|
||||||
(,MODE-enable-in-buffers)
|
(,MODE-enable-in-buffers)
|
||||||
(setq ,MODE-buffers nil)
|
|
||||||
(remove-hook 'post-command-hook ',MODE-check-buffers))
|
(remove-hook 'post-command-hook ',MODE-check-buffers))
|
||||||
(put ',MODE-check-buffers 'definition-name ',global-mode)
|
(put ',MODE-check-buffers 'definition-name ',global-mode)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue