Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
You can do M-x customize-variable RET TeX-view-program-list RET. See Customization in the Emacs manual. – Constantine Feb 12 at 0:59
up vote 7 down vote accepted

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.

share|improve this answer
    
Thanks, that did it and thanks for the explanation. I get it now. – user110524 Feb 12 at 1:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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