Re: Error with contrib/notmuch-pick
[notmuch-archives.git] / be / 311fa8675e0bfd43df122ed3cbbb26ec33d746
1 Return-Path: <jrollins@finestructure.net>\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 ACE7E431FD0\r
6         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 11:53:07 -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: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 AYbRbk9oVtR8 for <notmuch@notmuchmail.org>;\r
16         Sat, 14 Apr 2012 11:53:05 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id ACC05431FAF\r
20         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 11:53:05 -0700 (PDT)\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by fire-doxen-postvirus (Postfix) with ESMTP id 447212E50D69\r
23         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 11:53:03 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
25 Received: from finestructure.net (unknown [76.89.193.65])\r
26         (Authenticated sender: jrollins)\r
27         by fire-doxen-submit (Postfix) with ESMTP id 771D82E50D6C\r
28         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 11:53:01 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id 2B9FF5E8; Sat, 14 Apr 2012 11:53:01 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH 2/5] emacs: allow notmuch-tag to accept string inputs and\r
34         prompt for tags\r
35 Date: Sat, 14 Apr 2012 11:52:51 -0700\r
36 Message-Id: <1334429574-12918-3-git-send-email-jrollins@finestructure.net>\r
37 X-Mailer: git-send-email 1.7.9.5\r
38 In-Reply-To: <1334429574-12918-2-git-send-email-jrollins@finestructure.net>\r
39 References: <1333845338-22960-1-git-send-email-jrollins@finestructure.net>\r
40         <1334429574-12918-1-git-send-email-jrollins@finestructure.net>\r
41         <1334429574-12918-2-git-send-email-jrollins@finestructure.net>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Sat, 14 Apr 2012 18:53:07 -0000\r
55 \r
56 notmuch-tag is extended to accept various formats of the tag changes.\r
57 In particular, user prompting for tag changes is now incorporated\r
58 here, so it is common for modes.\r
59 \r
60 The tag binary and the notmuch-{before,after}-tag-hooks are only\r
61 called if tag changes is non-nil.\r
62 \r
63 The actual tag-changes applied are returned by the function.\r
64 ---\r
65  emacs/notmuch-tag.el |   20 +++++++++++++++-----\r
66  1 file changed, 15 insertions(+), 5 deletions(-)\r
67 \r
68 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
69 index c25cff8..dd7f9d7 100644\r
70 --- a/emacs/notmuch-tag.el\r
71 +++ b/emacs/notmuch-tag.el\r
72 @@ -108,18 +108,26 @@ from TAGS if present."\r
73            (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))\r
74      (sort result-tags 'string<)))\r
75  \r
76 -(defun notmuch-tag (query &rest tag-changes)\r
77 +(defun notmuch-tag (query &optional tag-changes)\r
78    "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
79  \r
80 -TAG-CHANGES should be a list of strings of the form \"+tag\" or\r
81 -\"-tag\" and QUERY should be a string containing the\r
82 -search-query.\r
83 +QUERY should be a string containing the search-terms.\r
84 +TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of\r
85 +strings of the form \"+tag\" or \"-tag\" then those are the tag\r
86 +changes applied.  If TAG-CHANGES is a string then it is\r
87 +interpreted as a single tag change.  If TAG-CHANGES is the string\r
88 +\"-\" or \"+\", or null, then the user is prompted to enter the\r
89 +tag changes.\r
90  \r
91  Note: Other code should always use this function alter tags of\r
92  messages instead of running (notmuch-call-notmuch-process \"tag\" ..)\r
93  directly, so that hooks specified in notmuch-before-tag-hook and\r
94  notmuch-after-tag-hook will be run."\r
95    ;; Perform some validation\r
96 +  (if (string-or-null-p tag-changes)\r
97 +      (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))\r
98 +         (setq tag-changes (notmuch-read-tag-changes tag-changes query))\r
99 +       (setq tag-changes (list tag-changes))))\r
100    (mapc (lambda (tag-change)\r
101           (unless (string-match-p "^[-+]\\S-+$" tag-change)\r
102             (error "Tag must be of the form `+this_tag' or `-that_tag'")))\r
103 @@ -128,7 +136,9 @@ notmuch-after-tag-hook will be run."\r
104      (run-hooks 'notmuch-before-tag-hook)\r
105      (apply 'notmuch-call-notmuch-process "tag"\r
106            (append tag-changes (list "--" query)))\r
107 -    (run-hooks 'notmuch-after-tag-hook)))\r
108 +    (run-hooks 'notmuch-after-tag-hook))\r
109 +  ;; return the list of actual changed tags\r
110 +  tag-changes)\r
111  \r
112  ;;\r
113  \r
114 -- \r
115 1.7.9.5\r
116 \r