Fixed.
[elisp/epg.git] / epa.el
diff --git a/epa.el b/epa.el
index d5a5eba..3a2c3ae 100644 (file)
--- a/epa.el
+++ b/epa.el
          (if key
              (list key))))))
 
-(defun epa-select-keys (context prompt &optional names mode)
+;;;###autoload
+(defun epa-select-keys (context prompt &optional names secret)
+  "Display a user's keyring and ask him to select keys.
+CONTEXT is an epg-context.
+PROMPT is a string to prompt with.
+NAMES is a list of strings to be matched with keys.  If it is nil, all
+the keys are listed.
+If SECRET is non-nil, list secret keys instead of public keys."
   (save-excursion
     (unless (and epa-keys-buffer
                 (buffer-live-p epa-keys-buffer))
       (if names
          (while names
            (setq point (point))
-           (epa-list-keys-1 context (car names) mode)
+           (epa-list-keys-1 context (car names) secret)
            (goto-char point)
            (epa-mark)
            (goto-char (point-max))
            (setq names (cdr names)))
-       (epa-list-keys-1 context nil mode))
+       (epa-list-keys-1 context nil secret))
       (epa-keys-mode)
       (setq epa-exit-buffer-function #'abort-recursive-edit)
       (goto-char (point-min))
-      (pop-to-buffer (current-buffer))
-      (unwind-protect
+      (pop-to-buffer (current-buffer)))
+    (unwind-protect
          (progn
            (recursive-edit)
            (epa-marked-keys))
        (if (get-buffer-window epa-keys-buffer)
            (delete-window (get-buffer-window epa-keys-buffer)))
-       (kill-buffer epa-keys-buffer)))))
+       (kill-buffer epa-keys-buffer))))
 
 (defun epa-show-key (key)
   (let* ((primary-sub-key (car (epg-key-sub-key-list key)))
   (epa-show-key (widget-get widget :value)))
 
 (defun epa-mark (&optional arg)
-  "Mark the current line."
+  "Mark the current line.
+If ARG is non-nil, unmark the current line."
   (interactive "P")
   (let ((inhibit-read-only t)
        buffer-read-only
     (forward-line)))
 
 (defun epa-unmark (&optional arg)
-  "Unmark the current line."
+  "Unmark the current line.
+If ARG is non-nil, mark the current line."
   (interactive "P")
   (epa-mark (not arg)))
 
 (defun epa-exit-buffer ()
+  "Exit the current buffer.
+`epa-exit-buffer-function' is called if it is set."
   (interactive)
   (funcall epa-exit-buffer-function))
 
+;;;###autoload
 (defun epa-decrypt-file (file)
+  "Decrypt FILE."
   (interactive "fFile: ")
   (let* ((default-name (file-name-sans-extension file))
         (plain (expand-file-name
     (epg-decrypt-file context file plain)
     (message "Decrypting %s...done" (file-name-nondirectory file))))
 
+;;;###autoload
 (defun epa-verify-file (file)
+  "Verify FILE."
   (interactive "fFile: ")
   (let* ((context (epg-make-context))
         (plain (if (equal (file-name-extension file) "sig")
             (epg-verify-result-to-string
              (epg-context-result-for context 'verify)))))
 
-(defun epa-sign-file (file detached)
+;;;###autoload
+(defun epa-sign-file (file signers detached)
+  "Sign FILE by selected SIGNERS keys.
+If DETACHED is non-nil, it creates a detached signature."
   (interactive
    (list (expand-file-name (read-file-name "File: "))
+        (epa-select-keys (epg-make-context) "Select keys for signing.
+If no one is selected, default secret key is used.  "
+                         nil t)
         (y-or-n-p "Make a detached signature? ")))
   (let ((signature (concat file (if detached ".sig" ".gpg")))
        (context (epg-make-context)))
     (message "Signing %s..." (file-name-nondirectory file))
+    (epg-context-set-signers context signers)
     (epg-sign-file context file signature (not (null detached)))
     (message "Signing %s...done" (file-name-nondirectory file))))
 
+;;;###autoload
 (defun epa-encrypt-file (file recipients)
+  "Encrypt FILE for RECIPIENTS."
   (interactive
    (list (expand-file-name (read-file-name "File: "))
         (epa-select-keys (epg-make-context) "Select recipents for encryption.
@@ -497,7 +521,9 @@ If no one is selected, symmetric encryption will be performed.  ")))
     (epg-encrypt-file context file recipients cipher)
     (message "Encrypting %s...done" (file-name-nondirectory file))))
 
+;;;###autoload
 (defun epa-delete-keys (keys)
+  "Delete selected KEYS."
   (interactive
    (let ((keys (epa-marked-keys)))
      (unless keys
@@ -509,7 +535,9 @@ If no one is selected, symmetric encryption will be performed.  ")))
     (apply #'epa-list-keys epa-list-keys-arguments)
     (message "Deleting...done")))
 
+;;;###autoload
 (defun epa-import-keys (file)
+  "Import keys from FILE."
   (interactive "fFile: ")
   (let ((context (epg-make-context)))
     (message "Importing %s..." (file-name-nondirectory file))
@@ -517,7 +545,9 @@ If no one is selected, symmetric encryption will be performed.  ")))
     (apply #'epa-list-keys epa-list-keys-arguments)
     (message "Importing %s...done" (file-name-nondirectory file))))
 
+;;;###autoload
 (defun epa-export-keys (keys file)
+  "Export selected KEYS to FILE."
   (interactive
    (let ((keys (epa-marked-keys))
         default-name)
@@ -541,7 +571,10 @@ If no one is selected, symmetric encryption will be performed.  ")))
     (epg-export-keys-to-file context keys file)
     (message "Exporting to %s...done" (file-name-nondirectory file))))
 
+;;;###autoload
 (defun epa-sign-keys (keys &optional local)
+  "Sign selected KEYS.
+If LOCAL is non-nil, the signature is marked as non exportable."
   (interactive
    (let ((keys (epa-marked-keys)))
      (unless keys