From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 004106DE0962 for ; Mon, 11 Dec 2017 22:52:59 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.027 X-Spam-Level: X-Spam-Status: No, score=-0.027 tagged_above=-999 required=5 tests=[AWL=-0.027] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5i1h2y-34xSV for ; Mon, 11 Dec 2017 22:52:57 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id A70396DE0941 for ; Mon, 11 Dec 2017 22:52:57 -0800 (PST) Received: from fifthhorseman.net (unknown [38.109.115.130]) by che.mayfirst.org (Postfix) with ESMTPSA id BFB85F99A for ; Tue, 12 Dec 2017 01:52:56 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id DE43F20D1F; Tue, 12 Dec 2017 01:52:52 -0500 (EST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v2] cli/reply: make --decrypt take a keyword Date: Tue, 12 Dec 2017 01:52:52 -0500 Message-Id: <20171212065252.24962-1-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171212001858.706-4-dkg@fifthhorseman.net> References: <20171212001858.706-4-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2017 06:52:59 -0000 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 | 2 +- doc/man1/notmuch-reply.rst | 34 ++++++++++++++++++++-------------- emacs/notmuch-mua.el | 2 +- notmuch-reply.c | 11 ++++++----- test/T350-crypto.sh | 2 +- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index 4ab2e5f6..a24b8a08 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -351,7 +351,7 @@ _notmuch_reply() return ;; --decrypt) - COMPREPLY=( $( compgen -W "true false" -- "${cur}" ) ) + COMPREPLY=( $( compgen -W "true auto false" -- "${cur}" ) ) return ;; esac diff --git a/doc/man1/notmuch-reply.rst b/doc/man1/notmuch-reply.rst index ede77930..1b62e075 100644 --- a/doc/man1/notmuch-reply.rst +++ b/doc/man1/notmuch-reply.rst @@ -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. - ``--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 . diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 7a341ebf..59b546a6 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -181,7 +181,7 @@ mutiple parts get a header." 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"))) diff --git a/notmuch-reply.c b/notmuch-reply.c index 5cdf642b..75cf7ecb 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -704,8 +704,6 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) }; 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 = @@ -719,7 +717,12 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) (notmuch_keyword_t []){ { "all", true }, { "sender", false }, { 0, 0 } } }, - { .opt_bool = &decrypt, .name = "decrypt", .present = &decrypt_set }, + { .opt_keyword = (int*)(¶ms.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 }, { } }; @@ -729,8 +732,6 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) 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 (); diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh index 761ff553..a776ec35 100755 --- a/test/T350-crypto.sh +++ b/test/T350-crypto.sh @@ -384,7 +384,7 @@ test_expect_equal_json \ "$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 Subject: Re: test encrypted message 002 -- 2.15.1