[Patch v3 7/8] emacs: search: use orig-tags in search
[notmuch-archives.git] / 8e / 1c9ae73122f2b8b2c808e3a2f6b8e2d71d9f75
1 Return-Path: <markwalters1009@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 85A66431FD2\r
6         for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 21:10:37 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id YjdwxszQjQsL for <notmuch@notmuchmail.org>;\r
18         Tue, 11 Mar 2014 21:10:33 -0700 (PDT)\r
19 Received: from mail-we0-f174.google.com (mail-we0-f174.google.com\r
20         [74.125.82.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 08678431FBD\r
23         for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 21:10:14 -0700 (PDT)\r
24 Received: by mail-we0-f174.google.com with SMTP id t60so10749499wes.19\r
25         for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 21:10:13 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=rrUeiRgkpA6faVReXIyxZLNBGvad/p5Ju8owu1KcQ6c=;\r
29         b=qNZ1NNAWObiuWcOOh3jR4CS57WrUswRxcUrJOEPJf2IjNu6TCRgLtT+45WSh33pGry\r
30         /fGFkFlF6hHe1rw5kiMUloDFf7Lel4owtOhcTs6bmnJ1Sq/KaK+IpwJqmGisFwv5ZSzG\r
31         0m4emOSN0Ozdd9LJvNRyg7zcY79Co+NIDqb+770LU6Hq0qCX8jiiRPNN9lTsRxjZzQzf\r
32         esFg8ggVmXgGxvHzT61uNdvBmo3uDx76NF0NJrBXKLsMwPM1eQ4fIvT9xJSWB7Km8Xsu\r
33         2rDnthOPOBiDg+r8UbBlEQgWTf7PuuZT9nUmMXiB8whAbco/c2enxQTDlv2EhLtWcQNb\r
34         vMAA==\r
35 X-Received: by 10.194.21.193 with SMTP id x1mr39073151wje.33.1394597413934;\r
36         Tue, 11 Mar 2014 21:10:13 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id n3sm12266236wix.10.2014.03.11.21.10.12\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Tue, 11 Mar 2014 21:10:13 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         amdragon@mit.edu\r
45 Subject: [Patch v3 7/8] emacs: search: use orig-tags in search\r
46 Date: Wed, 12 Mar 2014 04:09:56 +0000\r
47 Message-Id: <1394597397-8486-8-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.9.1\r
49 In-Reply-To: <1394597397-8486-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1394597397-8486-1-git-send-email-markwalters1009@gmail.com>\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, 12 Mar 2014 04:10:37 -0000\r
64 \r
65 This uses the recent functionality to show the tag changes in the\r
66 search buffer. Currently this is only used to show changes the search\r
67 buffer makes itself: i.e., it does not make display any changes\r
68 reflecting tagging done by other notmuch-buffers.\r
69 ---\r
70  emacs/notmuch.el |   41 +++++++++++++++++++++++++----------------\r
71  1 files changed, 25 insertions(+), 16 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
74 index 609f408..cb71381 100644\r
75 --- a/emacs/notmuch.el\r
76 +++ b/emacs/notmuch.el\r
77 @@ -753,24 +753,33 @@ (defun notmuch-search-insert-field (field format-string result)\r
78       format-string (notmuch-sanitize (plist-get result :authors))))\r
79  \r
80     ((string-equal field "tags")\r
81 -    (let ((tags (plist-get result :tags)))\r
82 -      (insert (format format-string (notmuch-tag-format-tags tags tags)))))))\r
83 +    (let ((tags (plist-get result :tags))\r
84 +         (orig-tags (plist-get result :orig-tags)))\r
85 +      (insert (format format-string (notmuch-tag-format-tags tags orig-tags)))))))\r
86  \r
87 -(defun notmuch-search-show-result (result &optional pos)\r
88 -  "Insert RESULT at POS or the end of the buffer if POS is null."\r
89 +(defun notmuch-search-show-result (result pos)\r
90 +  "Insert RESULT at POS."\r
91    ;; Ignore excluded matches\r
92    (unless (= (plist-get result :matched) 0)\r
93 -    (let ((beg (or pos (point-max))))\r
94 -      (save-excursion\r
95 -       (goto-char beg)\r
96 -       (dolist (spec notmuch-search-result-format)\r
97 -         (notmuch-search-insert-field (car spec) (cdr spec) result))\r
98 -       (insert "\n")\r
99 -       (notmuch-search-color-line beg (point) (plist-get result :tags))\r
100 -       (put-text-property beg (point) 'notmuch-search-result result))\r
101 -      (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
102 -       (setq notmuch-search-target-thread "found")\r
103 -       (goto-char beg)))))\r
104 +    (save-excursion\r
105 +      (goto-char pos)\r
106 +      (dolist (spec notmuch-search-result-format)\r
107 +       (notmuch-search-insert-field (car spec) (cdr spec) result))\r
108 +      (insert "\n")\r
109 +      (notmuch-search-color-line pos (point) (plist-get result :tags))\r
110 +      (put-text-property pos (point) 'notmuch-search-result result))))\r
111 +\r
112 +(defun notmuch-search-append-result (result)\r
113 +  "Insert RESULT at the end of the buffer.\r
114 +\r
115 +This is only called when a result is first inserted so it also\r
116 +sets the :orig-tag property."\r
117 +  (let ((new-result (plist-put result :orig-tags (plist-get result :tags)))\r
118 +       (pos (point-max)))\r
119 +    (notmuch-search-show-result new-result pos)\r
120 +    (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
121 +      (setq notmuch-search-target-thread "found")\r
122 +      (goto-char pos))))\r
123  \r
124  (defun notmuch-search-process-filter (proc string)\r
125    "Process and filter the output of \"notmuch search\""\r
126 @@ -784,7 +793,7 @@ (defun notmuch-search-process-filter (proc string)\r
127         (save-excursion\r
128           (goto-char (point-max))\r
129           (insert string))\r
130 -       (notmuch-sexp-parse-partial-list 'notmuch-search-show-result\r
131 +       (notmuch-sexp-parse-partial-list 'notmuch-search-append-result\r
132                                          results-buf)))))\r
133  \r
134  (defun notmuch-search-tag-all (tag-changes)\r
135 -- \r
136 1.7.9.1\r
137 \r