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