summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-04-09 12:04:03 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-04-09 12:04:03 -0400
commit1055eee692b2cdcee5ba7ee4ad8d92ead8fc30e5 (patch)
tree279a1d60b8cbbc03880f567a45825723a14a010e
parente1a457e63530cd566a1bc2957b70221bb6f76984 (diff)
downloademacs-1055eee692b2cdcee5ba7ee4ad8d92ead8fc30e5.tar.gz
* lisp/gnus/mm-view.el (mm-display-inline-fontify): Simplify.
Remove hacks that were needed before font-lock-ensure. Don't use switch-to-buffer. Don't assume point-min == 1.
-rw-r--r--lisp/gnus/mm-view.el31
1 files changed, 17 insertions, 14 deletions
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 8ce094349f2..1e1d264b994 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -476,29 +476,32 @@ If MODE is not set, try to find mode automatically."
(mm-decode-string text charset))
(t
text)))
- (require 'font-lock)
- ;; I find font-lock a bit too verbose.
- (let ((font-lock-verbose nil)
- (font-lock-support-mode nil)
+ (let ((font-lock-verbose nil) ; font-lock is a bit too verbose.
(enable-local-variables nil))
- ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
- ;; Note: XEmacs people use `font-lock-mode-hook' to run those modes.
+ ;; We used to set font-lock-mode-hook to nil to avoid enabling
+ ;; support modes, but now that we use font-lock-ensure, support modes
+ ;; aren't a problem any more. So we could probably get rid of this
+ ;; setting now, but it seems harmless and potentially still useful.
(set (make-local-variable 'font-lock-mode-hook) nil)
(setq buffer-file-name (mm-handle-filename handle))
(with-demoted-errors
- (if mode
- (save-window-excursion
- (switch-to-buffer (current-buffer))
- (funcall mode))
+ (if mode
+ (save-window-excursion
+ ;; According to Katsumi Yamaoka <yamaoka@jpl.org>, org-mode
+ ;; requires the buffer to be temporarily displayed here, but
+ ;; I could not reproduce this problem. Furthermore, if
+ ;; there's such a problem, we should fix org-mode rather than
+ ;; use switch-to-buffer which can have undesirable
+ ;; side-effects!
+ ;;(switch-to-buffer (current-buffer))
+ (funcall mode))
(let ((auto-mode-alist
(delq (rassq 'doc-view-mode-maybe auto-mode-alist)
(copy-sequence auto-mode-alist))))
(set-auto-mode)
(setq mode major-mode)))
- ;; The mode function might have already turned on font-lock.
;; Do not fontify if the guess mode is fundamental.
- (unless (or font-lock-mode
- (eq major-mode 'fundamental-mode))
+ (unless (eq major-mode 'fundamental-mode)
(font-lock-ensure))))
(setq text (buffer-string))
(when (eq mode 'diff-mode)
@@ -508,7 +511,7 @@ If MODE is not set, try to find mode automatically."
;; Set buffer unmodified to avoid confirmation when killing the
;; buffer.
(set-buffer-modified-p nil))
- (let ((b (1- (point))))
+ (let ((b (- (point) (save-restriction (widen) (point-min)))))
(mm-insert-inline handle text)
(dolist (ov ovs)
(move-overlay (nth 0 ov) (+ (nth 1 ov) b)