Re: [PATCH] lib: Add a new prefix "list" to the search-terms syntax
[notmuch-archives.git] / a9 / 97c9f9425a1a0acef60817208656a609fe8b12
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 E01ED431FD9\r
6         for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:44 -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.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 BcPPxPnFZjD1 for <notmuch@notmuchmail.org>;\r
18         Fri, 30 Nov 2012 00:23:43 -0800 (PST)\r
19 Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
20  [74.125.82.47])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  890B1429E2F    for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:28 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f47.google.com with SMTP id dq11so77771wgb.2\r
25         for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:27 -0800 (PST)\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:x-mailer:in-reply-to:references;\r
28         bh=9HqEC0BEnsSKkk4YUs6e8JVAZluwmFRZErzAeRmkf6A=;\r
29         b=hDAPu1dkQNSvGhxD7hBXQ0QgDMU1IlLMf/sqfgTjIpA71qBlqAxMnBeZhHmhzE5KAa\r
30         VI7iQo20LCtOzKWLEQEALTsLU9YHJeE09yCQl//inKfdOMjkaR9QawdEiYTtCmQ76lnJ\r
31         3xvHTpVisPTMIKf2w9MCidj1mxD3rBzwEJdXzqBowLjw2gZNzway+S4ZnaGTkWyJsURO\r
32         WM96bvwIJi5U1TuzI2e9BmM2laYcb54e5iScwQLIIXTkQ/qgf3bbynBanhorZCfcV9Bm\r
33         WhrDyBJDtYkROCnY2W7X6gOVnDb76mRC7MGfQwzzXaUCBQD8ACXi6UMO+xCS4GoUS2aq\r
34         Z/oA==\r
35 Received: by 10.180.87.39 with SMTP id u7mr42399506wiz.6.1354263807247;\r
36         Fri, 30 Nov 2012 00:23:27 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id s12sm14297513wik.11.2012.11.30.00.23.25\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Fri, 30 Nov 2012 00:23:26 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 5/5] emacs: show tag completion\r
44 Date: Fri, 30 Nov 2012 08:21:31 +0000\r
45 Message-Id: <1354263691-19715-6-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Fri, 30 Nov 2012 08:23:45 -0000\r
62 \r
63 From: markwalters1009 <markwalters1009@gmail.com>\r
64 \r
65 This makes tagging in show mode pass the list of tags that it believes\r
66 occur to the tag completion function. This means that tag-completion\r
67 will complete to any tag that the user can see (even if it is no\r
68 longer present).\r
69 ---\r
70 The function to get all tags for a thread was taken from Damien's\r
71 notmuch-labeler series.\r
72 \r
73  emacs/notmuch-show.el |   32 +++++++++++++++++++++++++-------\r
74  1 files changed, 25 insertions(+), 7 deletions(-)\r
75 \r
76 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
77 index 489e32c..c2fef7b 100644\r
78 --- a/emacs/notmuch-show.el\r
79 +++ b/emacs/notmuch-show.el\r
80 @@ -1439,6 +1439,16 @@ current thread."\r
81    "Return the tags of the current message."\r
82    (notmuch-show-get-prop :tags))\r
83  \r
84 +(defun notmuch-show-thread-tags ()\r
85 +  "Return the list of tags for the current thread."\r
86 +  (let ((tags (list)))\r
87 +    (notmuch-show-mapc (lambda ()\r
88 +                        (mapcar (lambda (elt)\r
89 +                                  ;; Avoid adding duplicate tags\r
90 +                                  (add-to-list 'tags elt))\r
91 +                                (notmuch-show-get-tags))))\r
92 +    tags))\r
93 +\r
94  (defun notmuch-show-message-visible-p ()\r
95    "Is the current message visible?"\r
96    (notmuch-show-get-prop :message-visible))\r
97 @@ -1730,9 +1740,13 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
98  \r
99  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
100    (interactive)\r
101 -  (setq tag-changes (funcall 'notmuch-tag (notmuch-show-get-message-id) tag-changes))\r
102 -  (let* ((current-tags (notmuch-show-get-tags))\r
103 -        (new-tags (notmuch-update-tags current-tags tag-changes)))\r
104 +  (let ((current-tags (notmuch-show-get-tags))\r
105 +       (new-tags))\r
106 +    (setq tag-changes (funcall 'notmuch-tag\r
107 +                              (notmuch-show-get-message-id)\r
108 +                              tag-changes\r
109 +                              current-tags))\r
110 +    (setq new-tags (notmuch-update-tags current-tags tag-changes))\r
111      (unless (equal current-tags new-tags)\r
112        (notmuch-show-set-tags new-tags))))\r
113  \r
114 @@ -1741,13 +1755,17 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
115  \r
116  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
117    (interactive)\r
118 -  (setq tag-changes (funcall 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes))\r
119 -  (notmuch-show-mapc\r
120 -   (lambda ()\r
121 +  (let ((existing-tags (notmuch-show-thread-tags)))\r
122 +    (setq tag-changes (funcall 'notmuch-tag\r
123 +                              (notmuch-show-get-messages-ids-search)\r
124 +                              tag-changes\r
125 +                              existing-tags))\r
126 +    (notmuch-show-mapc\r
127 +     (lambda ()\r
128       (let* ((current-tags (notmuch-show-get-tags))\r
129             (new-tags (notmuch-update-tags current-tags tag-changes)))\r
130         (unless (equal current-tags new-tags)\r
131 -        (notmuch-show-set-tags new-tags))))))\r
132 +        (notmuch-show-set-tags new-tags)))))))\r
133  \r
134  (defun notmuch-show-add-tag ()\r
135    "Same as `notmuch-show-tag' but sets initial input to '+'."\r
136 -- \r
137 1.7.9.1\r
138 \r