Reintroduce HTML inlining, with a much needed optimization

Now instead of requiring every single message be parsed, we now check
the Content-type in the parsed headers and only do HTML inlining if it's
text/html
This commit is contained in:
Alexander Botero-Lowry 2010-02-09 17:55:21 -08:00 committed by Carl Worth
parent e0a8dee8bc
commit b611cc2319

View file

@ -133,6 +133,8 @@ remaining lines into a button.")
(defvar notmuch-show-id-regexp "\\(id:[^ ]*\\)") (defvar notmuch-show-id-regexp "\\(id:[^ ]*\\)")
(defvar notmuch-show-depth-match-regexp " depth:\\([0-9]*\\).*match:\\([01]\\) ") (defvar notmuch-show-depth-match-regexp " depth:\\([0-9]*\\).*match:\\([01]\\) ")
(defvar notmuch-show-filename-regexp "filename:\\(.*\\)$") (defvar notmuch-show-filename-regexp "filename:\\(.*\\)$")
(defvar notmuch-show-contentype-regexp "Content-type: \\(.*\\)")
(defvar notmuch-show-tags-regexp "(\\([^)]*\\))$") (defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")
(defvar notmuch-show-parent-buffer nil) (defvar notmuch-show-parent-buffer nil)
@ -713,20 +715,44 @@ is what to put on the button."
(defun notmuch-show-markup-part (beg end depth) (defun notmuch-show-markup-part (beg end depth)
(if (re-search-forward notmuch-show-part-begin-regexp nil t) (if (re-search-forward notmuch-show-part-begin-regexp nil t)
(progn (progn
(forward-line) (let (mime-message mime-type)
(let ((beg (point-marker))) (save-excursion
(re-search-forward notmuch-show-part-end-regexp) (re-search-forward notmuch-show-contentype-regexp end t)
(let ((end (copy-marker (match-beginning 0)))) (setq mime-type (car (split-string (buffer-substring
(goto-char end) (match-beginning 1) (match-end 1))))))
(if (not (bolp))
(insert "\n")) (if (equal mime-type "text/html")
(indent-rigidly beg end depth) (let ((filename (notmuch-show-get-filename)))
(notmuch-show-markup-citations-region beg end depth) (with-temp-buffer
; Advance to the next part (if any) (so the outer loop can (insert-file-contents filename nil nil nil t)
; determine whether we've left the current message. (setq mime-message (mm-dissect-buffer)))))
(if (re-search-forward notmuch-show-part-begin-regexp nil t) (forward-line)
(beginning-of-line))))) (let ((beg (point-marker)))
(goto-char end))) (re-search-forward notmuch-show-part-end-regexp)
(let ((end (copy-marker (match-beginning 0))))
(goto-char end)
(if (not (bolp))
(insert "\n"))
(indent-rigidly beg end depth)
(if (not (eq mime-message nil))
(save-excursion
(goto-char beg)
(forward-line -1)
(let ((handle-type (mm-handle-type mime-message))
mime-type)
(if (sequencep (car handle-type))
(setq mime-type (car handle-type))
(setq mime-type (car (car (cdr handle-type))))
)
(if (equal mime-type "text/html")
(mm-display-part mime-message))))
)
(notmuch-show-markup-citations-region beg end depth)
; Advance to the next part (if any) (so the outer loop can
; determine whether we've left the current message.
(if (re-search-forward notmuch-show-part-begin-regexp nil t)
(beginning-of-line)))))
(goto-char end))))
(defun notmuch-show-markup-parts-region (beg end depth) (defun notmuch-show-markup-parts-region (beg end depth)
(save-excursion (save-excursion