From: ueno Date: Sun, 16 Apr 2006 21:22:07 +0000 (+0000) Subject: * epa.el (epa-select-keys): Renamed from epa-ask-keys; use X-Git-Tag: epgsm-branchpoint~75 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4a0e4453626050f816bce237441b2c5bd511386;p=elisp%2Fepg.git * epa.el (epa-select-keys): Renamed from epa-ask-keys; use recursive-edit. * epa-dired.el (epa-dired-encrypt-file): Use epa-select-keys. --- diff --git a/ChangeLog b/ChangeLog index 9399ce7..d20f304 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2006-04-16 Daiki Ueno + * 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 + * epa-setup.el: New file. * epa-dired.el: New file. diff --git a/epa-dired.el b/epa-dired.el index a9e11c2..9b2dc44 100644 --- a/epa-dired.el +++ b/epa-dired.el @@ -67,9 +67,11 @@ (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 @@ -84,10 +86,7 @@ (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 --- 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)) @@ -222,30 +220,17 @@ (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)) @@ -253,7 +238,20 @@ (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)))