Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d0 / d666f2f649488766e36fcfd1afc7b2e6b0eff6
1 Return-Path: <dkg@fifthhorseman.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 arlo.cworth.org (Postfix) with ESMTP id 1B4C36DE1BDF\r
6  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:37 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.022\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.022 tagged_above=-999 required=5\r
12  tests=[AWL=-0.022] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id XtxFlnrWpaR1 for <notmuch@notmuchmail.org>;\r
16  Tue, 19 Jan 2016 18:53:35 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id F40E76DE1B24\r
19  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:17 -0800 (PST)\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id 270CCF99A\r
22  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:14 -0500 (EST)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id 03089207EE; Tue, 19 Jan 2016 18:53:11 -0800 (PST)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH v2 12/16] add --try-decrypt to notmuch new\r
28 Date: Tue, 19 Jan 2016 21:52:45 -0500\r
29 Message-Id: <1453258369-7366-13-git-send-email-dkg@fifthhorseman.net>\r
30 X-Mailer: git-send-email 2.7.0.rc3\r
31 In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
32 References: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.20\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37  <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
39  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Wed, 20 Jan 2016 02:53:37 -0000\r
46 \r
47 Try to decrypt any encrypted parts of newly-discovered messages while\r
48 indexing them.  The cleartext of any successfully-decrypted messages\r
49 will be indexed, with tags applied in the same form as from notmuch\r
50 insert --try-decrypt.\r
51 \r
52 If ~/.notmuch-config contains crypto.gpg_path, and gpg is needed for\r
53 indexing, the configuration option will be used to find gpg.\r
54 ---\r
55  completion/notmuch-completion.bash |  2 +-\r
56  doc/man1/notmuch-new.rst           | 10 ++++++++++\r
57  notmuch-new.c                      | 30 +++++++++++++++++++++++++++++-\r
58  3 files changed, 40 insertions(+), 2 deletions(-)\r
59 \r
60 diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
61 index 4bc9040..214f776 100644\r
62 --- a/completion/notmuch-completion.bash\r
63 +++ b/completion/notmuch-completion.bash\r
64 @@ -247,7 +247,7 @@ _notmuch_new()\r
65  \r
66      case "${cur}" in\r
67         -*)\r
68 -           local options="--no-hooks --quiet ${_notmuch_shared_options}"\r
69 +           local options="--no-hooks --try-decrypt --quiet ${_notmuch_shared_options}"\r
70             compopt -o nospace\r
71             COMPREPLY=( $(compgen -W "${options}" -- ${cur}) )\r
72             ;;\r
73 diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst\r
74 index 787ed78..cf08021 100644\r
75 --- a/doc/man1/notmuch-new.rst\r
76 +++ b/doc/man1/notmuch-new.rst\r
77 @@ -43,6 +43,16 @@ Supported options for **new** include\r
78      ``--quiet``\r
79          Do not print progress or results.\r
80  \r
81 +    ``--try-decrypt``\r
82 +\r
83 +        For each message, if it is encrypted, try to decrypt it while\r
84 +        indexing.  If decryption is successful, index the cleartext\r
85 +        itself.  Be aware that the index is likely sufficient to\r
86 +        reconstruct the cleartext of the message itself, so please\r
87 +        ensure that the notmuch message index is adequately\r
88 +        protected. DO NOT USE THIS FLAG without considering the\r
89 +        security of your index.\r
90 +\r
91  SEE ALSO\r
92  ========\r
93  \r
94 diff --git a/notmuch-new.c b/notmuch-new.c\r
95 index e503776..3d5efd5 100644\r
96 --- a/notmuch-new.c\r
97 +++ b/notmuch-new.c\r
98 @@ -49,6 +49,7 @@ typedef struct {\r
99      size_t new_tags_length;\r
100      const char **new_ignore;\r
101      size_t new_ignore_length;\r
102 +    notmuch_indexopts_t *indexopts;\r
103  \r
104      int total_files;\r
105      int processed_files;\r
106 @@ -260,7 +261,8 @@ add_file (notmuch_database_t *notmuch, const char *filename,\r
107      if (status)\r
108         goto DONE;\r
109  \r
110 -    status = notmuch_database_add_message (notmuch, filename, &message);\r
111 +    status = notmuch_database_add_message_with_indexopts (notmuch, filename,\r
112 +                                                         state->indexopts, &message);\r
113      switch (status) {\r
114      /* Success. */\r
115      case NOTMUCH_STATUS_SUCCESS:\r
116 @@ -929,6 +931,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
117      add_files_state_t add_files_state = {\r
118         .verbosity = VERBOSITY_NORMAL,\r
119         .debug = FALSE,\r
120 +       .indexopts = NULL,\r
121         .output_is_a_tty = isatty (fileno (stdout)),\r
122      };\r
123      struct timeval tv_start;\r
124 @@ -942,6 +945,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
125      unsigned int i;\r
126      notmuch_bool_t timer_is_active = FALSE;\r
127      notmuch_bool_t no_hooks = FALSE;\r
128 +    notmuch_bool_t try_decrypt = FALSE;\r
129      notmuch_bool_t quiet = FALSE, verbose = FALSE;\r
130      notmuch_status_t status;\r
131  \r
132 @@ -950,6 +954,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
133         { NOTMUCH_OPT_BOOLEAN,  &verbose, "verbose", 'v', 0 },\r
134         { NOTMUCH_OPT_BOOLEAN,  &add_files_state.debug, "debug", 'd', 0 },\r
135         { NOTMUCH_OPT_BOOLEAN,  &no_hooks, "no-hooks", 'n', 0 },\r
136 +       { NOTMUCH_OPT_BOOLEAN,  &try_decrypt, "try-decrypt", 0, 0 },\r
137         { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
138         { 0, 0, 0, 0, 0 }\r
139      };\r
140 @@ -1067,6 +1072,28 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
141      if (notmuch == NULL)\r
142         return EXIT_FAILURE;\r
143  \r
144 +    add_files_state.indexopts = notmuch_indexopts_create ();\r
145 +    if (!add_files_state.indexopts) {\r
146 +       fprintf (stderr, "Error: could not create index options.\n");\r
147 +       return EXIT_FAILURE;\r
148 +    }\r
149 +    status = notmuch_indexopts_set_try_decrypt (add_files_state.indexopts, try_decrypt);\r
150 +    if (status != NOTMUCH_STATUS_SUCCESS) {\r
151 +       fprintf (stderr, "Error: Failed to set try_decrypt to %s. (%s)\n",\r
152 +                try_decrypt ? "True" : "False", notmuch_status_to_string (status));\r
153 +       notmuch_indexopts_destroy (add_files_state.indexopts);\r
154 +       return EXIT_FAILURE;\r
155 +    }\r
156 +    if (try_decrypt) {\r
157 +       const char* gpg_path = notmuch_config_get_crypto_gpg_path (config);\r
158 +       status = notmuch_indexopts_set_gpg_path (add_files_state.indexopts, gpg_path);\r
159 +       if (status)\r
160 +           fprintf (stderr, "Warning: failed to set database gpg_path to '%s' (%s)\n",\r
161 +                    gpg_path ? gpg_path : "(NULL)",\r
162 +                    notmuch_status_to_string (status));\r
163 +    }\r
164 +\r
165 +    \r
166      /* Set up our handler for SIGINT. We do this after having\r
167       * potentially done a database upgrade we this interrupt handler\r
168       * won't support. */\r
169 @@ -1150,5 +1177,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
170      if (!no_hooks && !ret && !interrupted)\r
171         ret = notmuch_run_hook (db_path, "post-new");\r
172  \r
173 +    notmuch_indexopts_destroy (add_files_state.indexopts);\r
174      return ret || interrupted ? EXIT_FAILURE : EXIT_SUCCESS;\r
175  }\r
176 -- \r
177 2.7.0.rc3\r
178 \r