From ff4871b986a082a4b21867827e460c50bfa0cb09 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 9 Jun 2013 17:32:49 -0700 Subject: [PATCH] * lisp/epa.el (epa-read-file-name): New function. (epa-decrypt-file): Make plain-file optional. Use epa-read-file-name. * doc/misc/epa.texi (Cryptographic operations on files): Update epa-decrypt-file. Fixes: debbugs:14510 --- doc/misc/ChangeLog | 4 ++++ doc/misc/epa.texi | 5 +++-- lisp/ChangeLog | 5 +++++ lisp/epa.el | 27 +++++++++++++++------------ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index bcd3fe78ae8..ce2852e90f8 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,7 @@ +2013-06-10 Glenn Morris + + * epa.texi (Cryptographic operations on files): Update epa-decrypt-file. + 2013-06-04 Katsumi Yamaoka * gnus.texi (Article Date): diff --git a/doc/misc/epa.texi b/doc/misc/epa.texi index e21851ef37a..adc63cc0bdb 100644 --- a/doc/misc/epa.texi +++ b/doc/misc/epa.texi @@ -240,8 +240,9 @@ you answered yes, it will let you select the signing keys. @node Cryptographic operations on files @section Cryptographic operations on files -@deffn Command epa-decrypt-file file -Decrypt @var{file}. +@deffn Command epa-decrypt-file file &optional output +Decrypt @var{file}. If you do not specify the name @var{output} to +use for the decrypted file, this function prompts for the value to use. @end deffn @deffn Command epa-verify-file file diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b7173c5cacf..02316659220 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-06-10 Glenn Morris + + * epa.el (epa-read-file-name): New function. (Bug#14510) + (epa-decrypt-file): Make plain-file optional. Use epa-read-file-name. + 2013-06-09 Aidan Gauland * eshell/em-term.el (eshell-visual-command-p): Fix bug that caused diff --git a/lisp/epa.el b/lisp/epa.el index b567df5f40b..14f8879c1c6 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -620,21 +620,24 @@ If SECRET is non-nil, list secret keys instead of public keys." (floor (* (/ current (float total)) 100)))) (message "%s..." prompt)))) +(defun epa-read-file-name (input) + "Interactively read an output file name based on INPUT file name." + (setq input (file-name-sans-extension (expand-file-name input))) + (expand-file-name + (read-file-name + (concat "To file (default " (file-name-nondirectory input) ") ") + (file-name-directory input) + input))) + ;;;###autoload -(defun epa-decrypt-file (decrypt-file plain-file) - "Decrypt DECRYPT-FILE into PLAIN-FILE." +(defun epa-decrypt-file (decrypt-file &optional plain-file) + "Decrypt DECRYPT-FILE into PLAIN-FILE. +If you do not specify PLAIN-FILE, this functions prompts for the value to use." (interactive - (let (file default-name plain) - (setq file (read-file-name "File to decrypt: ")) - (setq default-name (file-name-sans-extension (expand-file-name file))) - (setq plain (expand-file-name - (read-file-name - (concat "To file (default " - (file-name-nondirectory default-name) - ") ") - (file-name-directory default-name) - default-name))) + (let* ((file (read-file-name "File to decrypt: ")) + (plain (epa-read-file-name file))) (list file plain))) + (or plain-file (setq plain-file (epa-read-file-name decrypt-file))) (setq decrypt-file (expand-file-name decrypt-file)) (let ((context (epg-make-context epa-protocol))) (epg-context-set-passphrase-callback context -- 2.39.2