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?

1
  • You can do M-x customize-variable RET TeX-view-program-list RET. See Customization in the Emacs manual. Commented Feb 12, 2016 at 0:59

1 Answer 1

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.

1
  • Thanks, that did it and thanks for the explanation. I get it now. Commented Feb 12, 2016 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.