* epa.el (epa-decrypt-region): Confirm user to replace the region.
authorueno <ueno>
Sun, 31 Dec 2006 02:25:24 +0000 (02:25 +0000)
committerueno <ueno>
Sun, 31 Dec 2006 02:25:24 +0000 (02:25 +0000)
ChangeLog
epa.el

index 0dcf182..c423628 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
        (epa-encrypt): New command.
        (epa-import-armor-in-region): New command.
        (epa-import): New command.
+       (epa-decrypt-region): Confirm user to replace the region.
 
 2006-12-29  Daiki Ueno  <ueno@unixuser.org>
 
diff --git a/epa.el b/epa.el
index 6c48380..39ad100 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -743,12 +743,18 @@ Don't use this command in Lisp programs!"
       (message "Decrypting...")
       (setq plain (epg-decrypt-string context (buffer-substring start end)))
       (message "Decrypting...done")
-      (delete-region start end)
-      (goto-char start)
-      (insert (epa--decode-coding-string plain
-                                        (or coding-system-for-read
-                                            (get-text-property
-                                             start 'epa-coding-system-used))))
+      (setq plain (epa--decode-coding-string
+                  plain
+                  (or coding-system-for-read
+                      (get-text-property start 'epa-coding-system-used))))
+      (if (y-or-n-p "Replace the text in the region? ")
+         (let ((inhibit-read-only t)
+               buffer-read-only)
+           (delete-region start end)
+           (goto-char start)
+           (insert plain))
+       (let ((epa-popup-info-window t))
+         (epa-display-info plain)))
       (if (epg-context-result-for context 'verify)
          (epa-display-info (epg-verify-result-to-string
                             (epg-context-result-for context 'verify)))))))