(let ((auto-mode-alist
(delq (rassq 'doc-view-mode-maybe auto-mode-alist)
(copy-sequence auto-mode-alist))))
- (set-auto-mode)
+ ;; Don't run hooks that might assume buffer-file-name
+ ;; really associates buffer with a file (bug#39190).
+ (delay-mode-hooks (set-auto-mode))
(setq mode major-mode)))
;; Do not fontify if the guess mode is fundamental.
(unless (eq major-mode 'fundamental-mode)
(cl-assert (null buffer-file-name))
(let ((enable-local-variables :safe) ;; to find `mode:'
(buffer-file-name file))
- (set-auto-mode)
+ ;; Don't run hooks that might assume buffer-file-name
+ ;; really associates buffer with a file (bug#39190).
+ (delay-mode-hooks (set-auto-mode))
;; FIXME: Is this really worth the trouble?
(when (and (fboundp 'generic-mode-find-file-hook)
(memq #'generic-mode-find-file-hook
;; For non-interactive, skip any questions
(let ((enable-local-variables :safe) ;; to find `mode:'
(buffer-file-name file))
- (ignore-errors (set-auto-mode)))
+ ;; Don't run hooks that might assume buffer-file-name
+ ;; really associates buffer with a file (bug#39190).
+ (ignore-errors (delay-mode-hooks (set-auto-mode))))
(normal-mode))
(set-buffer-modified-p nil)
(setq buffer-read-only t))