From a89c8bd86f292f36af628f0b5306c0a3dfdaa744 Mon Sep 17 00:00:00 2001
From: Amin Bandali <bandali@gnu.org>
Date: Wed, 8 Jan 2020 01:05:54 -0500
Subject: [PATCH 1/1] emacs,gnupg: use emacs for pinentry again

---
 .emacs.d/init.el      | 14 ++++++++++++++
 .gnupg/gpg-agent.conf |  4 +++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index a043652..d2afd0f 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -451,12 +451,26 @@ For disabling the behaviour for certain buffers and/or modes."
   :config (pixel-scroll-mode 1))
 
 (use-package epg-config
+  :config
+  ;; ask for GPG passphrase in minibuffer
+  ;; this will fail if gpg>=2.1 is not available
+  (if (version< "27" emacs-version)
+      (setq epg-pinentry-mode 'loopback)
+    (setq epa-pinentry-mode 'loopback))
   :custom
   (epg-gpg-program (executable-find "gpg")))
 
 (use-package epg
   :after epg-config)
 
+(use-package pinentry
+  :demand
+  :after (epa epg server)
+  :config
+  ;; workaround for systemd-based distros:
+  ;; (setq pinentry--socket-dir server-socket-dir)
+  (pinentry-start))
+
 (use-package auth-source
   :custom
   (auth-sources '("~/.authinfo.gpg"))
diff --git a/.gnupg/gpg-agent.conf b/.gnupg/gpg-agent.conf
index 1b59d64..ba418db 100644
--- a/.gnupg/gpg-agent.conf
+++ b/.gnupg/gpg-agent.conf
@@ -4,4 +4,6 @@ max-cache-ttl 86400
 default-cache-ttl-ssh 43200
 max-cache-ttl-ssh 86400
 
-pinentry-program /home/bandali/.guix-profile/bin/pinentry
+pinentry-program /home/bandali/.guix-profile/bin/pinentry-emacs
+allow-emacs-pinentry
+allow-loopback-pinentry
-- 
2.20.1