GNU bug report logs - #21947
24.5; epa: option for always replace encrypted text without asking

Previous Next

Package: emacs;

Reported by: Christian Schwarzgruber <c.schwarzgruber.cs <at> gmail.com>

Date: Tue, 17 Nov 2015 22:18:02 UTC

Severity: wishlist

Tags: patch

Found in version 24.5

Done: Daiki Ueno <ueno <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Christian Schwarzgruber <c.schwarzgruber.cs <at> gmail.com>
To: Daiki Ueno <ueno <at> gnu.org>
Cc: 21947 <at> debbugs.gnu.org
Subject: bug#21947: 24.5; epa: option for always replace encrypted text without asking
Date: Wed, 18 Nov 2015 22:39:43 +0100
[Message part 1 (text/plain, inline)]
I made all the changes, hope I did it the way you guys want it (see inline patch).

I tested all possible options, with `epa-decrypt-region', as well as
epa-verify-region.

Daiki Ueno <ueno <at> gnu.org> writes:

> Christian Schwarzgruber <c.schwarzgruber.cs <at> gmail.com> writes:
>
>> When I get a new encrypted email and I hit `C-c C-e d' (epa-mail-decrypt) epa
>> asks, if I want replace the original text. Which in my opinion is a bit
>> superfluous in this case. This will become especially unpleasant once the
>> auto-decrypt functionality is implemented in mu/mu4e.
>
> That sounds reasonable.
>
>> So I patched epa.el and added a boolean `defcustom', when set to `t',
>> the text will always be replaced without asking.
>
> I tend to make this a choice of three: never (nil), ask (a symbol),
> always (t).  Would that make sense?
>
> Also please adjust `epa-verify-region' as well.
>
> Regards,

Regards,
--
Christian Schwarzgruber
[0001-lisp-epa.el-add-defcustom-to-replace-original-text.patch (text/x-patch, inline)]
From 9041f5bbe05cbf28dafdfb31f6f731e9ea7e023c Mon Sep 17 00:00:00 2001
From: Christian Schwarzgruber <c.schwarzgruber.cs <at> gmail.com>
Date: Sun, 15 Nov 2015 22:31:41 +0100
Subject: [PATCH] lisp/epa.el: add `defcustom' to replace original text

Possible options are: `ask', `always', `never'. Default is `ask'.
---
 lisp/epa.el | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lisp/epa.el b/lisp/epa.el
index 9f112c4..794fa5f 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -34,6 +34,15 @@ epa
   :link '(custom-manual "(epa) Top")
   :group 'epg)
 
+(defcustom epa-replace-original-text 'ask
+  "Whether the original text shall be replaced by the decrypted.
+
+Possible options are: `never', `ask' and `always'."
+  :type '(choice (const :tag "never" nil)
+		 (const ask)
+		 (const :tag "always" t))
+  :group 'epa)
+
 (defcustom epa-popup-info-window t
   "If non-nil, display status information from epa commands in another window."
   :type 'boolean
@@ -872,7 +881,11 @@ epa-decrypt-region
 	  (with-current-buffer (funcall make-buffer-function)
 	    (let ((inhibit-read-only t))
 	      (insert plain)))
-	(if (y-or-n-p "Replace the original text? ")
+	(if (cond
+	     ((eq 'ask epa-replace-original-text)
+	      (y-or-n-p "Replace the original text? "))
+	     ((null epa-replace-original-text) nil)
+	     (t t))
 	    (let ((inhibit-read-only t))
 	      (delete-region start end)
 	      (goto-char start)
@@ -968,7 +981,11 @@ epa-verify-region
 		 (or coding-system-for-read
 		     (get-text-property start 'epa-coding-system-used)
 		     'undecided)))
-    (if (y-or-n-p "Replace the original text? ")
+    (if (cond
+	 ((eq 'ask epa-replace-original-text)
+	  (y-or-n-p "Replace the original text? "))
+	 ((null epa-replace-original-text) nil)
+	 (t t))
 	(let ((inhibit-read-only t)
 	      buffer-read-only)
 	  (delete-region start end)
-- 
2.5.0


This bug report was last modified 8 years and 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.