suppressing epa's error buffer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

suppressing epa's error buffer

Robert Pluim
If the user cancels the epa decryption, epa pops up an obnoxious error
buffer, thus defeating any ignore-errors wrapping. The best solution
Iʼve come up with is

    modified   lisp/epa.el
    @@ -180,6 +180,7 @@ epa-list-keys-arguments
     (defvar epa-info-buffer nil)
     (defvar epa-error-buffer nil)
     (defvar epa-last-coding-system-specified nil)
    +(defvar epa-suppress-error-buffer nil)

     (defvar epa-key-list-mode-map
       (let ((keymap (make-sparse-keymap))
    @@ -578,7 +579,8 @@ epa-display-info
         (message "%s" info)))

     (defun epa-display-error (context)
    -  (unless (equal (epg-context-error-output context) "")
    +  (unless (or (equal (epg-context-error-output context) "")
    +              epa-suppress-error-buffer)
         (let ((buffer (get-buffer-create "*Error*")))
           (save-selected-window
            (unless (and epa-error-buffer (buffer-live-p
            epa-error-buffer))

Which then lets me do the following, but it all feels like a layering
violation. Iʼm hoping someone has a better suggestion. (I considered
'display-buffer-alist', but that feels even worse).

    modified   lisp/net/network-stream.el
    @@ -218,6 +218,8 @@ open-network-stream
                      :error        (nth 4 result))
              (car result))))))

    +(defvar epa-suppress-error-buffer)
    +
     (defun network-stream-certificate (host service parameters)
       (let ((spec (plist-get parameters :client-certificate)))
         (cond
    @@ -225,10 +227,12 @@ network-stream-certificate
           ;; Either nil or a list with a key/certificate pair.
           spec)
          ((eq spec t)
    -      (let* ((auth-info
    -      (car (auth-source-search :max 1
    -       :host host
    -       :port service)))
    +      (let* ((epa-suppress-error-buffer t)
    +             (auth-info
    +              (ignore-errors
    +                (car (auth-source-search :max 1
    +                                         :host host
    +                                         :port service))))
                 (key (plist-get auth-info :key))
                 (cert (plist-get auth-info :cert)))
            (and key cert (file-readable-p key) (file-readable-p cert)