X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=epa.el;h=043ffd6194b766fa5b5474332fb609c0fccf791e;hb=1e72feccfd861a57c5f86b154f1fb42af731c853;hp=0c90a7c2a42d3bf1ac920024024c07f763e23de8;hpb=d9e077e5c49f0678f7141862c3dd1f56dfc81e31;p=elisp%2Fepg.git diff --git a/epa.el b/epa.el index 0c90a7c..043ffd6 100644 --- a/epa.el +++ b/epa.el @@ -254,8 +254,15 @@ (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) (set-buffer epa-keys-buffer) (let ((inhibit-read-only t) - buffer-read-only) - (erase-buffer) + buffer-read-only + (point (point-min))) + (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-list-keys-1 name mode) (epa-keys-mode)) (make-local-variable 'epa-list-keys-arguments) @@ -264,17 +271,20 @@ (pop-to-buffer (current-buffer))) (defun epa-list-keys-1 (name mode) - (let ((inhibit-read-only t) - buffer-read-only - (keys (epg-list-keys name mode)) - point) - (while keys - (setq point (point)) - (insert " ") - (put-text-property point (point) 'epa-key (car keys)) - (widget-create 'epa-key :value (car keys)) - (insert "\n") - (setq keys (cdr keys))))) + (save-restriction + (narrow-to-region (point) (point)) + (let ((inhibit-read-only t) + buffer-read-only + (keys (epg-list-keys name mode)) + point) + (while keys + (setq point (point)) + (insert " ") + (put-text-property point (point) 'epa-key (car keys)) + (widget-create 'epa-key :value (car keys)) + (insert "\n") + (setq keys (cdr keys)))) + (put-text-property (point-min) (point-max) 'epa-list-keys t))) (defun epa-marked-keys () (or (save-excursion @@ -290,7 +300,7 @@ (beginning-of-line) (get-text-property (point) 'epa-key)))) -(defun epa-select-keys (prompt &optional names) +(defun epa-select-keys (prompt &optional names mode) (save-excursion (unless (and epa-keys-buffer (buffer-live-p epa-keys-buffer)) @@ -302,6 +312,12 @@ (erase-buffer) (insert prompt "\n") (widget-create 'link + :notify (lambda (&rest ignore) (abort-recursive-edit)) + :help-echo + (substitute-command-keys + "Click here or \\[abort-recursive-edit] to cancel") + "Cancel") + (widget-create 'link :notify (lambda (&rest ignore) (exit-recursive-edit)) :help-echo (substitute-command-keys @@ -311,12 +327,12 @@ (if names (while names (setq point (point)) - (epa-list-keys-1 (car names) nil) + (epa-list-keys-1 (car names) mode) (goto-char point) (epa-mark) (goto-char (point-max)) (setq names (cdr names))) - (epa-list-keys-1 nil nil)) + (epa-list-keys-1 nil mode)) (epa-keys-mode) (goto-char (point-min)) (pop-to-buffer (current-buffer)) @@ -432,19 +448,13 @@ (interactive "fFile: ") (let* ((context (epg-make-context)) (plain (if (equal (file-name-extension file) "sig") - (file-name-sans-extension file))) - signature) + (file-name-sans-extension file)))) (message "Verifying %s..." (file-name-nondirectory file)) (epg-verify-file context file plain) (message "Verifying %s...done" (file-name-nondirectory file)) - (setq signature (reverse (epg-context-result-for context 'verify))) - (while signature - (message "%s: %s %s %s" - (epg-signature-status (car signature)) - (epg-signature-key-id (car signature)) - (epg-signature-user-id (car signature)) - (epg-signature-validity (car signature))) - (setq signature (cdr signature))))) + (message "%s" + (epg-verify-result-to-string + (epg-context-result-for context 'verify))))) (defun epa-sign-file (file detached) (interactive @@ -459,18 +469,12 @@ (defun epa-encrypt-file (file recipients) (interactive (list (expand-file-name (read-file-name "File: ")) - (mapcar (lambda (key) - (epg-sub-key-id - (car (epg-key-sub-key-list key)))) - (epa-select-keys "Select recipents for encryption. -If no one is selected, symmetric encryption will be performed. ")))) + (epa-select-keys "Select recipents for encryption. +If no one is selected, symmetric encryption will be performed. "))) (let ((cipher (concat file ".gpg")) (context (epg-make-context))) (message "Encrypting %s..." (file-name-nondirectory file)) - (epg-encrypt-file context - file - recipients - cipher) + (epg-encrypt-file context file recipients cipher) (message "Encrypting %s...done" (file-name-nondirectory file)))) (defun epa-delete-keys (keys)