How to load a config file encrypted with gpg?

I have one config file located in $DOOMDIR where I keep work-related elisp functions that I need to encrypt using GPG.

I used to load this file with the following code in $DOOMDIR/config.el:

(add-hook 'after-init-hook
           (lambda ()
             (load-file (expand-file-name "work.el.gpg" doom-private-dir))))

This used to work on Emacs 27 but after I upgraded to Emacs 28 it doesn’t work anymore. What is the recommended approach to load these config files in Doom?

Answering my own question, I noticed that the value of file-name-handler-alist was wrong at startup time so I changed the code above to this:

(add-hook 'after-init-hook
           (lambda ()
             (let ((file-name-handler-alist '(("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" . epa-file-handler))))
               (load-file (expand-file-name "work.el.gpg" doom-private-dir)))))

works fine again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.