Fix bug #14842 with doc strings of next-line and previous-line.
[bpt/emacs.git] / lisp / epa.el
index ecc27c4..14f8879 100644 (file)
@@ -1,6 +1,6 @@
 ;;; epa.el --- the EasyPG Assistant -*- lexical-binding: t -*-
 
-;; Copyright (C) 2006-201 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Keywords: PGP, GnuPG
@@ -169,6 +169,7 @@ You should bind this variable with `let', but do not set it globally.")
     (define-key keymap "n" 'next-line)
     (define-key keymap "p" 'previous-line)
     (define-key keymap " " 'scroll-up-command)
+    (define-key keymap [?\S-\ ] 'scroll-down-command)
     (define-key keymap [delete] 'scroll-down-command)
     (define-key keymap "q" 'epa-exit-buffer)
     (define-key keymap [menu-bar epa-key-list-mode] (cons "Keys" menu-map))
@@ -619,31 +620,37 @@ 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 (file)
-  "Decrypt FILE."
-  (interactive "fFile: ")
-  (setq file (expand-file-name file))
-  (let* ((default-name (file-name-sans-extension file))
-        (plain (expand-file-name
-                (read-file-name
-                 (concat "To file (default "
-                         (file-name-nondirectory default-name)
-                         ") ")
-                 (file-name-directory default-name)
-                 default-name)))
-        (context (epg-make-context epa-protocol)))
+(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 (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
                                         #'epa-passphrase-callback-function)
     (epg-context-set-progress-callback context
                                       (cons
                                        #'epa-progress-callback-function
                                        (format "Decrypting %s..."
-                                               (file-name-nondirectory file))))
-    (message "Decrypting %s..." (file-name-nondirectory file))
-    (epg-decrypt-file context file plain)
-    (message "Decrypting %s...wrote %s" (file-name-nondirectory file)
-            (file-name-nondirectory plain))
+                                               (file-name-nondirectory decrypt-file))))
+    (message "Decrypting %s..." (file-name-nondirectory decrypt-file))
+    (epg-decrypt-file context decrypt-file plain-file)
+    (message "Decrypting %s...wrote %s" (file-name-nondirectory decrypt-file)
+            (file-name-nondirectory plain-file))
     (if (epg-context-result-for context 'verify)
        (epa-display-info (epg-verify-result-to-string
                           (epg-context-result-for context 'verify))))))