* [PATCH] Reintroduce HTML inlining, with a much needed optimization
@ 2010-02-10 1:55 Alexander Botero-Lowry
2010-02-10 2:18 ` Carl Worth
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Botero-Lowry @ 2010-02-10 1:55 UTC (permalink / raw)
To: notmuch
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
---
notmuch.el | 54 ++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index 6f69001..b49d4d1 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -133,6 +133,8 @@ remaining lines into a button.")
(defvar notmuch-show-id-regexp "\\(id:[^ ]*\\)")
(defvar notmuch-show-depth-match-regexp " depth:\\([0-9]*\\).*match:\\([01]\\) ")
(defvar notmuch-show-filename-regexp "filename:\\(.*\\)$")
+(defvar notmuch-show-contentype-regexp "Content-type: \\(.*\\)")
+
(defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")
(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)
(if (re-search-forward notmuch-show-part-begin-regexp nil t)
(progn
- (forward-line)
- (let ((beg (point-marker)))
- (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)
- (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)))
+ (let (mime-message mime-type)
+ (save-excursion
+ (re-search-forward notmuch-show-contentype-regexp end t)
+ (setq mime-type (car (split-string (buffer-substring
+ (match-beginning 1) (match-end 1))))))
+
+ (if (equal mime-type "text/html")
+ (let ((filename (notmuch-show-get-filename)))
+ (with-temp-buffer
+ (insert-file-contents filename nil nil nil t)
+ (setq mime-message (mm-dissect-buffer)))))
+ (forward-line)
+ (let ((beg (point-marker)))
+ (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)
(save-excursion
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Reintroduce HTML inlining, with a much needed optimization
2010-02-10 1:55 [PATCH] Reintroduce HTML inlining, with a much needed optimization Alexander Botero-Lowry
@ 2010-02-10 2:18 ` Carl Worth
2010-02-12 16:14 ` Michal Sojka
0 siblings, 1 reply; 3+ messages in thread
From: Carl Worth @ 2010-02-10 2:18 UTC (permalink / raw)
To: Alexander Botero-Lowry, notmuch
[-- Attachment #1: Type: text/plain, Size: 320 bytes --]
On Tue, 9 Feb 2010 17:55:21 -0800, Alexander Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> 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
Excellent! I've pushed this out now. Greatly appreciated.
-Carl
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Reintroduce HTML inlining, with a much needed optimization
2010-02-10 2:18 ` Carl Worth
@ 2010-02-12 16:14 ` Michal Sojka
0 siblings, 0 replies; 3+ messages in thread
From: Michal Sojka @ 2010-02-12 16:14 UTC (permalink / raw)
To: Carl Worth, Alexander Botero-Lowry, notmuch
On Tue, 09 Feb 2010 18:18:38 -0800, Carl Worth <cworth@cworth.org> wrote:
> On Tue, 9 Feb 2010 17:55:21 -0800, Alexander Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> > 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
>
> Excellent! I've pushed this out now. Greatly appreciated.
Hi,
I have the following problem when viewing HTML inline. With certain HTML
messages containing non-ASCII characters, these non-ASCII characters are
not displayed. Since we use many non-ASCII characters in czech language,
this is quite a problem. It is interesting that this doesn't happen with
all messages. Does anybody know what might cause this behaviour?
Thanks
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-12 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-10 1:55 [PATCH] Reintroduce HTML inlining, with a much needed optimization Alexander Botero-Lowry
2010-02-10 2:18 ` Carl Worth
2010-02-12 16:14 ` Michal Sojka
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).