* epa.el (epa-select-keys): Renamed from epa-ask-keys; use
authorueno <ueno>
Sun, 16 Apr 2006 21:22:07 +0000 (21:22 +0000)
committerueno <ueno>
Sun, 16 Apr 2006 21:22:07 +0000 (21:22 +0000)
recursive-edit.
* epa-dired.el (epa-dired-encrypt-file): Use epa-select-keys.

ChangeLog
epa-dired.el
epa.el

index 9399ce7..d20f304 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2006-04-16  Daiki Ueno  <ueno@unixuser.org>
 
+       * epa.el (epa-select-keys): Renamed from epa-ask-keys; use
+       recursive-edit.
+       * epa-dired.el (epa-dired-encrypt-file): Use epa-select-keys.
+
+2006-04-16  Daiki Ueno  <ueno@unixuser.org>
+
        * epa-setup.el: New file.
        * epa-dired.el: New file.
 
index a9e11c2..9b2dc44 100644 (file)
       (setq file-list (cdr file-list)))
     (revert-buffer)))
 
-(defun epa-dired-encrypt-file (keys file)
+(defun epa-dired-encrypt-file (file)
   (let ((cipher (concat file ".gpg"))
-       (context (epg-make-context)))
+       (context (epg-make-context))
+       (keys (epa-select-keys "Select recipents for encryption.
+If no one is selected, symmetric encryption will be performed.  ")))
     (message "Encrypting %s..." (file-name-nondirectory file))
     (epg-encrypt-file context
                      file
   (interactive)
   (let ((file-list (dired-get-marked-files)))
     (while file-list
-      (epa-ask-keys "Select recipents for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-                   #'epa-dired-encrypt-file nil
-                   (expand-file-name (car file-list)))
+      (epa-dired-encrypt-file (car file-list))
       (setq file-list (cdr file-list)))))
 
 (provide 'epa-dired)
diff --git a/epa.el b/epa.el
index 6e96a7b..fa1f6bf 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -36,8 +36,6 @@
   "Faces for epa-mode."
   :group 'epa)
 
-(defvar epa-buffer nil)
-
 (defface epa-validity-high-face
   '((((class color) (background dark))
      (:foreground "PaleTurquoise" :bold t))
       (put-text-property point (point) 'epa-key (car keys))
       (setq keys (cdr keys)))))
 
-(defun epa-ask-keys (prompt function &optional names &rest args)
+(defun epa-select-keys (prompt &optional names)
   (unless (and epa-keys-buffer
               (buffer-live-p epa-keys-buffer))
     (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
-  (let ((buffer (current-buffer))
-       (inhibit-read-only t)
+  (let ((inhibit-read-only t)
        buffer-read-only)
     (set-buffer epa-keys-buffer)
     (erase-buffer)
-    (insert prompt)
-    (widget-create 'push-button
-                  :tag "Done"
-                  :notify (lambda (widget &rest ignore)
-                            (let ((callback (widget-value widget))
-                                  keys key)
-                              (while (re-search-forward "^\\*" nil t)
-                                (if (setq key (get-text-property (point)
-                                                                 'epa-key))
-                                    (setq keys (cons key keys))))
-                              (set-buffer (car callback))
-                              (apply (car (cdr callback)) keys
-                                     (cdr (cdr callback)))))
-                  (cons buffer (cons function args)))
-    (insert "\n\n")
+    (insert prompt "\n\n"
+           (substitute-command-keys "\\[exit-recursive-edit] to exit.")
+           "\n\n")
     (if names
        (while names
          (epa-list-keys-1 (car names))
       (epa-list-keys-1 nil))
     (epa-keys-mode)
     (goto-char (point-min))
-    (pop-to-buffer (current-buffer))))
+    (pop-to-buffer (current-buffer))
+    (unwind-protect
+       (progn
+         (recursive-edit)
+         (save-excursion
+           (set-buffer epa-keys-buffer)
+           (goto-char (point-min))
+           (let (keys key)
+             (while (re-search-forward "^\\*" nil t)
+               (if (setq key (get-text-property (match-beginning 0) 'epa-key))
+                   (setq keys (cons key keys))))
+             (nreverse keys))))
+      (if (get-buffer-window epa-keys-buffer)
+         (delete-window (get-buffer-window epa-keys-buffer))))))
 
 (defun epa-show-key (key)
   (let* ((primary-sub-key (car (epg-key-sub-key-list key)))