summaryrefslogtreecommitdiff
path: root/lisp/epg.el
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2014-11-05 18:38:37 +0900
committerDaiki Ueno <ueno@gnu.org>2014-11-05 18:38:37 +0900
commit5e28461482115baee4d1f28f514a322a50774b75 (patch)
treef8ad9ff505c42b017e960887578a27a3c0cdd462 /lisp/epg.el
parentb6e66a5cc78e353ff9ae6cdd0807eefcf55b4934 (diff)
downloademacs-5e28461482115baee4d1f28f514a322a50774b75.tar.gz
epg: Collect output lines sent to stderr
* epg.el (epg-context): Add new slot ERROR-OUTPUT. (epg-error-output): New buffer-local variable. (epg--start): Initialize epg-error-output. (epg--process-filter): Record output lines sent to stderr, in epg-error-output. (epg-wait-for-completion): Copy epg-error-output to ERROR-OUTPUT slot of context. * epa-file.el (epa-file-insert-file-contents): On error, display output sent to stderr. (epa-file-write-region): Likewise.
Diffstat (limited to 'lisp/epg.el')
-rw-r--r--lisp/epg.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/lisp/epg.el b/lisp/epg.el
index 8b80de6295a..9c002e4ae30 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -40,6 +40,7 @@
(defvar epg-debug-buffer nil)
(defvar epg-agent-file nil)
(defvar epg-agent-mtime nil)
+(defvar epg-error-output nil)
;; from gnupg/include/cipher.h
(defconst epg-cipher-algorithm-alist
@@ -210,7 +211,8 @@
output-file
result
operation
- pinentry-mode)
+ pinentry-mode
+ error-output)
;; This is not an alias, just so we can mark it as autoloaded.
;;;###autoload
@@ -639,7 +641,9 @@ callback data (if any)."
(make-local-variable 'epg-agent-file)
(setq epg-agent-file agent-file)
(make-local-variable 'epg-agent-mtime)
- (setq epg-agent-mtime agent-mtime))
+ (setq epg-agent-mtime agent-mtime)
+ (make-local-variable 'epg-error-output)
+ (setq epg-error-output nil))
(with-file-modes 448
(setq process (apply #'start-process "epg" buffer
(epg-context-program context) args)))
@@ -673,7 +677,14 @@ callback data (if any)."
(if (and symbol
(fboundp symbol))
(funcall symbol epg-context string))
- (setq epg-last-status (cons status string))))
+ (setq epg-last-status (cons status string)))
+ ;; Record other lines sent to stderr. This assumes
+ ;; that the process-filter receives output only from
+ ;; stderr and the FD specified with --status-fd.
+ (setq epg-error-output
+ (cons (buffer-substring (point)
+ (line-end-position))
+ epg-error-output)))
(forward-line)
(setq epg-read-point (point)))))))))
@@ -715,7 +726,10 @@ callback data (if any)."
(redraw-frame))
(epg-context-set-result-for
context 'error
- (nreverse (epg-context-result-for context 'error))))
+ (nreverse (epg-context-result-for context 'error)))
+ (with-current-buffer (process-buffer (epg-context-process context))
+ (setf (epg-context-error-output context)
+ (mapconcat #'identity (nreverse epg-error-output) "\n"))))
(defun epg-reset (context)
"Reset the CONTEXT."