I'm not sure if this is possible or if there's a workaround for it, but I want M-x erc
to set the password after I try to call it, but before I input the actual parameters.
What I originally had in my init.el was
(let ((erc-plist (car (auth-source-search :host "irc.freenode.net"))))
(setq erc-server "irc.freenode.net")
(setq erc-nick (plist-get erc-plist :user))
(setq erc-password (funcall (plist-get erc-plist :secret))))
But this runs on startup, which is less than ideal because I run Emacs as a systemd user unit, and it needs to decrypt authinfo.gpg
So I tried to create an advice like the following:
(defadvice erc (:before (&key (server (erc-compute-server))
(port (erc-compute-port))
(nick (erc-compute-nick))
password
(full-name (erc-compute-full-name))))
"Set up nick and password before running ERC."
(let ((erc-plist (car (auth-source-search :host "irc.freenode.net"))))
(setq erc-server "irc.freenode.net")
(setq erc-nick (plist-get erc-plist :user))
(setq erc-password (funcall (plist-get erc-plist :secret)))))
But the advice will only run after I input the parameters from ERC, so it's already too late.
I also use helm, so if it's possible to add some hook for helm to run a function right after I select erc from the menu, it would solve my problem.