Update.
[elisp/epg.git] / epa.el
diff --git a/epa.el b/epa.el
index 66e0d3a..0967286 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -330,43 +330,6 @@ If ARG is non-nil, mark the current line."
   (interactive)
   (funcall epa-exit-buffer-function))
 
-;;;###autoload
-(defun epa-list-keys (&optional name mode)
-  "List all keys matched with NAME from the keyring.
-If MODE is non-nil, it reads the private keyring.  Otherwise, it
-reads the public keyring."
-  (interactive
-   (if current-prefix-arg
-       (let ((name (read-string "Pattern: "
-                               (if epa-list-keys-arguments
-                                   (car epa-list-keys-arguments)))))
-        (list (if (equal name "") nil name)
-              (y-or-n-p "Secret keys? ")))
-     (or epa-list-keys-arguments (list nil nil))))
-  (unless (and epa-keys-buffer
-              (buffer-live-p epa-keys-buffer))
-    (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
-  (set-buffer epa-keys-buffer)
-  (epa-key-list-mode)
-  (let ((inhibit-read-only t)
-       buffer-read-only
-       (point (point-min))
-       (context (epg-make-context epa-protocol)))
-    (unless (get-text-property point 'epa-list-keys)
-      (setq point (next-single-property-change point 'epa-list-keys)))
-    (when point
-      (delete-region point
-                    (or (next-single-property-change point 'epa-list-keys)
-                        (point-max)))
-      (goto-char point))
-    (epa--insert-keys context name mode)
-    (widget-setup)
-    (set-keymap-parent (current-local-map) widget-keymap))
-  (make-local-variable 'epa-list-keys-arguments)
-  (setq epa-list-keys-arguments (list name mode))
-  (goto-char (point-min))
-  (pop-to-buffer (current-buffer)))
-
 (defun epa--insert-keys (context name mode)
   (save-excursion
     (save-restriction
@@ -392,6 +355,55 @@ reads the public keyring."
                                 'start-open t
                                 'end-open t)))))
 
+(defun epa--list-keys (name secret)
+  (unless (and epa-keys-buffer
+              (buffer-live-p epa-keys-buffer))
+    (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
+  (set-buffer epa-keys-buffer)
+  (epa-key-list-mode)
+  (let ((inhibit-read-only t)
+       buffer-read-only
+       (point (point-min))
+       (context (epg-make-context epa-protocol)))
+    (unless (get-text-property point 'epa-list-keys)
+      (setq point (next-single-property-change point 'epa-list-keys)))
+    (when point
+      (delete-region point
+                    (or (next-single-property-change point 'epa-list-keys)
+                        (point-max)))
+      (goto-char point))
+    (epa--insert-keys context name secret)
+    (widget-setup)
+    (set-keymap-parent (current-local-map) widget-keymap))
+  (make-local-variable 'epa-list-keys-arguments)
+  (setq epa-list-keys-arguments (list name secret))
+  (goto-char (point-min))
+  (pop-to-buffer (current-buffer)))
+
+;;;###autoload
+(defun epa-list-keys (&optional name)
+  "List all keys matched with NAME from the public keyring."
+  (interactive
+   (if current-prefix-arg
+       (let ((name (read-string "Pattern: "
+                               (if epa-list-keys-arguments
+                                   (car epa-list-keys-arguments)))))
+        (list (if (equal name "") nil name)))
+     (or epa-list-keys-arguments (list nil nil))))
+  (epa--list-keys name nil))
+
+;;;###autoload
+(defun epa-list-secret-keys (&optional name)
+  "List all keys matched with NAME from the private keyring."
+  (interactive
+   (if current-prefix-arg
+       (let ((name (read-string "Pattern: "
+                               (if epa-list-keys-arguments
+                                   (car epa-list-keys-arguments)))))
+        (list (if (equal name "") nil name)))
+     (or epa-list-keys-arguments (list nil nil))))
+  (epa--list-keys name t))
+
 (defun epa--marked-keys ()
   (or (save-excursion
        (set-buffer epa-keys-buffer)