Subject: bug#24783: 25.1 launchs gpg-agent --homedir as ~/.emacs.d/elpa/gnupg

From: [email-masked]
Date: Sat, 12 Nov 2016 09:14:16 -0500

Fkqqrr <[email-masked]> writes:

> I am running Emacs 25.1 under Gentoo.
>
> Each time I run `list-packages', Emacs 25.1 launchs Gnupg-2.1 gpg-agent,
> but the `--homedir' argument is set to `~/.emacs.d/elpa/gnupg' though I
> have it to `~/.gnupg' in `~/.gnupg/gpg-agent.conf'.
>

According to `(gnupg) Agent Options':

'--homedir DIR'
     Set the name of the home directory to DIR.  If this option is not
     used, the home directory defaults to '~/.gnupg'.  It is only
     recognized when given on the command line.

So setting this in gpg-agent.conf wouldn't work (which makes sense,
since you need to know the homedir in order to find the configuration
file).

>
> However if `gpg-agent' is launched before `list-package', Emacs 25.1
> will respect that.

There is some code package.el that changes the gpg homedir:

(defun package-import-keyring (&optional file)
  "Import keys from FILE."
  (interactive "fFile: ")
  (setq file (expand-file-name file))
  (let ((context (epg-make-context 'OpenPGP))
        (homedir (expand-file-name "gnupg" package-user-dir)))
    (with-file-modes 448
      (make-directory homedir t))
    (setf (epg-context-home-directory context) homedir)
    (message "Importing %s..." (file-name-nondirectory file))
    (epg-import-keys-from-file context file)
    (message "Importing %s...done" (file-name-nondirectory file))))

Perhaps this setf should be a letf instead?