From 69dacd8e529f38db107ad0fc4c8531ab8c8edc5c Mon Sep 17 00:00:00 2001 From: ueno Date: Wed, 19 Apr 2006 08:50:16 +0000 Subject: [PATCH] * epa.el (epa-verify-file): Show results in minibuffer. * epg.el (epg-debug-buffer): New variable. (epg-flush): New function. --- ChangeLog | 6 ++++++ epa.el | 18 +++++++----------- epg.el | 36 ++++++++++++++++++++++++------------ 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 866a960..da5c4af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-19 Daiki Ueno + + * epa.el (epa-verify-file): Show results in minibuffer. + * epg.el (epg-debug-buffer): New variable. + (epg-flush): New function. + 2006-04-18 Daiki Ueno * epa.el (epa-export-keys): New command. diff --git a/epa.el b/epa.el index 8db752b..6e5fe12 100644 --- a/epa.el +++ b/epa.el @@ -437,17 +437,13 @@ (message "Verifying %s..." (file-name-nondirectory file)) (epg-verify-file context file plain) (setq signature (reverse (epg-context-result-for context 'verify))) - (with-output-to-temp-buffer "*epa-verify-file*" - (set-buffer standard-output) - (while signature - (insert (format "%s: %s %s %s\n" - (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)))) - (shrink-window-if-larger-than-buffer - (get-buffer-window "*epa-verify-file*")) + (while signature + (message "%s: %s %s %s\n" + (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 "Verifying %s...done" (file-name-nondirectory file)))) (defun epa-sign-file (file detached) diff --git a/epg.el b/epg.el index f084237..beebfc1 100644 --- a/epg.el +++ b/epg.el @@ -46,6 +46,7 @@ (defvar epg-key-id nil) (defvar epg-context nil) (defvar epg-debug nil) +(defvar epg-debug-buffer nil) ;; from gnupg/include/cipher.h (defconst epg-cipher-algorithm-alist @@ -423,7 +424,9 @@ This function is for internal use only." process) (if epg-debug (save-excursion - (set-buffer (get-buffer-create " *epg-debug*")) + (unless epg-debug-buffer + (setq epg-debug-buffer (generate-new-buffer " *epg-debug*"))) + (set-buffer epg-debug-buffer) (goto-char (point-max)) (insert (format "%s %s\n" epg-gpg-program (mapconcat #'identity args " "))))) @@ -448,7 +451,9 @@ This function is for internal use only." (defun epg-process-filter (process input) (if epg-debug (save-excursion - (set-buffer (get-buffer-create " *epg-debug*")) + (unless epg-debug-buffer + (setq epg-debug-buffer (generate-new-buffer " *epg-debug*"))) + (set-buffer epg-debug-buffer) (goto-char (point-max)) (insert input))) (if (buffer-live-p (process-buffer process)) @@ -490,15 +495,16 @@ This function is for internal use only." epg-pending-status-list) (accept-process-output (epg-context-process context) 1)))) -(defun epg-wait-for-completion (context &optional no-eof) - (if (and (not no-eof) - (eq (process-status (epg-context-process context)) 'run)) - (process-send-eof (epg-context-process context))) +(defun epg-wait-for-completion (context) (while (eq (process-status (epg-context-process context)) 'run) ;; We can't use accept-process-output instead of sit-for here ;; because it may cause an interrupt during the sentinel execution. (sit-for 0.1))) +(defun epg-flush (context) + (if (eq (process-status (epg-context-process context)) 'run) + (process-send-eof (epg-context-process context)))) + (defun epg-reset (context) (if (and (epg-context-process context) (buffer-live-p (process-buffer (epg-context-process context)))) @@ -909,7 +915,7 @@ If PLAIN is nil, it returns the result as a string." (epg-context-set-output-file context (epg-make-temp-file "epg-output"))) (epg-start-decrypt context (epg-make-data-from-file cipher)) - (epg-wait-for-completion context t) + (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Decrypt failed: %S" (epg-context-result-for context 'error))) @@ -930,6 +936,7 @@ If PLAIN is nil, it returns the result as a string." (epg-context-set-output-file context (epg-make-temp-file "epg-output")) (epg-start-decrypt context (epg-make-data-from-file input-file)) + (epg-flush context) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Decrypt failed: %S" @@ -990,7 +997,7 @@ For a normal or a clear text signature, SIGNED-TEXT should be nil." (epg-make-data-from-file signed-text)) (epg-start-verify context (epg-make-data-from-file signature))) - (epg-wait-for-completion context t) + (epg-wait-for-completion context) (unless plain (epg-read-output context))) (unless plain @@ -1018,6 +1025,7 @@ For a normal or a clear text signature, SIGNED-TEXT should be nil." (epg-make-data-from-file input-file) (epg-make-data-from-string signed-text))) (epg-start-verify context (epg-make-data-from-string signature))) + (epg-flush context) (epg-wait-for-completion context) (epg-read-output context)) (epg-delete-output-file context) @@ -1073,7 +1081,7 @@ Otherwise, it makes a normal signature." (epg-context-set-output-file context (epg-make-temp-file "epg-output"))) (epg-start-sign context (epg-make-data-from-file plain) mode) - (epg-wait-for-completion context t) + (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Sign failed: %S" (epg-context-result-for context 'error))) @@ -1094,6 +1102,7 @@ Otherwise, it makes a normal signature." (epg-context-set-output-file context (epg-make-temp-file "epg-output")) (epg-start-sign context (epg-make-data-from-string plain) mode) + (epg-flush context) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Sign failed: %S" @@ -1152,7 +1161,7 @@ If RECIPIENTS is nil, it performs symmetric encryption." (epg-make-temp-file "epg-output"))) (epg-start-encrypt context (epg-make-data-from-file plain) recipients sign always-trust) - (epg-wait-for-completion context t) + (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Encrypt failed: %S" (epg-context-result-for context 'error))) @@ -1173,6 +1182,7 @@ If RECIPIENTS is nil, it performs symmetric encryption." (epg-make-temp-file "epg-output")) (epg-start-encrypt context (epg-make-data-from-string plain) recipients sign always-trust) + (epg-flush context) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Encrypt failed: %S" @@ -1244,7 +1254,9 @@ If you are unsure, use synchronous version of this function (unwind-protect (progn (epg-start-import-keys context keys) - (epg-wait-for-completion context (epg-data-file keys)) + (if (epg-data-file keys) + (epg-flush context)) + (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Import keys failed")) (epg-read-output context)) @@ -1285,7 +1297,7 @@ If you are unsure, use synchronous version of this function (unwind-protect (progn (epg-start-delete-keys context keys) - (epg-wait-for-completion context t) + (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Delete key failed"))) (epg-reset context))) -- 1.7.10.4