mu4e: toggle-html: use if-let/seq-find

Slightly update the algo.
This commit is contained in:
Dirk-Jan C. Binnema
2021-08-15 20:53:52 +03:00
parent 1f98060ef3
commit 2c99cb3374

View File

@ -631,18 +631,17 @@ I.e., '3 A o' opens the third MIME-part."
(t (mu4e-error "Invalid action %S" action)))))))) (t (mu4e-error "Invalid action %S" action))))))))
(defun mu4e-view-toggle-html () (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) (interactive)
(let ((html-part ;; This function assumes `gnus-article-mime-handle-alist' is sorted by
(catch :found ;; pertinence, i.e. the first HTML part found in it is the most important one.
;; This function assume `gnus-article-mime-handle-alist' is sorted (if-let ((html-part
;; by pertinence, i.e. the first HTML part found in it is the most (seq-find (lambda (handle)
;; important one. (equal (mm-handle-media-type (cdr handle)) "text/html"))
(dolist (part-handle gnus-article-mime-handle-alist) gnus-article-mime-handle-alist)))
(when (equal (mm-handle-media-type (cdr part-handle)) "text/html") (gnus-article-inline-part (car html-part))
(throw :found (car part-handle))))))) (mu4e-warn "No html part in this message")))
(when html-part (gnus-article-inline-part html-part))))
;;;
(provide 'mu4e-view-gnus) (provide 'mu4e-view-gnus)
;;; mu4e-view.el ends here ;;; mu4e-view.el ends here