Re: problems with nmbug and empty prefix (UnicodeWarning and broken pipe)
[notmuch-archives.git] / 0a / 408f28cf82fc62c5d37209767a9fbe7f33fc34
1 Return-Path: <alex.boterolowry@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id D5BB6431FBC\r
6         for <notmuch@notmuchmail.org>; Tue,  9 Feb 2010 17:54:14 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.117\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.117 tagged_above=-999 required=5\r
12         tests=[AWL=-0.119, BAYES_50=0.001, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=ham\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id yWYPqPYbaiXS for <notmuch@notmuchmail.org>;\r
17         Tue,  9 Feb 2010 17:54:13 -0800 (PST)\r
18 Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com\r
19         [209.85.210.182])\r
20         by olra.theworths.org (Postfix) with ESMTP id D44A9431FAE\r
21         for <notmuch@notmuchmail.org>; Tue,  9 Feb 2010 17:54:13 -0800 (PST)\r
22 Received: by yxe12 with SMTP id 12so113973yxe.32\r
23         for <notmuch@notmuchmail.org>; Tue, 09 Feb 2010 17:54:13 -0800 (PST)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
25         h=domainkey-signature:received:received:received:from:to:cc:subject\r
26         :date:message-id:x-mailer;\r
27         bh=tRwhr+AhZzqN3a1iDMpFdUodnJCcTG2QFZK3CuZmpV0=;\r
28         b=OWKzC6UCS3uB/VNYq/1T+kgLm/z6UuKrWw4YYgp7M6KFyUnQc5bi3R+7dkONibb/AV\r
29         +qt6giGtQ50hi//dqR0R1npgCDSYMeL2C7f1Zfg/eiuug1AEtUvlRKPogt600t8b/mVT\r
30         rVFaQ1j96NVmhbuOKs6oBp4OQ62mCw9gsBYA8=\r
31 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
32         h=from:to:cc:subject:date:message-id:x-mailer;\r
33         b=Y7ZguFdf+qRRgMicEI4WcUwU7JLXpWMB0qRe3HyloJ2Ix9lrsHjqCwY405OUAV5NdR\r
34         92NBto14L+J2rLIpV+4IQmo1FvIIRooMhY/FMASoi/TwOe464JNJjo670DJRmRY9z/Hh\r
35         1f4JwPq5u+qc0JYS3qgWAu+gN95d6lHgUXnGw=\r
36 Received: by 10.151.89.33 with SMTP id r33mr1278202ybl.290.1265766853270;\r
37         Tue, 09 Feb 2010 17:54:13 -0800 (PST)\r
38 Received: from fortitudo (nat10.metaweb.com [208.68.111.137])\r
39         by mx.google.com with ESMTPS id 21sm259764yxe.37.2010.02.09.17.54.12\r
40         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
41         Tue, 09 Feb 2010 17:54:12 -0800 (PST)\r
42 Received: from alexbl (uid 1001) (envelope-from alexbl@fortitudo) id a0ed\r
43         by fortitudo (DragonFly Mail Agent) Tue, 09 Feb 2010 17:55:28 -0800\r
44 From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
45 To: notmuch@notmuchmail.org\r
46 Date: Tue,  9 Feb 2010 17:55:21 -0800\r
47 Message-Id: <1265766921-9380-1-git-send-email-alex.boterolowry@gmail.com>\r
48 X-Mailer: git-send-email 1.6.5.2\r
49 Subject: [notmuch] [PATCH] Reintroduce HTML inlining,\r
50         with a much needed optimization\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Wed, 10 Feb 2010 01:54:15 -0000\r
64 \r
65 Now instead of requiring every single message be parsed, we now check\r
66 the Content-type in the parsed headers and only do HTML inlining if it's\r
67 text/html\r
68 ---\r
69  notmuch.el |   54 ++++++++++++++++++++++++++++++++++++++++--------------\r
70  1 files changed, 40 insertions(+), 14 deletions(-)\r
71 \r
72 diff --git a/notmuch.el b/notmuch.el\r
73 index 6f69001..b49d4d1 100644\r
74 --- a/notmuch.el\r
75 +++ b/notmuch.el\r
76 @@ -133,6 +133,8 @@ remaining lines into a button.")\r
77  (defvar notmuch-show-id-regexp "\\(id:[^ ]*\\)")\r
78  (defvar notmuch-show-depth-match-regexp " depth:\\([0-9]*\\).*match:\\([01]\\) ")\r
79  (defvar notmuch-show-filename-regexp "filename:\\(.*\\)$")\r
80 +(defvar notmuch-show-contentype-regexp "Content-type: \\(.*\\)")\r
81 +\r
82  (defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")\r
83  \r
84  (defvar notmuch-show-parent-buffer nil)\r
85 @@ -713,20 +715,44 @@ is what to put on the button."\r
86  (defun notmuch-show-markup-part (beg end depth)\r
87    (if (re-search-forward notmuch-show-part-begin-regexp nil t)\r
88        (progn\r
89 -       (forward-line)\r
90 -       (let ((beg (point-marker)))\r
91 -         (re-search-forward notmuch-show-part-end-regexp)\r
92 -         (let ((end (copy-marker (match-beginning 0))))\r
93 -           (goto-char end)\r
94 -           (if (not (bolp))\r
95 -               (insert "\n"))\r
96 -           (indent-rigidly beg end depth)\r
97 -           (notmuch-show-markup-citations-region beg end depth)\r
98 -           ; Advance to the next part (if any) (so the outer loop can\r
99 -           ; determine whether we've left the current message.\r
100 -           (if (re-search-forward notmuch-show-part-begin-regexp nil t)\r
101 -               (beginning-of-line)))))\r
102 -    (goto-char end)))\r
103 +        (let (mime-message mime-type)\r
104 +          (save-excursion\r
105 +            (re-search-forward notmuch-show-contentype-regexp end t)\r
106 +            (setq mime-type (car (split-string (buffer-substring \r
107 +                                                (match-beginning 1) (match-end 1))))))\r
108 +\r
109 +          (if (equal mime-type "text/html")\r
110 +              (let ((filename (notmuch-show-get-filename)))\r
111 +                (with-temp-buffer\r
112 +                  (insert-file-contents filename nil nil nil t)\r
113 +                  (setq mime-message (mm-dissect-buffer)))))\r
114 +          (forward-line)\r
115 +          (let ((beg (point-marker)))\r
116 +            (re-search-forward notmuch-show-part-end-regexp)\r
117 +            (let ((end (copy-marker (match-beginning 0))))\r
118 +              (goto-char end)\r
119 +              (if (not (bolp))\r
120 +                  (insert "\n"))\r
121 +              (indent-rigidly beg end depth)\r
122 +              (if (not (eq mime-message nil))\r
123 +                  (save-excursion\r
124 +                    (goto-char beg)\r
125 +                    (forward-line -1)\r
126 +                    (let ((handle-type (mm-handle-type mime-message))\r
127 +                          mime-type)\r
128 +                      (if (sequencep (car handle-type))\r
129 +                          (setq mime-type (car handle-type))\r
130 +                        (setq mime-type (car (car (cdr handle-type))))\r
131 +                        )\r
132 +                      (if (equal mime-type "text/html")\r
133 +                          (mm-display-part mime-message))))\r
134 +                )\r
135 +              (notmuch-show-markup-citations-region beg end depth)\r
136 +              ; Advance to the next part (if any) (so the outer loop can\r
137 +              ; determine whether we've left the current message.\r
138 +              (if (re-search-forward notmuch-show-part-begin-regexp nil t)\r
139 +                  (beginning-of-line)))))\r
140 +        (goto-char end))))\r
141  \r
142  (defun notmuch-show-markup-parts-region (beg end depth)\r
143    (save-excursion\r
144 -- \r
145 1.6.5.2\r
146 \r