Fix default encryption recipient detection

This commit is contained in:
Henrik Lissner 2020-01-18 20:34:18 -05:00
parent 453e20534f
commit bee7798a50
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -29,16 +29,23 @@
(after! epa (after! epa
(setq epa-file-encrypt-to ;; With GPG 2.1+, this forces gpg-agent to use the Emacs minibuffer to prompt
(or epa-file-encrypt-to ;; for the key passphrase.
;; Collect all public key IDs with your username (setq epa-pinentry-mode 'loopback)
(unless (string-empty-p user-full-name) ;; Default to the first secret key available in your keyring.
(cl-loop for key in (ignore-errors (epg-list-keys (epg-make-context) user-full-name)) (setq-default
collect (epg-sub-key-id (car (epg-key-sub-key-list key))))) epa-file-encrypt-to
user-mail-address) (or (default-value 'epa-file-encrypt-to)
;; With GPG 2.1, this forces gpg-agent to use the Emacs minibuffer to (unless (string-empty-p user-full-name)
;; prompt for the key passphrase. (cl-loop for key in (ignore-errors (epg-list-keys (epg-make-context) user-full-name))
epa-pinentry-mode 'loopback)) collect (epg-sub-key-id (car (epg-key-sub-key-list key)))))
user-mail-address))
;; And suppress prompts if epa-file-encrypt-to has a default value (without
;; overwriting file-local values).
(defadvice! +default--dont-prompt-for-keys-a (&rest _)
:before #'epa-file-write-region
(unless (local-variable-p 'epa-file-encrypt-to)
(setq-local epa-file-encrypt-to (default-value 'epa-file-encrypt-to)))))
(use-package! drag-stuff (use-package! drag-stuff