3

In Spacemacs, how can I customize a variable used in a layer that's loaded lazily?

Specifically, I'm trying to use Zathura and Synctex with Spacemacs' Latex layer. I have the following code in my dotspacemacs/user-config.

(with-eval-after-load "tex"
  '(progn
     (add-to-list 'TeX-view-program-list
                  '("Zathura"
                    ("zathura "
                     (mode-io-correlate " --synctex-forward %n:0:%b   -x \"emacsclient +%{line} %{input}\" ")
                     " %o")
                    "zathura"))
     (add-to-list 'TeX-view-program-selection
                  '(output-pdf "Zathura"))
     (TeX-PDF-mode 1)
     ))

My intent is to mutate the variables TeX-view-program-list and TeX-view-program-selection after the Latex layer is loaded since before that the variables are free, but this code doesn't seem to be working. Note that if I explicitly evaluate those two add-to-list expressions after opening a .tex file, they have their intended effect and Spacemacs defaults to viewing with Zathura.

Does anyone know if there's a canonical way to customize the variables used in the Emacs modes provided by Spacemacs layers?

Drew
  • 75,699
  • 9
  • 109
  • 225
imperfectgrist
  • 225
  • 3
  • 6
  • You can do `M-x customize-variable RET TeX-view-program-list RET`. See [Customization](https://www.gnu.org/software/emacs/manual/html_node/emacs/Customization.html#Customization) in the Emacs manual. – Constantine Feb 12 '16 at 00:59

1 Answers1

7

Replace '(progn ...) with (progn ...)

By putting the quote there you are specifically telling emacs NOT to evaluate the code in your progn. In fact you don't need progn at all. It looks like you are trying to treat with-eval-after-load like eval-after-load. Note the signature differences:

(with-eval-after-load FILE &rest BODY)

vs

(eval-after-load FILE FORM)

This is how it should be written:

(with-eval-after-load "tex"
  (add-to-list 'TeX-view-program-list
               '("Zathura"
                 ("zathura "
                  (mode-io-correlate " --synctex-forward %n:0:%b   -x \"emacsclient +%{line} %{input}\" ")
                  " %o")
                 "zathura"))
  (add-to-list 'TeX-view-program-selection
               '(output-pdf "Zathura"))
  (TeX-PDF-mode 1))

Also note that nothing here is specific to Spacemacs, this is the same for any autoloaded Emacs package.

Jordon Biondo
  • 12,332
  • 2
  • 41
  • 62