mu4e: Replace mu4e-view-use-gnus with mu4e-view-use-old

Make mu4e-view-use-gnus obsolete (it's the default now), and add a
variable mu4e-view-use-old (which must be set before starting mu4e).

Update documentation / mentions.

Load the correct view when starting mu4e, so people can customize
e.g. the keymap.

Add some sanity checking.
This commit is contained in:
Dirk-Jan C. Binnema 2021-03-16 19:49:27 +02:00
parent 342df5a3ed
commit 2437dc27c9
8 changed files with 52 additions and 60 deletions

View File

@ -39,16 +39,21 @@
*** mu4e *** mu4e
- Use the gnus-based message viewer as the default; the new viewer has quite - Use the gnus-based message viewer as the default; the new viewer has quite
a few features compared to the old, mu4e-specific one, such as faster a few extra features compared to the old, mu4e-specific one, such as
crypto, support for S/MIME, syntax-highlighting, calendar invitations and faster crypto, support for S/MIME, syntax-highlighting, calendar
more. invitations and more.
It does not do everything the old viewer does though (e.g., attachment It does not do everything the old viewer does though (e.g., attachment
actions), so if you depend on those, you can use: actions), so if you depend on those:
#+begin_example #+begin_example
(setq mu4e-view-use-gnus nil) ;; set *before* loading mu4e; and restart emacs if you want to change it
;; users of use-packag~ should can use the :init section for this.
(setq mu4e-view-use-old t)
#+end_example #+end_example
(The older variable ~mu4e-view-use-gnus~ with the opposite meaning is
obsolete now, and no longer in use).
- Include maildir-shortcuts in the main-view with overall/unread counts, - Include maildir-shortcuts in the main-view with overall/unread counts,
similar to bookmarks, and with the same ~:hide~ and ~:hide-unread~ properties. similar to bookmarks, and with the same ~:hide~ and ~:hide-unread~ properties.
Note that for the latter, you need to update your maildir-shortcuts to the Note that for the latter, you need to update your maildir-shortcuts to the

View File

@ -1,6 +1,6 @@
;;; mu4e-contrib.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*- ;;; mu4e-contrib.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
;; Copyright (C) 2013-2020 Dirk-Jan C. Binnema ;; Copyright (C) 2013-2021 Dirk-Jan C. Binnema
;; This file is not part of GNU Emacs. ;; This file is not part of GNU Emacs.

View File

@ -1749,7 +1749,7 @@ _not_ refresh the last search with the new setting for threading."
(defun mu4e~decrypt-p (msg) (defun mu4e~decrypt-p (msg)
"Should we decrypt this message?" "Should we decrypt this message?"
(unless mu4e-view-use-gnus ;; we don't decrypt in the gnus-view case (when mu4e-view-use-old ;; we don't decrypt in the gnus-view case
(and (member 'encrypted (mu4e-message-field msg :flags)) (and (member 'encrypted (mu4e-message-field msg :flags))
(if (eq mu4e-decryption-policy 'ask) (if (eq mu4e-decryption-policy 'ask)
(yes-or-no-p (mu4e-format "Decrypt message?")) (yes-or-no-p (mu4e-format "Decrypt message?"))
@ -1773,7 +1773,7 @@ window . "
(funcall mu4e-view-auto-mark-as-read msg) (funcall mu4e-view-auto-mark-as-read msg)
mu4e-view-auto-mark-as-read)) mu4e-view-auto-mark-as-read))
(decrypt (mu4e~decrypt-p msg)) (decrypt (mu4e~decrypt-p msg))
(verify (not mu4e-view-use-gnus)) (verify mu4e-view-use-old)
(viewwin (mu4e~headers-redraw-get-view-window))) (viewwin (mu4e~headers-redraw-get-view-window)))
(unless (window-live-p viewwin) (unless (window-live-p viewwin)
(mu4e-error "Cannot get a message view")) (mu4e-error "Cannot get a message view"))

View File

