Add support for rendering and quoting HTML parts. Adds a customize option notmuch-mua-quote-html-parts, which when non-nil causes HTML parts to be included in replies using notmuch reply --format=html. --- emacs/notmuch-mua.el | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 8824b08..e7c1315 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -46,6 +46,14 @@ list." :group 'notmuch :type '(repeat string)) +(defcustom notmuch-mua-quote-html-parts nil + "Quote HTML parts when replying to a message. + +If non-nil, notmuch will attempt to render HTML parts using w3m and insert them +into reply buffers." + :group 'notmuch + :type 'boolean) + ;; (defun notmuch-mua-user-agent-full () @@ -69,10 +77,13 @@ list." (push header message-hidden-headers))) notmuch-mua-hidden-headers)) +(defun w3m-region (start end)) ;; From `w3m.el'. (defun notmuch-mua-reply (query-string &optional sender) (let (headers body (args '("reply"))) + (if notmuch-mua-quote-html-parts + (setq args (append args '("--format=html")))) (if notmuch-show-process-crypto (setq args (append args '("--decrypt")))) (setq args (append args (list query-string))) @@ -89,6 +100,18 @@ list." (goto-char (point-min)) (setq headers (mail-header-extract))))) (forward-line 1) + (if notmuch-mua-quote-html-parts + (save-excursion + (if (re-search-forward "<html" nil t) + (save-restriction + (goto-char (point-at-bol)) + (narrow-to-region (point) (point-max)) + (w3m-region (point) (point-max)) + (goto-char (point-min)) + (fill-region (point) (point-max)) + (goto-char (point-min)) + (while (re-search-forward "^" nil t) + (replace-match "> " nil nil)))))) (setq body (buffer-substring (point) (point-max)))) ;; If sender is non-nil, set the From: header to its value. (when sender -- 1.7.5.4