From d343f7f5386dd54749c7e0c81acd2e4e6952be60 Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 26 Aug 2017 19:47:36 -0700 Subject: [PATCH 1/3] Allow to set the reply policy in a smart manner Depending on whether the original email was encrypted, one can set different reply policies. --- mu4e/mu4e-compose.el | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 5a94814d..1b1d0c25 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -146,7 +146,7 @@ Also see `mu4e-context-policy'." :group 'mu4e-compose)) -(defcustom mu4e-compose-crypto-reply-policy 'sign-and-encrypt +(defcustom mu4e-compose-crypto-reply-encrypted-policy 'sign-and-encrypt "Policy for signing/encrypting replies to encrypted messages. We have the following choices: @@ -162,6 +162,22 @@ We have the following choices: :safe 'symbolp :group 'mu4e-compose)) +(defcustom mu4e-compose-crypto-reply-plain-encrypted-policy 'sign "Policy for signing/encrypting replies to encrypted messages. +We have the following choices: + +- `sign': sign the reply +- `sign-and-encrypt': sign and encrypt the reply +- `encrypt': encrypt the reply, but don't sign it. +- anything else: do nothing." + :type '(choice + (const :tag "Sign the reply" sign) + (const :tag "Sign and encrypt the reply" sign-and-encrypt) + (const :tag "Encrypt the reply" encrypt) + (const :tag "Don't do anything" nil) + :safe 'symbolp + :group 'mu4e-compose)) + + (defcustom mu4e-compose-format-flowed nil "Whether to compose messages to be sent as format=flowed (or with long lines if `use-hard-newlines' is set to nil). The @@ -525,13 +541,23 @@ buffers; lets remap its faces so it uses the ones for mu4e." (defun mu4e~compose-crypto-reply (parent compose-type) "When composing a reply to an encrypted message, we can -automatically encrypt that reply." - (when (and (eq compose-type 'reply) +automatically encrypt that reply. When the message is unencrypted, +we can decide what we want to do." + (message "%S %S" parent compose-type) + (if (and (eq compose-type 'reply) (and parent (member 'encrypted (mu4e-message-field parent :flags)))) - (case mu4e-compose-crypto-reply-policy + (case mu4e-compose-crypto-reply-encrypted-policy (sign (mml-secure-message-sign)) (encrypt (mml-secure-message-encrypt)) - (sign-and-encrypt (mml-secure-message-sign-encrypt))))) + (sign-and-encrypt (mml-secure-message-sign-encrypt)) + (message "Do nothing")) + (case mu4e-compose-crypto-reply-plain-policy + (sign (mml-secure-message-sign)) + (encrypt (mml-secure-message-encrypt)) + (sign-and-encrypt (mml-secure-message-sign-encrypt)) + (message "Do nothing"))) + ) + (defun* mu4e~compose-handler (compose-type &optional original-msg includes) "Create a new draft message, or open an existing one. From 5c6561873ea572b104af05015df09087275dd9fb Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 2 Sep 2017 09:13:57 -0700 Subject: [PATCH 2/3] Warning the used abot obsolete variable Following code review (PR 1118): - Warn the user about the fact that the 'mu4e-compose-crypto-reply-policy' variable is deprecated - Removed a leftover debug message - Edited typo in the name of the new variable --- mu4e/mu4e-compose.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 1b1d0c25..bc40834d 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -162,7 +162,8 @@ We have the following choices: :safe 'symbolp :group 'mu4e-compose)) -(defcustom mu4e-compose-crypto-reply-plain-encrypted-policy 'sign "Policy for signing/encrypting replies to encrypted messages. +(defcustom mu4e-compose-crypto-reply-plain-policy 'sign + "Policy for signing/encrypting replies to messages received unencrypted. We have the following choices: - `sign': sign the reply @@ -177,6 +178,12 @@ We have the following choices: :safe 'symbolp :group 'mu4e-compose)) +(make-obsolete-variable mu4e-compose-crypto-reply-policy "The use of the + 'mu4e-compose-crypto-reply-policy' variable is deprecated. + 'mu4e-compose-crypto-reply-plain-policy' and + 'mu4e-compose-crypto-reply-encrypted-policy' should be used instead" + "2017-09-02") + (defcustom mu4e-compose-format-flowed nil "Whether to compose messages to be sent as format=flowed (or @@ -543,7 +550,6 @@ buffers; lets remap its faces so it uses the ones for mu4e." "When composing a reply to an encrypted message, we can automatically encrypt that reply. When the message is unencrypted, we can decide what we want to do." - (message "%S %S" parent compose-type) (if (and (eq compose-type 'reply) (and parent (member 'encrypted (mu4e-message-field parent :flags)))) (case mu4e-compose-crypto-reply-encrypted-policy From e761f74f19b1af685fa4fc8fc93bedd4e2583e34 Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 2 Sep 2017 09:24:11 -0700 Subject: [PATCH 3/3] Warn the user about obsolete crypto-policy variable --- mu4e/mu4e-compose.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index bc40834d..e5e9241d 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -178,6 +178,10 @@ We have the following choices: :safe 'symbolp :group 'mu4e-compose)) +(defcustom mu4e-compose-crypto-reply-policy nil "The use of the + 'mu4e-compose-crypto-reply-policy' variable is deprecated. + 'mu4e-compose-crypto-reply-plain-policy' and + 'mu4e-compose-crypto-reply-encrypted-policy' should be used instead") (make-obsolete-variable mu4e-compose-crypto-reply-policy "The use of the 'mu4e-compose-crypto-reply-policy' variable is deprecated. 'mu4e-compose-crypto-reply-plain-policy' and