summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-08-15 20:53:52 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-08-15 20:53:52 +0300
commit2c99cb33746b36765e7289333116c74d19742d57 (patch)
treea47566955d3ef1c0164ed2e4b811858db31e2d79
parent1f98060ef38cc97744fd6a0c0018f0b99c3f98e7 (diff)
mu4e: toggle-html: use if-let/seq-find
Slightly update the algo.
-rw-r--r--mu4e/mu4e-view-gnus.el23
1 files changed, 11 insertions, 12 deletions
diff --git a/mu4e/mu4e-view-gnus.el b/mu4e/mu4e-view-gnus.el
index 21e48d4..f279f0e 100644
--- a/mu4e/mu4e-view-gnus.el
+++ b/mu4e/mu4e-view-gnus.el
@@ -631,18 +631,17 @@ I.e., '3 A o' opens the third MIME-part."
(t (mu4e-error "Invalid action %S" action))))))))
(defun mu4e-view-toggle-html ()
- "Toggle html-display of the first HTML body found, if any."
+ "Toggle html-display of the first html-part found."
(interactive)
- (let ((html-part
- (catch :found
- ;; This function assume `gnus-article-mime-handle-alist' is sorted
- ;; by pertinence, i.e. the first HTML part found in it is the most
- ;; important one.
- (dolist (part-handle gnus-article-mime-handle-alist)
- (when (equal (mm-handle-media-type (cdr part-handle)) "text/html")
- (throw :found (car part-handle)))))))
- (when html-part (gnus-article-inline-part html-part))))
-
-;;;
+ ;; This function assumes `gnus-article-mime-handle-alist' is sorted by
+ ;; pertinence, i.e. the first HTML part found in it is the most important one.
+ (if-let ((html-part
+ (seq-find (lambda (handle)
+ (equal (mm-handle-media-type (cdr handle)) "text/html"))
+ gnus-article-mime-handle-alist)))
+ (gnus-article-inline-part (car html-part))
+ (mu4e-warn "No html part in this message")))
+
+
(provide 'mu4e-view-gnus)
;;; mu4e-view.el ends here