]> git.notmuchmail.org Git - notmuch/commitdiff
cli/reply: make --decrypt take a keyword
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Tue, 19 Dec 2017 16:40:55 +0000 (11:40 -0500)
committerDavid Bremner <david@tethera.net>
Fri, 29 Dec 2017 20:45:55 +0000 (16:45 -0400)
This brings the --decrypt argument to "notmuch reply" into line with
the other --decrypt arguments (in "show", "new", "insert", and
"reindex").  This patch is really just about bringing consistency to
the user interface.

We also use the recommended form in the emacs MUA when replying, and
update test T350 to match.

completion/notmuch-completion.bash
doc/man1/notmuch-reply.rst
emacs/notmuch-mua.el
notmuch-reply.c
test/T350-crypto.sh

index 17f3c5ec0d409de7cda94b10afab0955ac9027a6..249b9664259cf3206a0b1d1f16f2abfae5e17c5b 100644 (file)
@@ -351,7 +351,7 @@ _notmuch_reply()
            return
            ;;
        --decrypt)
            return
            ;;
        --decrypt)
-           COMPREPLY=( $( compgen -W "true false" -- "${cur}" ) )
+           COMPREPLY=( $( compgen -W "true auto false" -- "${cur}" ) )
            return
            ;;
     esac
            return
            ;;
     esac
index ede779306c0e80888ee773754b72e78b0792cbaa..1b62e075c29689a561d94be970db20bf12b8d474 100644 (file)
@@ -72,20 +72,26 @@ Supported options for **reply** include
             in this order, and copy values from the first that contains
             something other than only the user's addresses.
 
             in this order, and copy values from the first that contains
             something other than only the user's addresses.
 
-    ``--decrypt``
-        Decrypt any MIME encrypted parts found in the selected content
-        (ie. "multipart/encrypted" parts). Status of the decryption will
-        be reported (currently only supported with --format=json and
-        --format=sexp) and on successful decryption the
-        multipart/encrypted part will be replaced by the decrypted
-        content.
-
-        If a session key is already known for the message, then it
-        will be decrypted automatically unless the user explicitly
-        sets ``--decrypt=false``.
-
-        Decryption expects a functioning **gpg-agent(1)** to provide any
-        needed credentials. Without one, the decryption will likely fail.
+    ``--decrypt=(false|auto|true)``
+
+        If ``true``, decrypt any MIME encrypted parts found in the
+        selected content (i.e., "multipart/encrypted" parts). Status
+        of the decryption will be reported (currently only supported
+        with --format=json and --format=sexp), and on successful
+        decryption the multipart/encrypted part will be replaced by
+        the decrypted content.
+
+        If ``auto``, and a session key is already known for the
+        message, then it will be decrypted, but notmuch will not try
+        to access the user's secret keys.
+
+        Use ``false`` to avoid even automatic decryption.
+
+        Non-automatic decryption expects a functioning
+        **gpg-agent(1)** to provide any needed credentials. Without
+        one, the decryption will likely fail.
+
+        Default: ``auto``
 
 See **notmuch-search-terms(7)** for details of the supported syntax for
 <search-terms>.
 
 See **notmuch-search-terms(7)** for details of the supported syntax for
 <search-terms>.
index 7a341ebf0588a3e91ee3666b119701be2ca91c8f..59b546a65f072b18420e80aced14f22f938fac87 100644 (file)
@@ -181,7 +181,7 @@ mutiple parts get a header."
        reply
        original)
     (when process-crypto
        reply
        original)
     (when process-crypto
-      (setq args (append args '("--decrypt"))))
+      (setq args (append args '("--decrypt=true"))))
 
     (if reply-all
        (setq args (append args '("--reply-to=all")))
 
     (if reply-all
        (setq args (append args '("--reply-to=all")))
index 5cdf642be2ce276fd47630fec3df92cf4fa89e16..75cf7ecb5068534df678e37fd0a606cd6215739e 100644 (file)
@@ -704,8 +704,6 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
     };
     int format = FORMAT_DEFAULT;
     int reply_all = true;
     };
     int format = FORMAT_DEFAULT;
     int reply_all = true;
-    bool decrypt = false;
-    bool decrypt_set = false;
 
     notmuch_opt_desc_t options[] = {
        { .opt_keyword = &format, .name = "format", .keywords =
 
     notmuch_opt_desc_t options[] = {
        { .opt_keyword = &format, .name = "format", .keywords =
@@ -719,7 +717,12 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
          (notmuch_keyword_t []){ { "all", true },
                                  { "sender", false },
                                  { 0, 0 } } },
          (notmuch_keyword_t []){ { "all", true },
                                  { "sender", false },
                                  { 0, 0 } } },
-       { .opt_bool = &decrypt, .name = "decrypt", .present = &decrypt_set },
+       { .opt_keyword = (int*)(&params.crypto.decrypt), .name = "decrypt",
+         .keyword_no_arg_value = "true", .keywords =
+         (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
+                                 { "auto", NOTMUCH_DECRYPT_AUTO },
+                                 { "true", NOTMUCH_DECRYPT_NOSTASH },
+                                 { 0, 0 } } },
        { .opt_inherit = notmuch_shared_options },
        { }
     };
        { .opt_inherit = notmuch_shared_options },
        { }
     };
@@ -729,8 +732,6 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
        return EXIT_FAILURE;
 
     notmuch_process_shared_options (argv[0]);
        return EXIT_FAILURE;
 
     notmuch_process_shared_options (argv[0]);
-    if (decrypt_set)
-       params.crypto.decrypt = decrypt ? NOTMUCH_DECRYPT_NOSTASH : NOTMUCH_DECRYPT_FALSE;
 
     notmuch_exit_if_unsupported_format ();
 
 
     notmuch_exit_if_unsupported_format ();
 
index 761ff55344d5c7a13984c4fb6396c9d7f973cc74..a776ec35043b324efd1c38572ff18683b0afd960 100755 (executable)
@@ -384,7 +384,7 @@ test_expect_equal_json \
     "$expected"
 
 test_begin_subtest "reply to encrypted message"
     "$expected"
 
 test_begin_subtest "reply to encrypted message"
-output=$(notmuch reply --decrypt subject:"test encrypted message 002" \
+output=$(notmuch reply --decrypt=true subject:"test encrypted message 002" \
     | notmuch_drop_mail_headers In-Reply-To References)
 expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>
 Subject: Re: test encrypted message 002
     | notmuch_drop_mail_headers In-Reply-To References)
 expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>
 Subject: Re: test encrypted message 002