From 5488d4d3b1c2f7a308a847cdd2d1edb574200697 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 20 May 2022 03:24:37 +0100 Subject: working better in term mode: html emails with .mailcap --- lib/net/jao-notmuch.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index 53137be..bd48e8f 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -174,6 +174,20 @@ (jao-notmuch--toggle-mime) (jao-notmuch-goto-tree-buffer t))) +(defun jao-notmuch--view-html () + "Open the text/html part of the current message using `notmuch-show-view-part'." + (interactive) + (save-excursion + (goto-char + (prop-match-beginning + (text-property-search-forward + :notmuch-part + "text/html" + (lambda (value notmuch-part) + (equal (plist-get notmuch-part :content-type) + value))))) + (notmuch-show-view-part))) + (defvar-local jao-notmuch--showing-images nil) (defun jao-notmuch--shr-toggle-images () @@ -193,10 +207,12 @@ (defun jao-notmuch-toggle-images () (interactive) - (if (eq mm-text-html-renderer 'w3m) - (when (fboundp 'jao-notmuch--w3m-toggle-images) - (jao-notmuch--w3m-toggle-images)) - (jao-notmuch--shr-toggle-images))) + (cond ((eq mm-text-html-renderer 'w3m) + (when (fboundp 'jao-notmuch--w3m-toggle-images) + (jao-notmuch--w3m-toggle-images))) + (window-system (jao-notmuch--shr-toggle-images)) + (t (with-current-buffer notmuch-tree-message-buffer + (jao-notmuch--view-html))))) ;;;; Keeping track of unread messages in current tree view -- cgit v1.2.3