Missing headers when forwarding html message as RFC822
[notmuch-archives.git] / 5d / 0b0de72c1337a93ce04c19022a3b3a06c7baa8
1 Return-Path: <prvs=jrosenthal=712b66f61@jhu.edu>\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 8EF5F418C3C\r
6         for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 11:47:25 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.301\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.301 tagged_above=-999 required=5\r
12         tests=[BAYES_20=-0.001, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id tj0qlkNOhVxs for <notmuch@notmuchmail.org>;\r
16         Tue, 13 Apr 2010 11:47:21 -0700 (PDT)\r
17 Received: from ipex4.johnshopkins.edu (ipex4.johnshopkins.edu\r
18         [128.220.161.141])\r
19         by olra.theworths.org (Postfix) with ESMTP id 40B7F418C25\r
20         for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 11:47:21 -0700 (PDT)\r
21 X-IronPort-AV: E=Sophos;i="4.52,199,1270440000"; d="scan'208";a="354301918"\r
22 Received: from c-69-255-36-229.hsd1.md.comcast.net (HELO lucky)\r
23         ([69.255.36.229])\r
24         by ipex4.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
25         13 Apr 2010 14:47:20 -0400\r
26 Received: from jkr by lucky with local (Exim 4.69)\r
27         (envelope-from <jrosenthal@jhu.edu>)\r
28         id 1O1l8p-0006Md-Or; Tue, 13 Apr 2010 14:47:19 -0400\r
29 From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
30 To: Carl Worth <cworth@cworth.org>, notmuch@notmuchmail.org\r
31 Subject: [PATCH] Fix bug, and clean up code duplication,\r
32         in adding or removing tag by region.\r
33 In-Reply-To: <878w8rkzis.fsf@yoom.home.cworth.org>\r
34 References: <m1636w7au5.fsf@watt.gilman.jhu.edu> <87sk90ragj.fsf@jhu.edu>\r
35         <87aatfq88h.fsf@yoom.home.cworth.org> <877hogaf7v.fsf@jhu.edu>\r
36         <878w8rkzis.fsf@yoom.home.cworth.org>\r
37 Date: Tue, 13 Apr 2010 14:47:19 -0400\r
38 Message-ID: <871vejxk94.fsf@jhu.edu>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain; charset=us-ascii\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Tue, 13 Apr 2010 18:47:25 -0000\r
54 \r
55 There was a bug in notmuch-search-{add,remove}-tag-region, which would\r
56 not behave correctly if the region went beyond the last message. Now,\r
57 instead of simply iterating to the last line of the region, these\r
58 functions will iterate to the minimum of the last line of the region\r
59 and the last possible line, i.e.\r
60 \r
61 (- (line-number-at-pos (point-max)) 2)\r
62 \r
63 Also clean up code duplication, as per Carl's suggestion, by making\r
64 notmuch-search-{add/remove}-tag-thread a special case of the -region\r
65 commands, where the region in question is between (point) and (point).\r
66 ---\r
67  emacs/notmuch.el |   26 ++++++++++++++------------\r
68  1 files changed, 14 insertions(+), 12 deletions(-)\r
69 \r
70 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
71 index 517c53a..be09f42 100644\r
72 --- a/emacs/notmuch.el\r
73 +++ b/emacs/notmuch.el\r
74 @@ -399,10 +399,11 @@ Complete list of currently available key bindings:\r
75  (defun notmuch-search-properties-in-region (property beg end)\r
76    (save-excursion\r
77      (let ((output nil)\r
78 -         (last-line (line-number-at-pos end)))\r
79 +         (last-line (line-number-at-pos end))\r
80 +         (max-line (- (line-number-at-pos (point-max)) 2)))\r
81        (goto-char beg)\r
82        (beginning-of-line)\r
83 -      (while (<= (line-number-at-pos) last-line)\r
84 +      (while (<= (line-number-at-pos) (min last-line max-line))\r
85         (setq output (cons (get-text-property (point) property) output))\r
86         (forward-line 1))\r
87        output)))\r
88 @@ -497,38 +498,39 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
89  (defun notmuch-search-get-tags-region (beg end)\r
90    (save-excursion\r
91      (let ((output nil)\r
92 -         (last-line (line-number-at-pos end)))\r
93 +         (last-line (line-number-at-pos end))\r
94 +         (max-line (- (line-number-at-pos (point-max)) 2)))\r
95        (goto-char beg)\r
96 -      (while (<= (line-number-at-pos) last-line)\r
97 +      (while (<= (line-number-at-pos) (min last-line max-line))\r
98         (setq output (append output (notmuch-search-get-tags)))\r
99         (forward-line 1))\r
100        output)))\r
101  \r
102  (defun notmuch-search-add-tag-thread (tag)\r
103 -  (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id))\r
104 -  (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))\r
105 +  (notmuch-search-add-tag-region tag (point) (point)))\r
106  \r
107  (defun notmuch-search-add-tag-region (tag beg end)\r
108    (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))\r
109      (notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-string)\r
110      (save-excursion\r
111 -      (let ((last-line (line-number-at-pos end)))\r
112 +      (let ((last-line (line-number-at-pos end))\r
113 +           (max-line (- (line-number-at-pos (point-max)) 2)))\r
114         (goto-char beg)\r
115 -       (while (<= (line-number-at-pos) last-line)\r
116 +       (while (<= (line-number-at-pos) (min last-line max-line))\r
117           (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<)))\r
118           (forward-line))))))\r
119  \r
120  (defun notmuch-search-remove-tag-thread (tag)\r
121 -  (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id))\r
122 -  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))\r
123 +  (notmuch-search-remove-tag-region tag (point) (point)))\r
124  \r
125  (defun notmuch-search-remove-tag-region (tag beg end)\r
126    (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))\r
127      (notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-string)\r
128      (save-excursion\r
129 -      (let ((last-line (line-number-at-pos end)))\r
130 +      (let ((last-line (line-number-at-pos end))\r
131 +           (max-line (- (line-number-at-pos (point-max)) 2)))\r
132         (goto-char beg)\r
133 -       (while (<= (line-number-at-pos) last-line)\r
134 +       (while (<= (line-number-at-pos) (min last-line max-line))\r
135           (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))\r
136           (forward-line))))))\r
137  \r
138 -- \r
139 1.6.5.3\r
140 \r