summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/easy-mmode.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-07-13 09:28:15 -0700
committerGlenn Morris <rgm@gnu.org>2018-07-13 09:28:15 -0700
commitcda7e1850f2f19a5025fd163ff2c6c6cba275acf (patch)
tree1fdb0014a632e936da813128ead6353051436cbd /lisp/emacs-lisp/easy-mmode.el
parent1013e0392b78ee0e2199fb51859dc9e939315f9b (diff)
parent17ebb6e5ae9cdd2586d1b4d6f2347ae09c6f653f (diff)
downloademacs-cda7e1850f2f19a5025fd163ff2c6c6cba275acf.tar.gz
Merge from origin/emacs-26
17ebb6e (origin/emacs-26) Use consistent function names in thread-tes... 1c86229 Fix format error in Faccept_process_output b38b91a Lessen stack consumption in recursive read1 3eb4603 Match w32 paths in grep sans --null hits (Bug#32051) 5cc7c4b Fix previous make-network-process change d6a1b69 Another documentation improvement in flyspell.el 9b49a8e Improve documentation of Flyspell 3744fda Provide feature 'threads ef9025f Save the server alias on reconnect (Bug#29657) db3874b Refer to "proper lists" instead of "true lists" 35e0305 Avoid turning on the global-minor-mode recursively 51bf4e4 Fix Bug#32085
Diffstat (limited to 'lisp/emacs-lisp/easy-mmode.el')
-rw-r--r--lisp/emacs-lisp/easy-mmode.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index b83b53a8e52..4d8a5020267 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -474,22 +474,26 @@ See `%s' for more information on %s."
;; The function that calls TURN-ON in each buffer.
(defun ,MODE-enable-in-buffers ()
- (dolist (buf ,MODE-buffers)
- (when (buffer-live-p buf)
- (with-current-buffer buf
- (unless ,MODE-set-explicitly
- (unless (eq ,MODE-major-mode major-mode)
- (if ,mode
- (progn
- (,mode -1)
- (funcall #',turn-on))
- (funcall #',turn-on))))
- (setq ,MODE-major-mode major-mode)))))
+ (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)
+ (with-current-buffer buf
+ (unless ,MODE-set-explicitly
+ (unless (eq ,MODE-major-mode major-mode)
+ (if ,mode
+ (progn
+ (,mode -1)
+ (funcall #',turn-on))
+ (funcall #',turn-on))))
+ (setq ,MODE-major-mode major-mode))))))
(put ',MODE-enable-in-buffers 'definition-name ',global-mode)
(defun ,MODE-check-buffers ()
(,MODE-enable-in-buffers)
- (setq ,MODE-buffers nil)
(remove-hook 'post-command-hook ',MODE-check-buffers))
(put ',MODE-check-buffers 'definition-name ',global-mode)