From: ueno Date: Fri, 26 May 2006 11:09:29 +0000 (+0000) Subject: * epa.el (epa-popup-info-window): New user option. X-Git-Tag: epg-0_0_2~16 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=0fdd8c127b2253e4c3886f974c2d81d96da2e3a4;p=elisp%2Fepg.git * epa.el (epa-popup-info-window): New user option. (epa-info-window-height): New user option. (epa-display-verify-result): New function. --- diff --git a/ChangeLog b/ChangeLog index ae017b9..1be35ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * epa.el (epa-insert-keys): Renamed from epa-list-keys-1; don't disable inhibit-quit here; make text-properties nonsticky. + (epa-popup-info-window): New user option. + (epa-info-window-height): New user option. + (epa-display-verify-result): New function. * epg.el (epg-make-context): New slot "operation". (epg-passphrase-callback-function): Confirm passphrase when diff --git a/epa.el b/epa.el index b9eb487..762b172 100644 --- a/epa.el +++ b/epa.el @@ -42,6 +42,17 @@ :type 'boolean :group 'epa) +(defcustom epa-popup-info-window t + "If non-nil, status information from epa commands is displayed on +the separate window." + :type 'boolean + :group 'epa) + +(defcustom epa-info-window-height 5 + "Number of lines used to display status information." + :type 'integer + :group 'epa) + (defgroup epa-faces nil "Faces for epa-mode." :group 'epa) @@ -154,6 +165,7 @@ (defvar epa-key-buffer-alist nil) (defvar epa-key nil) (defvar epa-list-keys-arguments nil) +(defvar epa-info-buffer nil) (defvar epa-keys-mode-map (let ((keymap (make-sparse-keymap))) @@ -215,6 +227,35 @@ (epg-sub-key-id (car (epg-key-sub-key-list (widget-get widget :value)))))) +(defun epa--temp-buffer-show-function (buffer) + (save-selected-window + (let ((window (or (get-buffer-window epa-buffer-name) + (progn + (select-window (get-largest-window)) + (split-window-vertically))))) + (set-window-buffer window buffer) + (if window + (select-window window)) + (unless (pos-visible-in-window-p (point-max)) + (enlarge-window (- epa-info-window-height (window-height)))) + (let ((height (window-height))) + (if (> height epa-info-window-height) + (shrink-window (- height epa-info-window-height))) + (set-window-start window (point-min)))))) + +(defun epa-display-verify-result (verify-result) + (if epa-popup-info-window + (let ((temp-buffer-show-function #'epa--temp-buffer-show-function)) + (unless epa-info-buffer + (setq epa-info-buffer (generate-new-buffer "*Info*")) + (with-current-buffer epa-info-buffer + (setq buffer-read-only t))) + (with-output-to-temp-buffer epa-info-buffer + (save-excursion + (set-buffer standard-output) + (insert (epg-verify-result-to-string verify-result))))) + (message "%s" (epg-verify-result-to-string verify-result)))) + (defun epa-keys-mode () "Major mode for `epa-list-keys'." (kill-all-local-variables) @@ -496,9 +537,7 @@ If ARG is non-nil, mark the current line." (epg-decrypt-file context file plain) (message "Decrypting %s...done" (file-name-nondirectory file)) (if (epg-context-result-for context 'verify) - (message "%s" - (epg-verify-result-to-string - (epg-context-result-for context 'verify)))))) + (epa-display-verify-result (epg-context-result-for context 'verify))))) ;;;###autoload (defun epa-verify-file (file) @@ -510,9 +549,8 @@ If ARG is non-nil, mark the current line." (message "Verifying %s..." (file-name-nondirectory file)) (epg-verify-file context file plain) (message "Verifying %s...done" (file-name-nondirectory file)) - (message "%s" - (epg-verify-result-to-string - (epg-context-result-for context 'verify))))) + (if (epg-context-result-for context 'verify) + (epa-display-verify-result (epg-context-result-for context 'verify))))) ;;;###autoload (defun epa-sign-file (file signers mode) @@ -572,9 +610,7 @@ Don't use this command in Lisp programs!" (goto-char start) (insert (decode-coding-string plain coding-system-for-read)) (if (epg-context-result-for context 'verify) - (message "%s" - (epg-verify-result-to-string - (epg-context-result-for context 'verify))))))) + (epa-display-verify-result (epg-context-result-for context 'verify)))))) ;;;###autoload (defun epa-decrypt-armor-in-region (start end) @@ -615,9 +651,8 @@ Don't use this command in Lisp programs!" (encode-coding-string (buffer-substring start end) coding-system-for-write)) - (message "%s" - (epg-verify-result-to-string - (epg-context-result-for context 'verify))))) + (if (epg-context-result-for context 'verify) + (epa-display-verify-result (epg-context-result-for context 'verify))))) ;;;###autoload (defun epa-verify-armor-in-region (start end)