From 65e0fdf80da74fd3312e89df0d9e6c85db20beef Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 10 Sep 2019 11:28:41 +0200 Subject: [PATCH] Notmuch: Unlock GPG on demand in the foreground. --- .emacs.d/lisp/init-notmuch.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.emacs.d/lisp/init-notmuch.el b/.emacs.d/lisp/init-notmuch.el index 8684a839..8dec8fc0 100644 --- a/.emacs.d/lisp/init-notmuch.el +++ b/.emacs.d/lisp/init-notmuch.el @@ -86,4 +86,17 @@ ;; (advice-add 'debbugs-gnu-select-report :override #'debbugs-notmuch-select-report) +;; TODO: This is a bit brittle since it only works if ~/.authinfo.gpg exists. +;; Is there a way to unlock gpg manually without a file? +(defun ambrevar/gpg-unlock () + "Unlock GPG." + (let ((sentinel (lambda (_process _args) + (notmuch-poll) + (notmuch-refresh-this-buffer)))) + (make-process :name "gpg" :buffer nil + :command (list "gpg" "--decrypt" (expand-file-name "~/.authinfo.gpg")) + :sentinel sentinel))) + +(advice-add 'notmuch-poll-and-refresh-this-buffer :override #'ambrevar/gpg-unlock) + (provide 'init-notmuch)