0

So, inspired by this article. I decided to try adding the following to my init.el:

 (setq custom-file (expand-file-name "secret.el" user-emacs-directory))
 (load custom-file)

Where the file in question (secret.el) has:

# -*- epa-file-encrypt-to: ("kramer@example.com") -*-
(setq jabber-account-list ...)
(setq my-secret-password "rosebud")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(abbrev-mode t)
'(auto-save-default nil)
'(comment-column 2)
 )

Along with necessary variables. However I can't seem to work with this. Inspite of having my password authentication set such that I can use gpg -d from the commandline without a password prompt, and am able to edit it transparently without the line.

My precise error is:

Debugger entered--Lisp error: (void-variable \205)
  eval-buffer(#<buffer  *load*-77127> nil "/home/haozeke/.config/doom/local/private.el.gpg" nil t)  ; Reading at buffer position 2
  load-with-code-conversion("/home/haozeke/.config/doom/local/private.el.gpg" "/home/haozeke/.config/doom/local/private.el.gpg" nil n$
  load("/home/haozeke/.config/doom/local/private.el.gpg")
  eval-buffer(#<buffer  *load*-596012> nil "/home/haozeke/.config/doom/config.el" nil t)  ; Reading at buffer position 12972
  load-with-code-conversion("/home/haozeke/.config/doom/config.el" "/home/haozeke/.config/doom/config.el" t nil)
  load("/home/haozeke/.config/doom/config" t nil)
  (condition-case e (load (expand-file-name "config" doom-private-dir) t nil) ((debug doom-error) (signal (car e) (cdr e))) ((debug e$
  (if noninteractive nil (if doom-modules (progn (maphash (function (lambda (key plist) (let (... ...) (condition-case e ... ... ...)$
  (progn (if doom-modules (progn (maphash (function (lambda (key plist) (let (... ...) (condition-case e ... ... ...)))) doom-modules$
  (if (condition-case e (load (expand-file-name "init" doom-private-dir) t nil) ((debug doom-error) (signal (car e) (cdr e))) ((debug$
Quit

Now, I realized I might need to actually load the right packages before, so I amended my init.el to :

(require 'epa-file)
(epa-file-enable)
(setq custom-file (expand-file-name "secret.el" user-emacs-directory))
(load custom-file)

So that changes the error to:

Debugger entered--Lisp error: (invalid-read-syntax "#")
  read(#<buffer  *load*-61450>)
  eval-buffer(#<buffer  *load*-61450> nil "/home/haozeke/.config/doom/local/private.el.gpg" nil t)  ; Reading at buffer position 66
  load-with-code-conversion("/home/haozeke/.config/doom/local/private.el.gpg" "/home/haozeke/.config/doom/local/private.el.gpg" nil n$
  load("/home/haozeke/.config/doom/local/private.el.gpg")
  eval-buffer(#<buffer  *load*-27802> nil "/home/haozeke/.config/doom/config.el" nil t)  ; Reading at buffer position 13010
  load-with-code-conversion("/home/haozeke/.config/doom/config.el" "/home/haozeke/.config/doom/config.el" t nil)
  load("/home/haozeke/.config/doom/config" t nil)
  (condition-case e (load (expand-file-name "config" doom-private-dir) t nil) ((debug doom-error) (signal (car e) (cdr e))) ((debug e$
  (if noninteractive nil (if doom-modules (progn (maphash (function (lambda (key plist) (let (... ...) (condition-case e ... ... ...)$
  (progn (if doom-modules (progn (maphash (function (lambda (key plist) (let (... ...) (condition-case e ... ... ...)))) doom-modules$
HaoZeke
  • 145
  • 4

1 Answers1

0

It turns out that my setup after requiring the files was ok, but the file itself was wrongly formatted. So a working example is then the following: init.el:

(require 'epa-file)
(epa-file-enable)
(setq custom-file (expand-file-name "secret.el" user-emacs-directory))
(load custom-file)

and the following file:

;;;; -*- epa-file-encrypt-to: ("kramer@example.com") -*-
(setq jabber-account-list ...)
(setq my-secret-password "rosebud")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(abbrev-mode t)
'(auto-save-default nil)
'(comment-column 2)
 )

Then everything works as it should.

HaoZeke
  • 145
  • 4