0

I have a setting in my Spacemacs dotfile that adds Make as a compile option for a latex document. The actual command is below.

(add-to-list 'TeX-command-list 
            '("Make" "make" TeX-run-compile nil t))

For some reason this command seems to generate a error. The specific message is:

 (Spacemacs) Error in dotspacemacs/user-config: Symbol’s value as variable is void: TeX-command-list

Is there a better way to write this command, or has the api for the Tex-command-list command, etc?

1

There are several ways to fix that issue:

  1. TeX-command-list is defined in tex.el. Use (require 'tex) before your (add-to-list 'TeX-command-list ...). That is the smallest change. But you always load tex.el at startup time.

  2. Put your code into eval-after-load such that it is evaluated after TeX-command-list is defined in tex.el.

(eval-after-load "tex.el"
   '(add-to-list 'TeX-command-list
                 '("Make" "make" TeX-run-compile nil t)))
  1. You can customize TeX-command-list over M-x customize-option. That is the normal way to do it. (But see my note at the bottom.)

  2. Put (add-to-list 'TeX-command-list ...) into a hook function for TeX-mode-hook. That is slightly better than the first approach since you don't need to load tex.el at startup. With respect to the second approach it has the disadvantage that the code runs every time when you load a TeX-file. The following code demonstrates that approach:

(defun my-TeX-mode-hook-fun ()
  (add-to-list 'TeX-command-list '("Make" "make" TeX-run-compile nil t)))

(add-hook 'TeX-mode-hook #'my-TeX-mode-hook-fun)

Note: I don't know spacemacs. So I am not sure whether the vanilla customization interface works well with spacemacs.

  • Yeah, this worked just fine. Thanks so much @Tobias. I used option 2. I could have used the customize-option, which does work with spacemacs as well. I just like having the explicit code of option 2 because I tend to regenerate my custom variables frequently, and I just worry I will forget to set that again, or lose it during the regeneration process--and then won't remember how to fix it :). – krishnab Sep 12 '18 at 20:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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