Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 6d / 44ab9f87cfeb97485c069d4f6c3ca643d12a09
1 Return-Path: <amdragon@mit.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 8B69C431FD8\r
6         for <notmuch@notmuchmail.org>; Tue,  3 Jul 2012 15:21:10 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 ZNO-aod-YEZG for <notmuch@notmuchmail.org>;\r
16         Tue,  3 Jul 2012 15:21:06 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
18         [18.7.68.37])\r
19         by olra.theworths.org (Postfix) with ESMTP id 68416431FAF\r
20         for <notmuch@notmuchmail.org>; Tue,  3 Jul 2012 15:21:06 -0700 (PDT)\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-5c-4ff37051c068\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 99.1B.02244.15073FF4; Tue,  3 Jul 2012 18:21:05 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q63ML40M022244; \r
27         Tue, 3 Jul 2012 18:21:05 -0400\r
28 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q63ML1wU023221\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Tue, 3 Jul 2012 18:21:02 -0400 (EDT)\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1SmBSv-0007fP-0N; Tue, 03 Jul 2012 18:21:01 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 3/8] emacs: Move search-target logic to\r
40         `notmuch-search-show-result'\r
41 Date: Tue,  3 Jul 2012 18:20:54 -0400\r
42 Message-Id: <1341354059-29396-4-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10\r
44 In-Reply-To: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
45 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixG6nohtY8NnfYMpfQ4sje2axWyw985/Z\r
48         4vrNmcwWb1bOY3Vg8dg56y67x+GvC1k8nq26xezR9GMxawBLFJdNSmpOZllqkb5dAlfG429r\r
49         2QtmS1fcO3mFqYHxhWgXIyeHhICJxI+ja1ggbDGJC/fWs3UxcnEICexjlJi5rpEVwlnPKPH+\r
50         xWOwKiGBk0wS105ZQiTmMkpM2H+XCSTBJqAhsW3/ckYQW0RAWmLn3dmsIDazQK7E2dbDYHFh\r
51         gRCJKXeWg9WzCKhKXPhwGSzOK+Ag0bbqCiPEGfIST+/3sYHYnAKOEitunoVa7CCx7UMH6wRG\r
52         /gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0LfRyM0v0UlNKNzGCQ85FdQfjhENKhxgFOBiV\r
53         eHgTFT77C7EmlhVX5h5ilORgUhLlvZIHFOJLyk+pzEgszogvKs1JLT7EKMHBrCTCuzoJKMeb\r
54         klhZlVqUD5OS5mBREue9kXLTX0ggPbEkNTs1tSC1CCYrw8GhJMHbmg/UKFiUmp5akZaZU4KQ\r
55         ZuLgBBnOAzR8GUgNb3FBYm5xZjpE/hSjopQ4bxVIQgAkkVGaB9cLSwmvGMWBXhHm7QSp4gGm\r
56         E7juV0CDmYAG5y3+BDK4JBEhJdXAaPzC4MFWKafuVWvvyr8009my1GgOY1jR/dKOtO+aDyL/\r
57         fdm1s6Ii4XJBxLLt38KLao448JR/O/1a+vCbksXNW6RcNdMVj7z/Mc11VWh6498rsm66t9Tn\r
58         CByZdvnCqgLenljJ1olblx2+aBLHFf9gd9rFM1H/n16VX5IpuFk+SsXnELt/yqJuEyWW4oxE\r
59         Qy3mouJEAF295MLkAgAA\r
60 Cc: tomi.ollila@iki.fi\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Tue, 03 Jul 2012 22:21:10 -0000\r
74 \r
75 This is a simpler place to do this, since we can avoid any point\r
76 motion and hence any save-excursions in\r
77 `notmuch-search-process-filter', which in turn lets us put all of the\r
78 search-target logic outside of any save-excursions.\r
79 \r
80 `notmuch-search-process-filter' could use some reindentation after\r
81 this, but we're about to rewrite it entirely, so we won't bother.\r
82 ---\r
83  emacs/notmuch.el |   33 +++++++++++++++------------------\r
84  1 file changed, 15 insertions(+), 18 deletions(-)\r
85 \r
86 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
87 index dadc6d6..4a6490a 100644\r
88 --- a/emacs/notmuch.el\r
89 +++ b/emacs/notmuch.el\r
90 @@ -729,24 +729,27 @@ non-authors is found, assume that all of the authors match."\r
91  (defun notmuch-search-show-result (thread-id date count authors subject tags)\r
92    ;; Ignore excluded matches\r
93    (unless (eq (aref count 1) ?0)\r
94 -    (let ((beg (point))\r
95 +    (let ((beg (point-max))\r
96           (tags-str (mapconcat 'identity tags " ")))\r
97 -      (dolist (format notmuch-search-result-format)\r
98 -       (notmuch-search-insert-field (car format) (cdr format)\r
99 -                                    date count authors subject tags-str))\r
100 -      (insert "\n")\r
101 -      (notmuch-search-color-line beg (point) tags)\r
102 -      (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
103 -      (put-text-property beg (point) 'notmuch-search-authors authors)\r
104 -      (put-text-property beg (point) 'notmuch-search-subject subject))))\r
105 +      (save-excursion\r
106 +       (goto-char beg)\r
107 +       (dolist (format notmuch-search-result-format)\r
108 +         (notmuch-search-insert-field (car format) (cdr format)\r
109 +                                      date count authors subject tags-str))\r
110 +       (insert "\n")\r
111 +       (notmuch-search-color-line beg (point) tags)\r
112 +       (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
113 +       (put-text-property beg (point) 'notmuch-search-authors authors)\r
114 +       (put-text-property beg (point) 'notmuch-search-subject subject))\r
115 +      (when (string= thread-id notmuch-search-target-thread)\r
116 +       (setq notmuch-search-target-thread "found")\r
117 +       (goto-char beg)))))\r
118  \r
119  (defun notmuch-search-process-filter (proc string)\r
120    "Process and filter the output of \"notmuch search\""\r
121 -  (let ((buffer (process-buffer proc))\r
122 -       (found-target nil))\r
123 +  (let ((buffer (process-buffer proc)))\r
124      (if (buffer-live-p buffer)\r
125         (with-current-buffer buffer\r
126 -         (save-excursion\r
127             (let ((line 0)\r
128                   (more t)\r
129                   (inhibit-read-only t)\r
130 @@ -763,12 +766,8 @@ non-authors is found, assume that all of the authors match."\r
131                            (subject (match-string 5 string))\r
132                            (tags (match-string 6 string))\r
133                            (tag-list (if tags (save-match-data (split-string tags)))))\r
134 -                     (goto-char (point-max))\r
135                       (if (/= (match-beginning 1) line)\r
136                           (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n")))\r
137 -                     (when (string= thread-id notmuch-search-target-thread)\r
138 -                       (set 'found-target (point))\r
139 -                       (set 'notmuch-search-target-thread "found"))\r
140                       (notmuch-search-show-result thread-id date count authors subject tag-list)\r
141                       (set 'line (match-end 0)))\r
142                   (set 'more nil)\r
143 @@ -777,8 +776,6 @@ non-authors is found, assume that all of the authors match."\r
144                   (if (< line (length string))\r
145                       (setq notmuch-search-process-filter-data (substring string line)))\r
146                   ))))\r
147 -         (if found-target\r
148 -             (goto-char found-target)))\r
149        (delete-process proc))))\r
150  \r
151  (defun notmuch-search-tag-all (&optional tag-changes)\r
152 -- \r
153 1.7.10\r
154 \r