From 0465b273d37dd73f6f01dae9162cc1e13359e7f4 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 28 Feb 2020 00:38:55 +0200 Subject: [PATCH] mu4e: avoid mu-side crypto in gnus-mode No need to decrypt/verify when we don't use the results. --- mu4e/mu4e-headers.el | 19 +++++++++++-------- mu4e/mu4e-view.el | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 02a0bd3e..98fc3fea 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -1661,18 +1661,19 @@ _not_ refresh the last search with the new setting for threading." (defun mu4e~decrypt-p (msg) "Should we decrypt this message?" - (and (member 'encrypted (mu4e-message-field msg :flags)) - (if (eq mu4e-decryption-policy 'ask) - (yes-or-no-p (mu4e-format "Decrypt message?")) - mu4e-decryption-policy))) + (unless mu4e-view-use-gnus ;; we don't decrypt in the gnus-view case + (and (member 'encrypted (mu4e-message-field msg :flags)) + (if (eq mu4e-decryption-policy 'ask) + (yes-or-no-p (mu4e-format "Decrypt message?")) + mu4e-decryption-policy)))) (defun mu4e-headers-view-message () - "View message at point. -If there's an existing window for the view, re-use that one. If + "View message at point . +If there's an existing window for the view, re-use that one . If not, create a new one, depending on the value of `mu4e-split-view': if it's a symbol `horizontal' or `vertical', split the window accordingly; if it is nil, replace the current -window. " +window . " (interactive) (unless (eq major-mode 'mu4e-headers-mode) (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) @@ -1680,11 +1681,13 @@ window. " (docid (or (mu4e-message-field msg :docid) (mu4e-warn "No message at point"))) (decrypt (mu4e~decrypt-p msg)) + (verify (not mu4e-view-use-gnus)) (viewwin (mu4e~headers-redraw-get-view-window))) (unless (window-live-p viewwin) (mu4e-error "Cannot get a message view")) (select-window viewwin) + ;; show some 'loading...' buffer (unless (buffer-live-p mu4e~headers-loading-buf) (setq mu4e~headers-loading-buf (get-buffer-create " *mu4e-loading*")) (with-current-buffer mu4e~headers-loading-buf @@ -1700,7 +1703,7 @@ window. " ;; (if mu4e-view-use-gnus ;; (mu4e-view msg) ;; (mu4e~proc-view docid mu4e-view-show-images decrypt)) - (mu4e~proc-view docid mu4e-view-show-images decrypt))) + (mu4e~proc-view docid mu4e-view-show-images decrypt verify))) (defun mu4e-headers-rerun-search () "Rerun the search for the last search expression." diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 4fa8cf0f..964c7ec5 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -996,7 +996,8 @@ changes, it triggers a refresh." ;; this message will be marked as read. We don't want an update thougn, ;; we want a full message, so images etc. work correctly. (mu4e~proc-move msgid nil "+S-u-N" 'noview) - (mu4e~proc-view docid mu4e-view-show-images (mu4e~decrypt-p msg)) + (mu4e~proc-view docid mu4e-view-show-images + (mu4e~decrypt-p msg) (not mu4e-view-use-gnus)) t)))) (defun mu4e~view-browse-url-func (url)