mu4e: define the view-mode when needed

Define the view-mode (gnus or internal) just before it's needed. This
ensures that (when in gnus mode) it's really a gnus-article-mode
derivative, so more of the gnus specifics work.
This commit is contained in:
djcb 2018-06-08 10:01:55 +03:00
parent ee6e91da9b
commit 088064d5e1
1 changed files with 15 additions and 12 deletions

View File

@ -314,6 +314,7 @@ marking if it still had that.
Depending on the value of `mu4e-view-use-gnus', either use mu4e's Depending on the value of `mu4e-view-use-gnus', either use mu4e's
internal display mode, or a display mode based on Gnu's internal display mode, or a display mode based on Gnu's
article-mode." article-mode."
(mu4e~view-define-mode)
(if mu4e-view-use-gnus (if mu4e-view-use-gnus
(mu4e~view-gnus msg) (mu4e~view-gnus msg)
(mu4e~view-internal msg))) (mu4e~view-internal msg)))
@ -870,18 +871,20 @@ FUNC should be a function taking two arguments:
(when (boundp 'autopair-dont-activate) (when (boundp 'autopair-dont-activate)
(setq autopair-dont-activate t))) (setq autopair-dont-activate t)))
(if mu4e-view-use-gnus (defun mu4e~view-define-mode ()
(define-derived-mode mu4e-view-mode gnus-article-mode "mu4e:view/g" "Define the major-mode for the mu4e-view."
;; remove some gnus stuff that does not apply (if mu4e-view-use-gnus
(define-key mu4e-view-mode-map [menu-bar Treatment] nil) (define-derived-mode mu4e-view-mode gnus-article-mode "mu4e:view"
(define-key mu4e-view-mode-map [menu-bar Article] nil) ;; remove some gnus stuff that does not apply
(define-key mu4e-view-mode-map [menu-bar post] nil) (define-key mu4e-view-mode-map [menu-bar Treatment] nil)
"Major mode for viewing an e-mail message in mu4e, based on Gnus." (define-key mu4e-view-mode-map [menu-bar Article] nil)
(mu4e~view-mode-body)) (define-key mu4e-view-mode-map [menu-bar post] nil)
(define-derived-mode mu4e-view-mode special-mode "mu4e:view" "Major mode for viewing an e-mail message in mu4e, based on
"Major mode for viewing an e-mail message in mu4e, using the Gnus' article-mode."
mu4e-specific view." (mu4e~view-mode-body))
(mu4e~view-mode-body))) (define-derived-mode mu4e-view-mode special-mode "mu4e:view"
"Major mode for viewing an e-mail message in mu4e."
(mu4e~view-mode-body))))
(defun mu4e~view-mark-as-read-maybe (msg) (defun mu4e~view-mark-as-read-maybe (msg)
"Clear the message MSG New/Unread status and set it to Seen. "Clear the message MSG New/Unread status and set it to Seen.