emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r118291: epg: Collect output lines sent to stderr


From: Daiki Ueno
Subject: [Emacs-diffs] trunk r118291: epg: Collect output lines sent to stderr
Date: Wed, 05 Nov 2014 09:40:04 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118291
revision-id: address@hidden
parent: address@hidden
committer: Daiki Ueno <address@hidden>
branch nick: trunk
timestamp: Wed 2014-11-05 18:38:37 +0900
message:
  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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/epa-file.el               epafile.el-20091113204419-o5vbwnq5f7feedwu-8554
  lisp/epg.el                    epg.el-20091113204419-o5vbwnq5f7feedwu-8560
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-11-05 05:08:57 +0000
+++ b/lisp/ChangeLog    2014-11-05 09:38:37 +0000
@@ -1,3 +1,16 @@
+2014-11-05  Daiki Ueno  <address@hidden>
+
+       * 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.
+
 2014-11-05  Eli Zaretskii  <address@hidden>
 
        * jit-lock.el (jit-lock-stealth-fontify): Be tolerant to nil being

=== modified file 'lisp/epa-file.el'
--- a/lisp/epa-file.el  2014-01-14 08:41:09 +0000
+++ b/lisp/epa-file.el  2014-11-05 09:38:37 +0000
@@ -162,6 +162,11 @@
               (add-hook 'find-file-not-found-functions
                         'epa-file--find-file-not-found-function
                         nil t))
+            (if (epg-context-error-output context)
+                (epa-display-info
+                 (concat (format "Error while executing \"%s\":\n\n"
+                                 epg-gpg-program)
+                         (epg-context-error-output context))))
             (signal 'file-error
                     (cons "Opening input file" (cdr error)))))
           (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)!
@@ -257,6 +262,11 @@
       (error
        (if (setq entry (assoc file epa-file-passphrase-alist))
           (setcdr entry nil))
+       (if (epg-context-error-output context)
+          (epa-display-info
+           (concat (format "Error while executing \"%s\":\n\n"
+                           epg-gpg-program)
+                   (epg-context-error-output context))))
        (signal 'file-error (cons "Opening output file" (cdr error)))))
     (epa-file-run-real-handler
      #'write-region

=== modified file 'lisp/epg.el'
--- a/lisp/epg.el       2014-10-23 21:38:56 +0000
+++ b/lisp/epg.el       2014-11-05 09:38:37 +0000
@@ -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 @@
       (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 @@
                       (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 @@
       (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."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]