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 A631B431FC0
\r
6 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:27 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 CdTiXX58HwRG for <notmuch@notmuchmail.org>;
\r
18 Fri, 30 Nov 2012 00:23:25 -0800 (PST)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (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 95912431FBD
\r
23 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:20 -0800 (PST)
\r
24 Received: by mail-we0-f181.google.com with SMTP id t11so77850wey.26
\r
25 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:20 -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=u8rN4bEUPi/AHwBU9koSVq66/aT0WL7fbyJgV8hVgro=;
\r
29 b=DlPRn7QBiWeJWEZwmeU8UGORm6pBhE212fT9uqWnL2C1QbCWMd2C1PZQWkFBNkr208
\r
30 mpqGuhvD32Fjmi5Utx442WMFn8yPseiw7qp2BWDL6QxGoKxX42qnD3DLTgMh3TgViNfX
\r
31 q3dv+U6UHRtKYwNQtH0+nU/PpS06q/G7Wn8HqSUTS8d/3ReHVuBh/4VR1kl7+krYVwCJ
\r
32 vxBwVEINeL9o0jxx2Badj9sqs7QPkp8+JKUccswLHJWFE4ZSAuST7eqWHzcnF9IR4pSA
\r
33 cDGc8ltVAB5gcvdCDYW9cwKoGxefNoeiXnTxm9RC+ifh+HhlpCi69lBoSgBnjOe4bQIp
\r
35 Received: by 10.216.90.11 with SMTP id d11mr166295wef.103.1354263800293;
\r
36 Fri, 30 Nov 2012 00:23:20 -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 gz3sm14294419wib.2.2012.11.30.00.23.19
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Fri, 30 Nov 2012 00:23:19 -0800 (PST)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 2/5] emacs: allow the tag caller to specify possible
\r
45 Date: Fri, 30 Nov 2012 08:21:28 +0000
\r
46 Message-Id: <1354263691-19715-3-git-send-email-markwalters1009@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.9.1
\r
48 In-Reply-To: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>
\r
49 References: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Fri, 30 Nov 2012 08:23:28 -0000
\r
64 From: markwalters1009 <markwalters1009@gmail.com>
\r
66 Previously notmuch tag would always query the database for possible
\r
67 tag completions (allowing all tags for + but only tags present in the
\r
68 messages being tagged for -). This allows the caller so specify these
\r
71 emacs/notmuch-tag.el | 30 +++++++++++++++++++++++-------
\r
72 1 files changed, 23 insertions(+), 7 deletions(-)
\r
74 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
75 index 1f3d8cf..c8508d1 100644
\r
76 --- a/emacs/notmuch-tag.el
\r
77 +++ b/emacs/notmuch-tag.el
\r
78 @@ -68,13 +68,18 @@ the messages that were tagged"
\r
79 (let ((tag-list (notmuch-tag-completions search-terms)))
\r
80 (completing-read prompt tag-list nil nil nil 'notmuch-select-tag-history)))
\r
82 -(defun notmuch-read-tag-changes (&optional initial-input search-terms)
\r
83 +(defun notmuch-read-tag-changes (&optional initial-input
\r
85 + negative-completions
\r
86 + positive-completions)
\r
87 (let* ((all-tag-list (notmuch-tag-completions))
\r
88 - (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))
\r
89 + (add-tag-list (mapcar (apply-partially 'concat "+")
\r
90 + (or positive-completions all-tag-list)))
\r
91 (remove-tag-list (mapcar (apply-partially 'concat "-")
\r
93 - (notmuch-tag-completions search-terms)
\r
95 + (or negative-completions
\r
97 + (notmuch-tag-completions search-terms)
\r
99 (tag-list (append add-tag-list remove-tag-list))
\r
100 (crm-separator " ")
\r
101 ;; By default, space is bound to "complete word" function.
\r
102 @@ -108,7 +113,7 @@ from TAGS if present."
\r
103 (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))
\r
104 (sort result-tags 'string<)))
\r
106 -(defun notmuch-tag (query &optional tag-changes)
\r
107 +(defun notmuch-tag (query &optional tag-changes negative-completions positive-completions)
\r
108 "Add/remove tags in TAG-CHANGES to messages matching QUERY.
\r
110 QUERY should be a string containing the search-terms.
\r
111 @@ -119,6 +124,14 @@ interpreted as a single tag change. If TAG-CHANGES is the string
\r
112 \"-\" or \"+\", or null, then the user is prompted to enter the
\r
115 +NEGATIVE-COMPLETIONS and POSITIVE-COMPLETIONS should be lists of
\r
116 +tags that should be used for tab-completion for
\r
117 +removal (i.e. after a \"-\") and addition (i.e. after a
\r
118 +\"+\") repectively. If either of these is nil the possible
\r
119 +completions will be read from the notmuch database. This does not
\r
120 +stop the removal or addition of a tag; it just changes which tags
\r
121 +can be tag-completed.
\r
123 Note: Other code should always use this function alter tags of
\r
124 messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
\r
125 directly, so that hooks specified in notmuch-before-tag-hook and
\r
126 @@ -126,7 +139,10 @@ notmuch-after-tag-hook will be run."
\r
127 ;; Perform some validation
\r
128 (if (string-or-null-p tag-changes)
\r
129 (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))
\r
130 - (setq tag-changes (notmuch-read-tag-changes tag-changes query))
\r
131 + (setq tag-changes (notmuch-read-tag-changes tag-changes
\r
133 + negative-completions
\r
134 + positive-completions))
\r
135 (setq tag-changes (list tag-changes))))
\r
136 (mapc (lambda (tag-change)
\r
137 (unless (string-match-p "^[-+]\\S-+$" tag-change)
\r