From 1f98060ef38cc97744fd6a0c0018f0b99c3f98e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Deparis?= Date: Sat, 14 Aug 2021 17:41:19 +0200 Subject: [PATCH] mu4e: Add back the `h' keybinding to toggle HTML view in a gnus article Fixes: https://github.com/djcb/mu/issues/2013 --- mu4e/mu4e-view-gnus.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mu4e/mu4e-view-gnus.el b/mu4e/mu4e-view-gnus.el index 3901074d..21e48d46 100644 --- a/mu4e/mu4e-view-gnus.el +++ b/mu4e/mu4e-view-gnus.el @@ -328,6 +328,7 @@ some Gnus-functionality that does not work in mu4e." (define-key map "M" #'mu4e-view-massage) (define-key map "w" 'visual-line-mode) + (define-key map "h" #'mu4e-view-toggle-html) (define-key map (kbd "M-q") 'article-fill-long-lines) ;; next 3 only warn user when attempt in the message view @@ -629,6 +630,19 @@ I.e., '3 A o' opens the third MIME-part." (mu4e~view-mime-part-to-temp-file handle)))))) (t (mu4e-error "Invalid action %S" action)))))))) +(defun mu4e-view-toggle-html () + "Toggle html-display of the first HTML body found, if any." + (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)))) + ;;; (provide 'mu4e-view-gnus) ;;; mu4e-view.el ends here