Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / f3 / ba2025e244cd7232e50b7e5dade69e528d8034
1 Return-Path: <pieter@praet.org>\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 C1276416017\r
6         for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:33:33 -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.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 yNo0EdQbYeNz for <notmuch@notmuchmail.org>;\r
16         Fri, 24 Feb 2012 14:33:32 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  D676540A39E    for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:33:31 -0800\r
21  (PST)\r
22 Received: by mail-ww0-f45.google.com with SMTP id dt12so2226566wgb.2\r
23         for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:33:31 -0800 (PST)\r
24 Received-SPF: pass (google.com: domain of pieter@praet.org designates\r
25         10.180.84.41 as permitted sender) client-ip=10.180.84.41; \r
26 Authentication-Results: mr.google.com;\r
27         spf=pass (google.com: domain of pieter@praet.org\r
28         designates 10.180.84.41 as permitted sender)\r
29         smtp.mail=pieter@praet.org\r
30 Received: from mr.google.com ([10.180.84.41])\r
31         by 10.180.84.41 with SMTP id v9mr1892673wiy.11.1330122811610 (num_hops\r
32         = 1); Fri, 24 Feb 2012 14:33:31 -0800 (PST)\r
33 MIME-Version: 1.0\r
34 Received: by 10.180.84.41 with SMTP id v9mr1466888wiy.11.1330122811554;\r
35         Fri, 24 Feb 2012 14:33:31 -0800 (PST)\r
36 Received: from localhost ([109.131.181.26])\r
37         by mx.google.com with ESMTPS id h19sm6281406wiw.9.2012.02.24.14.33.30\r
38         (version=TLSv1/SSLv3 cipher=OTHER);\r
39         Fri, 24 Feb 2012 14:33:31 -0800 (PST)\r
40 From: Pieter Praet <pieter@praet.org>\r
41 To: David Bremner <david@tethera.net>,\r
42         Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
43 Subject: [PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only\r
44         tags open messages\r
45 Date: Fri, 24 Feb 2012 23:30:40 +0100\r
46 Message-Id: <1330122640-18895-7-git-send-email-pieter@praet.org>\r
47 X-Mailer: git-send-email 1.7.8.1\r
48 In-Reply-To: <1330122640-18895-1-git-send-email-pieter@praet.org>\r
49 References: <87wr7xqpuf.fsf@rocinante.cs.unb.ca>\r
50         <1330122640-18895-1-git-send-email-pieter@praet.org>\r
51 X-Gm-Message-State:\r
52  ALoCoQkHwEgRqcSgUsWH2P172kGcyTAP78BDGxIq0fuOzwTQSge5VFIje50IMRuPRbNM9IZeM/PK\r
53 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Fri, 24 Feb 2012 22:33:34 -0000\r
67 \r
68 * emacs/notmuch-show.el\r
69 \r
70   (notmuch-show-get-messages-ids):\r
71     If provided with optional argument PREDICATE, only return\r
72     Message-Id's of messages for which PREDICATE returns non-nil.\r
73 \r
74   (notmuch-show-tag-all):\r
75     New argument ONLY-OPEN (set to `current-prefix-arg' if running\r
76     interactively): if non-nil, only change tags of *open* messages.\r
77     Also correct original docstring: 's/thread/buffer/'.\r
78 \r
79   (notmuch-show-archive-thread):\r
80     Update wrt changes to `notmuch-show-tag-all'.\r
81 \r
82 * test/emacs\r
83 \r
84   - Subtest "notmuch-show: change tags of open messages in current buffer"\r
85     is no longer broken...\r
86 ---\r
87  emacs/notmuch-show.el |   33 ++++++++++++++++++++++++---------\r
88  test/emacs            |    1 -\r
89  2 files changed, 24 insertions(+), 10 deletions(-)\r
90 \r
91 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
92 index 05606fc..4bd1a7c 100644\r
93 --- a/emacs/notmuch-show.el\r
94 +++ b/emacs/notmuch-show.el\r
95 @@ -1339,14 +1339,18 @@ (defun notmuch-show-get-message-id ()\r
96    "Return the message id of the current message."\r
97    (concat "id:\"" (notmuch-show-get-prop :id) "\""))\r
98  \r
99 -(defun notmuch-show-get-messages-ids (&optional separator)\r
100 +(defun notmuch-show-get-messages-ids (&optional separator predicate)\r
101    "Return a list of Message-Id's of all messages in the current buffer.\r
102  \r
103  If provided with optional argument SEPARATOR, return a string\r
104 -instead, consisting of all Message-Id's separated by SEPARATOR."\r
105 +instead, consisting of all Message-Id's separated by SEPARATOR.\r
106 +\r
107 +If provided with optional argument PREDICATE, only return\r
108 +Message-Id's of messages for which PREDICATE returns non-nil."\r
109    (let ((message-ids))\r
110      (notmuch-show-mapc\r
111 -     (lambda () (push (notmuch-show-get-message-id) message-ids)))\r
112 +     (lambda () (push (notmuch-show-get-message-id) message-ids))\r
113 +     predicate)\r
114      (if separator\r
115         (mapconcat 'identity message-ids separator)\r
116        message-ids)))\r
117 @@ -1633,18 +1637,29 @@ (defun notmuch-show-tag (&optional initial-input)\r
118                       initial-input (notmuch-show-get-message-id))))\r
119      (apply 'notmuch-show-tag-message tag-changes)))\r
120  \r
121 -(defun notmuch-show-tag-all (&rest tag-changes)\r
122 -  "Change tags for all messages in the current thread.\r
123 +(defun notmuch-show-tag-all (only-open &rest tag-changes)\r
124 +  "Change tags of all messages in the current buffer.\r
125 +\r
126 +If ONLY-OPEN is non-nil, only change tags of *open* messages in\r
127 +the current buffer.\r
128  \r
129  TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
130 -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))\r
131 -  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)\r
132 +  (interactive (cons current-prefix-arg\r
133 +                    (notmuch-read-tag-changes nil notmuch-show-thread-id)))\r
134 +  (apply 'notmuch-tag\r
135 +        (notmuch-show-get-messages-ids\r
136 +         " or "\r
137 +         `(lambda ()\r
138 +            ,(if only-open '(notmuch-show-message-visible-p) t)))\r
139 +        tag-changes)\r
140    (notmuch-show-mapc\r
141     (lambda ()\r
142       (let* ((current-tags (notmuch-show-get-tags))\r
143             (new-tags (notmuch-update-tags current-tags tag-changes)))\r
144         (unless (equal current-tags new-tags)\r
145 -        (notmuch-show-set-tags new-tags))))))\r
146 +        (notmuch-show-set-tags new-tags))))\r
147 +   `(lambda ()\r
148 +      ,(if only-open '(notmuch-show-message-visible-p) t))))\r
149  \r
150  (defun notmuch-show-add-tag ()\r
151    "Same as `notmuch-show-tag' but sets initial input to '+'."\r
152 @@ -1724,7 +1739,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)\r
153  buffer."\r
154    (interactive "P")\r
155    (let ((op (if unarchive "+" "-")))\r
156 -    (notmuch-show-tag-all (concat op "inbox"))))\r
157 +    (notmuch-show-tag-all nil (concat op "inbox"))))\r
158  \r
159  (defun notmuch-show-archive-thread-then-next ()\r
160    "Archive each message in thread, then show next thread from search."\r
161 diff --git a/test/emacs b/test/emacs\r
162 index 9088ced..e6b0503 100755\r
163 --- a/test/emacs\r
164 +++ b/test/emacs\r
165 @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes\r
166  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == TOTAL\r
167  \r
168  test_begin_subtest "notmuch-show: change tags of open messages in current buffer"\r
169 -test_subtest_known_broken\r
170  query="$os_x_darwin_thread"\r
171  filter="from:Jiang"\r
172  add_tag="notmuch-show-tag-all"\r
173 -- \r
174 1.7.8.1\r
175 \r