aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2020-02-06 00:38:53 +0200
committerJuri Linkov2020-02-06 00:38:53 +0200
commit09eed01afb4968a93247fb8eb7b5301a5bfb6342 (patch)
treeadc6d7dfbb588f8516b91ccee07584cf9a62d578
parent4a0a1145054db9ba71c48ae5c3d766a06e144887 (diff)
downloademacs-09eed01afb4968a93247fb8eb7b5301a5bfb6342.tar.gz
emacs-09eed01afb4968a93247fb8eb7b5301a5bfb6342.zip
Wrap some set-auto-mode calls with delay-mode-hooks (bug#39190)
* lisp/gnus/mm-view.el (mm-display-inline-fontify): * lisp/vc/diff-mode.el (diff-syntax-fontify-props): * lisp/vc/vc.el (vc-find-revision-no-save): Add delay-mode-hooks around set-auto-mode calls to not run hooks that might assume buffer-file-name really associates buffer with a file.
-rw-r--r--lisp/gnus/mm-view.el4
-rw-r--r--lisp/vc/diff-mode.el4
-rw-r--r--lisp/vc/vc.el4
3 files changed, 9 insertions, 3 deletions
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index a6be04e313d..828ac633dc5 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -497,7 +497,9 @@ If MODE is not set, try to find mode automatically."
497 (let ((auto-mode-alist 497 (let ((auto-mode-alist
498 (delq (rassq 'doc-view-mode-maybe auto-mode-alist) 498 (delq (rassq 'doc-view-mode-maybe auto-mode-alist)
499 (copy-sequence auto-mode-alist)))) 499 (copy-sequence auto-mode-alist))))
500 (set-auto-mode) 500 ;; Don't run hooks that might assume buffer-file-name
501 ;; really associates buffer with a file (bug#39190).
502 (delay-mode-hooks (set-auto-mode))
501 (setq mode major-mode))) 503 (setq mode major-mode)))
502 ;; Do not fontify if the guess mode is fundamental. 504 ;; Do not fontify if the guess mode is fundamental.
503 (unless (eq major-mode 'fundamental-mode) 505 (unless (eq major-mode 'fundamental-mode)
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 2dbab802086..d61c363c821 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2719,7 +2719,9 @@ hunk text is not found in the source file."
2719 (cl-assert (null buffer-file-name)) 2719 (cl-assert (null buffer-file-name))
2720 (let ((enable-local-variables :safe) ;; to find `mode:' 2720 (let ((enable-local-variables :safe) ;; to find `mode:'
2721 (buffer-file-name file)) 2721 (buffer-file-name file))
2722 (set-auto-mode) 2722 ;; Don't run hooks that might assume buffer-file-name
2723 ;; really associates buffer with a file (bug#39190).
2724 (delay-mode-hooks (set-auto-mode))
2723 ;; FIXME: Is this really worth the trouble? 2725 ;; FIXME: Is this really worth the trouble?
2724 (when (and (fboundp 'generic-mode-find-file-hook) 2726 (when (and (fboundp 'generic-mode-find-file-hook)
2725 (memq #'generic-mode-find-file-hook 2727 (memq #'generic-mode-find-file-hook
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index f64b6c06310..ec252b74d47 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2098,7 +2098,9 @@ Unlike `vc-find-revision-save', doesn't save the buffer to the file."
2098 ;; For non-interactive, skip any questions 2098 ;; For non-interactive, skip any questions
2099 (let ((enable-local-variables :safe) ;; to find `mode:' 2099 (let ((enable-local-variables :safe) ;; to find `mode:'
2100 (buffer-file-name file)) 2100 (buffer-file-name file))
2101 (ignore-errors (set-auto-mode))) 2101 ;; Don't run hooks that might assume buffer-file-name
2102 ;; really associates buffer with a file (bug#39190).
2103 (ignore-errors (delay-mode-hooks (set-auto-mode))))
2102 (normal-mode)) 2104 (normal-mode))
2103 (set-buffer-modified-p nil) 2105 (set-buffer-modified-p nil)
2104 (setq buffer-read-only t)) 2106 (setq buffer-read-only t))