]> code.delx.au - gnu-emacs/blobdiff - lisp/epg.el
Make the eww buffers read-only
[gnu-emacs] / lisp / epg.el
index 8b80de6295a246be06a0365f88afcd2139bf5ea2..e4d8c1e1a024d134733c86d8c3ca252de4fca21a 100644 (file)
@@ -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
   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."
@@ -1264,8 +1278,9 @@ callback data (if any)."
              string (match-string 0)
              index 0
              field 0)
-       (while (eq index
-                  (string-match "\\([^:]+\\)?:" string index))
+       (while (and (< field (length (car keys)))
+                   (eq index
+                       (string-match "\\([^:]+\\)?:" string index)))
          (setq index (match-end 0))
          (aset (car keys) field (match-string 1 string))
          (setq field (1+ field))))