* epa.el (epa-popup-info-window): Disable by default.
authorueno <ueno>
Fri, 26 May 2006 22:14:57 +0000 (22:14 +0000)
committerueno <ueno>
Fri, 26 May 2006 22:14:57 +0000 (22:14 +0000)
(epa-display-verify-result): Don't use with-output-to-temp-buffer.
(epa-info-mode): New function.

ChangeLog
epa.el

index 181cdfe..13e3c91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,6 @@
        disable inhibit-quit here; make text-properties nonsticky.
        (epa-popup-info-window): New user option.
        (epa-info-window-height): New user option.
-       (epa--temp-buffer-show-function): New function.
        (epa-display-verify-result): New function.
        (epa-decrypt-file): Use it.
        (epa-verify-file): Use it.
diff --git a/epa.el b/epa.el
index 7e862cb..4269254 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -42,7 +42,7 @@
   :type 'boolean
   :group 'epa)
 
-(defcustom epa-popup-info-window t
+(defcustom epa-popup-info-window nil
   "If non-nil, status information from epa commands is displayed on
 the separate window."
   :type 'boolean
@@ -165,6 +165,7 @@ the separate window."
 (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)))
@@ -186,6 +187,16 @@ the separate window."
     (define-key keymap "q" 'epa-exit-buffer)
     keymap))
 
+(defvar epa-key-mode-map
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap "q" 'bury-buffer)
+    keymap))
+
+(defvar epa-info-mode-map
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap "q" 'delete-window)
+    keymap))
+
 (defvar epa-exit-buffer-function #'bury-buffer)
 
 (define-widget 'epa-key 'push-button
@@ -226,31 +237,6 @@ the separate window."
          (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 buffer)
-                     (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))
-       (with-output-to-temp-buffer "*Info*"
-         (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)
@@ -270,11 +256,6 @@ the separate window."
   (make-local-variable 'epa-exit-buffer-function)
   (run-hooks 'epa-keys-mode-hook))
 
-(defvar epa-key-mode-map
-  (let ((keymap (make-sparse-keymap)))
-    (define-key keymap "q" 'bury-buffer)
-    keymap))
-
 (defun epa-key-mode ()
   "Major mode for `epa-show-key'."
   (kill-all-local-variables)
@@ -515,6 +496,35 @@ If ARG is non-nil, mark the current line."
   (interactive)
   (funcall epa-exit-buffer-function))
 
+(defun epa-display-verify-result (verify-result)
+  (if epa-popup-info-window
+      (progn
+       (unless epa-info-buffer
+         (setq epa-info-buffer (generate-new-buffer "*Info*")))
+       (save-excursion
+         (set-buffer epa-info-buffer)
+         (let ((inhibit-read-only t)
+               buffer-read-only)
+           (erase-buffer)
+           (insert (epg-verify-result-to-string verify-result)))
+         (epa-info-mode))
+       (pop-to-buffer epa-info-buffer)
+       (if (> (window-height) epa-info-window-height)
+           (shrink-window (- (window-height) epa-info-window-height)))
+       (goto-char (point-min)))
+    (message "%s" (epg-verify-result-to-string verify-result))))
+
+(defun epa-info-mode ()
+  "Major mode for `epa-info-buffer'."
+  (kill-all-local-variables)
+  (buffer-disable-undo)
+  (setq major-mode 'epa-info-mode
+       mode-name "Info"
+       truncate-lines t
+       buffer-read-only t)
+  (use-local-map epa-info-mode-map)
+  (run-hooks 'epa-info-mode-hook))
+
 ;;;###autoload
 (defun epa-decrypt-file (file)
   "Decrypt FILE."