@ -58,6 +58,9 @@
(require 'mu4e-view) (require 'mu4e-view)
(require 'mu4e-vars) (require 'mu4e-vars)
(when mu4e-view-use-old
(mu4e-error "iCalender support is not available with the old viewer"))
;;;###autoload ;;;###autoload
(defun mu4e-icalendar-setup () (defun mu4e-icalendar-setup ()
"Perform the necessary initialization to use mu4e-icalendar." "Perform the necessary initialization to use mu4e-icalendar."

View File

@ -856,9 +856,9 @@ When successful, call FUNC (if non-nil) afterwards."
;; kill all mu4e buffers ;; kill all mu4e buffers
(mapc (mapc
(lambda (buf) (lambda (buf)
;; When using mu4e-view-use-gnus, the view buffer has the kill-buffer-hook ;; When using the Gnus-based viewer, the view buffer has the
;; function mu4e~view-kill-buffer-hook-fn which kills the mm-* buffers ;; kill-buffer-hook function mu4e~view-kill-buffer-hook-fn which kills the
;; created by Gnus' article mode. Those have been returned by ;; mm-* buffers created by Gnus' article mode. Those have been returned by
;; `buffer-list' but might already be deleted in case the view buffer has ;; `buffer-list' but might already be deleted in case the view buffer has
;; been killed first. So we need a `buffer-live-p' check here. ;; been killed first. So we need a `buffer-live-p' check here.
(when (buffer-live-p buf) (when (buffer-live-p buf)

View File

@ -69,12 +69,13 @@ Setting this to t increases the amount of information in the log."
"Settings for the message view." "Settings for the message view."
:group 'mu4e) :group 'mu4e)
(defcustom mu4e-view-use-gnus t (defcustom mu4e-view-use-old nil
"If non-nil, use the new Gnus-based viewer. "If non-nil, use the old viewer.
Otherwise, use the old viewer." Otherwise, use the new, Gnus-based viewer."
:type 'boolean :type 'boolean
:group 'mu4e-view) :group 'mu4e-view)
(make-obsolete-variable 'mu4e-view-use-gnus 'mu4e-view-use-old "1.5.10")
(defcustom mu4e-speedbar-support nil (defcustom mu4e-speedbar-support nil
"Support having a speedbar to navigate folders/bookmarks." "Support having a speedbar to navigate folders/bookmarks."
@ -421,7 +422,7 @@ The setting is a symbol:
* `ask': ask before decrypting anything * `ask': ask before decrypting anything
* nil: don't try to decrypt anything. * nil: don't try to decrypt anything.
Note that this is not used when `mu4e-view-use-gnus' is enabled." Note that this is not used unless `mu4e-view-use-old' is enabled."
:type '(choice (const :tag "Try to decrypt automatically" t) :type '(choice (const :tag "Try to decrypt automatically" t)
(const :tag "Ask before decrypting anything" ask) (const :tag "Ask before decrypting anything" ask)
(const :tag "Don't try to decrypt anything" nil)) (const :tag "Don't try to decrypt anything" nil))
@ -1019,10 +1020,9 @@ property, which should point to a function that takes a message
plist as argument, and returns a string. See the default value of plist as argument, and returns a string. See the default value of
`mu4e-header-info-custom for an example. `mu4e-header-info-custom for an example.
Note that when using the gnus-based view (see Note that when using the gnus-based view, you only have access to
`mu4e-view-use-gnus'), you only have access to a limited set of a limited set of message fields: only the ones used in the
message fields: only the ones used in the header-view, not header-view, not including, for instance, the message body.")
including, for instance, the message body.")
;;; Run-time variables / constants ;;; Run-time variables / constants

View File

@ -33,6 +33,7 @@
(declare-function mu4e-error "mu4e-utils") (declare-function mu4e-error "mu4e-utils")
(require 'mu4e-view-common) (require 'mu4e-view-common)
(require (if mu4e-view-use-old 'mu4e-view-old 'mu4e-view-gnus))
(defun mu4e-view (msg) (defun mu4e-view (msg)
"Display the message MSG in a new buffer, and keep in sync with HDRSBUF. "Display the message MSG in a new buffer, and keep in sync with HDRSBUF.
@ -42,23 +43,21 @@ the the message view affects HDRSBUF, as does marking etc.
As a side-effect, a message that is being viewed loses its 'unread' As a side-effect, a message that is being viewed loses its 'unread'
marking if it still had that. 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-old', either use mu4e's
internal display mode, or a display mode based on Gnus' internal display mode, or a (by default) display mode based on
article-mode." Gnus' article-mode."
;; sanity checks.
(if (and mu4e-view-use-old (featurep 'mu4e-view-gnus))
(error "Cannot use old view when gnus-view is loaded; restart emacs")
(if (and (not mu4e-view-use-old) (featurep 'mu4e-view-old))
(error "Cannot use gnus-based view with old view loaded; restart emacs")))
(mu4e~headers-update-handler msg nil nil);; update headers, if necessary. (mu4e~headers-update-handler msg nil nil);; update headers, if necessary.
;; sanity check; only one can be active. (if mu4e-view-use-old
(if mu4e-view-use-gnus (mu4e~view-old msg)
(progn (mu4e~view-gnus msg)))
(when (featurep 'mu4e-view-old)
(mu4e-error "Cannot load gnus-based view with old one loaded. Restart emacs"))
(require 'mu4e-view-gnus)
(mu4e~view-gnus msg))
(progn
(when (featurep 'mu4e-view-gnus)
(mu4e-error "Cannot load old view with gnus-based view loaded. Restart emacs"))
(require 'mu4e-view-old)
(mu4e~view-old msg))))
(defun mu4e-view-message-with-message-id (msgid) (defun mu4e-view-message-with-message-id (msgid)
"View message with message-id MSGID. This (re)creates a "View message with message-id MSGID. This (re)creates a

View File

@ -1329,7 +1329,6 @@ q leave the message view
For the marking commands, please refer to @ref{Marking messages}. For the marking commands, please refer to @ref{Marking messages}.
@node MSGV Custom headers @node MSGV Custom headers
@section Custom headers @section Custom headers
@ -1361,11 +1360,18 @@ Since version 1.6 @t{mu4e} defaults to the new, Gnus-based, message view.
However, the older view is still available, and this chapter is about However, the older view is still available, and this chapter is about
that one. While we recommend using the default one, you can still use that one. While we recommend using the default one, you can still use
the old one by configuring it: the old one by configuring it @emph{before} @t{require}'ing @t{mu4e}:
@lisp @lisp
(setq mu4e-view-use-gnus nil) (setq mu4e-view-use-old t)
@end lisp @end lisp
Users of
@t{use-package}@footnote{@url{https://jwiegley.github.io/use-package/}}
can use the @t{:init} section for this.
If you want to change this, you need to fully restart @t{mu4e} (in
practice, this means you need to restart @t{emacs}.
After selecting a message in the @ref{Headers view}, it appears in a message After selecting a message in the @ref{Headers view}, it appears in a message
view window, which shows the message headers, followed by the message view window, which shows the message headers, followed by the message
body. Its major mode is @code{mu4e-view-mode}. body. Its major mode is @code{mu4e-view-mode}.
@ -3805,13 +3811,8 @@ Now, you can bind a convenient key to my-mu4e-bookmarks/body.
By default, mu4e presents iCalendar invitations as .vcs file By default, mu4e presents iCalendar invitations as .vcs file
attachments. Experimental support is available to parse these attachments. Experimental support is available to parse these
attachments in order to add the expected ``Accept'', ``Reject'', ``Add attachments in order to add the expected ``Accept'', ``Reject'', ``Add
to Calendar'' buttons. This requires using Gnus' article view, instead to Calendar'' buttons. This requires using Gnus' article view, which
of mu4e's internal viewer. We do this by setting the value of is the default since @t{mu4e} version 1.6.
mu4e-view-use-gnus:
@lisp
(setq mu4e-view-use-gnus t)
@end lisp
The minimal setup is: The minimal setup is:
@ -3838,22 +3839,6 @@ To enable optional functionality to capture iCalendar events to your org files:
NOTE: both the capture file and the headline(s) inside must already NOTE: both the capture file and the headline(s) inside must already
exist. exist.
These features require the Gnus article viewer. This is currently
experimental, and doesn't yet support all the features available with
mu4e's internal viewer. Consequently, you may want a way to toggle
between the two modes. You can do this with the following:
@lisp
(defun mu4e-toggle-gnus-view ()
(interactive)
(mu4e~view-quit-buffer)
(setq mu4e-view-use-gnus
(not mu4e-view-use-gnus))
(mu4e-headers-view-message))
(define-key mu4e-view-mode-map "i" 'mu4e-toggle-gnus-view)
@end lisp
@node Example configs @node Example configs
@appendix Example configs @appendix Example configs