[PATCH] RFC: all deleting all properties with a given key
[notmuch-archives.git] / 7a / f1a4fb032f3e5440ed8d0576e943c51d1f47b3
1 Return-Path: <jani@nikula.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 45168431FC2\r
6         for <notmuch@notmuchmail.org>; Sun, 28 Sep 2014 07:41:28 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id S4KCSe1y-5Et for <notmuch@notmuchmail.org>;\r
17         Sun, 28 Sep 2014 07:41:24 -0700 (PDT)\r
18 Received: from mail-we0-f169.google.com (mail-we0-f169.google.com\r
19         [74.125.82.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id AA5CE431FCF\r
22         for <notmuch@notmuchmail.org>; Sun, 28 Sep 2014 07:41:17 -0700 (PDT)\r
23 Received: by mail-we0-f169.google.com with SMTP id k48so11672073wev.14\r
24         for <notmuch@notmuchmail.org>; Sun, 28 Sep 2014 07:41:16 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
28         :references:in-reply-to:references;\r
29         bh=uXHyNvzC1EKNVDpwXmY8mTyWGcVtfmKQExXaUgnePFs=;\r
30         b=jdQjN4n8w1TSzvloB+Fazzvcuk0tQk4NzZ7PknGGyhKo6V91RS3IBUxjXySxt0xytM\r
31         mgiKT9sKRNkREtBzeRoM5yerL83vXl2tFLc2h4bJYJZSAJ6NBXZ9g28IQSXZFeIjllkj\r
32         EziE6nq843rmmRbzHE39WCYXJDSVC7CTkqniR5848DHBEVFU5w8fbDA5HSRAekz+xb4+\r
33         hYG513HxkRXP+T9pnZ6cn3P0jDHQOR7p9WBHQG+oSsI2Ul+wkwyYseorNm2kcYhfJpsj\r
34         dcUjAxFxRr8jLp9V0Jq5M1L0dgIqeqEdthqyHa/nxIzsvmMpPJ8XR93Kz4nTumX00nOq\r
35         uxmA==\r
36 X-Gm-Message-State:\r
37  ALoCoQmZfnnG8FPiChrzepwBNRmfq9Soo4AG8D/XUkYXv9d5I91gkiXrab8wGk8uiUvwepoTSuYi\r
38 X-Received: by 10.180.231.9 with SMTP id tc9mr38535943wic.58.1411915276495;\r
39         Sun, 28 Sep 2014 07:41:16 -0700 (PDT)\r
40 Received: from localhost (dsl-hkibrasgw2-58c36c-245.dhcp.inet.fi.\r
41         [88.195.108.245])\r
42         by mx.google.com with ESMTPSA id mx5sm8702900wic.0.2014.09.28.07.41.15\r
43         for <multiple recipients>\r
44         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
45         Sun, 28 Sep 2014 07:41:15 -0700 (PDT)\r
46 From: Jani Nikula <jani@nikula.org>\r
47 To: notmuch@notmuchmail.org\r
48 Subject: [PATCH v2 3/3] cli/insert: add post-insert hook\r
49 Date: Sun, 28 Sep 2014 17:40:59 +0300\r
50 Message-Id:\r
51  <27c7ada91f96deda6e51732e0397bffd2ef2ab42.1411914914.git.jani@nikula.org>\r
52 X-Mailer: git-send-email 2.1.0\r
53 In-Reply-To: <cover.1411914914.git.jani@nikula.org>\r
54 References: <cover.1411914914.git.jani@nikula.org>\r
55 In-Reply-To: <cover.1411914914.git.jani@nikula.org>\r
56 References: <cover.1411914914.git.jani@nikula.org>\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Sun, 28 Sep 2014 14:41:28 -0000\r
70 \r
71 The post-new hook might no longer be needed or run very often if\r
72 notmuch insert is being used. Therefore a post-insert hook is needed\r
73 (arguably pre-insert not so much, so don't add one). Also add the\r
74 --no-hooks option to skip hooks.\r
75 ---\r
76  doc/man1/notmuch-insert.rst |  9 +++++++++\r
77  doc/man5/notmuch-hooks.rst  | 11 +++++++++++\r
78  notmuch-insert.c            |  7 +++++++\r
79  3 files changed, 27 insertions(+)\r
80 \r
81 diff --git a/doc/man1/notmuch-insert.rst b/doc/man1/notmuch-insert.rst\r
82 index e396f6cf2279..2c9c0d02c251 100644\r
83 --- a/doc/man1/notmuch-insert.rst\r
84 +++ b/doc/man1/notmuch-insert.rst\r
85 @@ -25,6 +25,9 @@ If the new message is a duplicate of an existing message in the database\r
86  (it has same Message-ID), it will be added to the maildir folder and\r
87  notmuch database, but the tags will not be changed.\r
88  \r
89 +The **insert** command supports hooks. See **notmuch-hooks(5)** for\r
90 +more details on hooks.\r
91 +\r
92  Option arguments must appear before any tag operation arguments.\r
93  Supported options for **insert** include\r
94  \r
95 @@ -44,6 +47,9 @@ Supported options for **insert** include\r
96          fails. Ignore these errors and return exit status 0 to\r
97          indicate succesful mail delivery.\r
98  \r
99 +    ``--no-hooks``\r
100 +        Prevent hooks from being run.\r
101 +\r
102  EXIT STATUS\r
103  ===========\r
104  \r
105 @@ -54,6 +60,9 @@ indexing to Notmuch database, changing tags, and synchronizing tags to\r
106  maildir flags. The ``--keep`` option may be used to settle for\r
107  successful message file delivery.\r
108  \r
109 +The exit status of the **post-insert** hook does not affect the exit\r
110 +status of the **insert** command.\r
111 +\r
112  SEE ALSO\r
113  ========\r
114  \r
115 diff --git a/doc/man5/notmuch-hooks.rst b/doc/man5/notmuch-hooks.rst\r
116 index 493abf20f003..f1c2528c5666 100644\r
117 --- a/doc/man5/notmuch-hooks.rst\r
118 +++ b/doc/man5/notmuch-hooks.rst\r
119 @@ -35,6 +35,17 @@ The currently available hooks are described below.\r
120          Typically this hook is used to perform additional query-based\r
121          tagging on the imported messages.\r
122  \r
123 +    **post-insert**\r
124 +\r
125 +        This hook is invoked by the **insert** command after the\r
126 +        message has been delivered, added to the database, and initial\r
127 +        tags have been applied. The hook will not be run if there have\r
128 +        been any errors during the message delivery; what is regarded\r
129 +        as succesful delivery depends on the ``--keep`` option.\r
130 +\r
131 +        Typically this hook is used to perform additional query-based\r
132 +        tagging on the delivered messages.\r
133 +\r
134  SEE ALSO\r
135  ========\r
136  \r
137 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
138 index 7074077ca699..e9d71efa1fb6 100644\r
139 --- a/notmuch-insert.c\r
140 +++ b/notmuch-insert.c\r
141 @@ -454,6 +454,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
142      const char *folder = NULL;\r
143      notmuch_bool_t create_folder = FALSE;\r
144      notmuch_bool_t keep = FALSE;\r
145 +    notmuch_bool_t no_hooks = FALSE;\r
146      notmuch_bool_t synchronize_flags;\r
147      const char *maildir;\r
148      char *newpath;\r
149 @@ -464,6 +465,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
150         { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },\r
151         { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },\r
152         { NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },\r
153 +       { NOTMUCH_OPT_BOOLEAN,  &no_hooks, "no-hooks", 'n', 0 },\r
154         { NOTMUCH_OPT_END, 0, 0, 0, 0 }\r
155      };\r
156  \r
157 @@ -565,5 +567,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
158         }\r
159      }\r
160  \r
161 +    if (! no_hooks && status == NOTMUCH_STATUS_SUCCESS) {\r
162 +       /* Ignore hook failures. */\r
163 +       notmuch_run_hook (db_path, "post-insert");\r
164 +    }\r
165 +\r
166      return status ? EXIT_FAILURE : EXIT_SUCCESS;\r
167  }\r
168 -- \r
169 2.1.0\r
170 \r