last day (14 days later) » 

9:34 AM
2
Q: AUCTeX isn't loading local per-package style files, is ignoring `TeX-auto-local`

Antal Spector-ZabuskyMy AUCTeX setup isn't loading any local per-package auto-generated style files. Suppose I have a simple package doc-preamble.sty % doc-preamble.sty \usepackage{cleveref} \newcommand*{\mycmd}[1]{Hello, #1!} and I use that in doc-main.tex (in the same directory): % doc-main.tex \documentclass{...

 
Some comments unrelated to your problem: you usually don't need to add explicit require commands (this is valid in general, not just for AUCTeX); the line (setq-default TeX-master nil) is also warmly suggested, along the settings of TeX-auto-save and TeX-parse-self; starting from AUCTeX 11.88 the PDF mode is enabled by default.
I can't reproduce your problem. Did you reset the buffer of doc.tex after the file doc-preamble.el has been created? What's the value of TeX-active-styles in doc.tex buffer?
 
@giordano: I quit and reopened Emacs, for good measure, to make sure that everything was reloaded. And the value of TeX-active-styles is ("shortvrb" "doc" "LATEX")shortvrb is because I'm apparently colliding with an elisp style file doc.sty in AUCTeX's default config. I'll change the names and get back to you, although I don't think that will fix the problem.
@giordano: Alright, I renamed the file to doc-main.tex, which doesn't collide with anything (nor does doc-preamble.sty, and nor do the file names I've been working with in my real documents). Now, the value of TeX-active-styles is ("doc-preamble" "art10" "article" "latex2e" "doc-main" "LATEX"), which is even more mysterious to me! I've included that in the question. (Also, I should add that I'm sure that all of my Emacs configuration is being loaded successfully – it's not an error halfway through the file preventing the rest from being loaded.)
 
If you issue C-c C-c on both doc-preamble.sty and doc-main.tex (in this order) you should end up with TeX-active-styles being ("cleveref" "doc-preamble" "art10" "article" "latex2e" "doc-main" "LATEX"), and this would be completely normal.
 
@giordano: I don't understand something in your instructions. As it stands, C-c C-c doesn't work in doc-preamble.sty, since I can't compile a .sty file. If I add the local variable % TeX-master: "doc-main.tex", then C-c C-c doesn't do anything but View in doc-main.tex. And even if I pick LaTeX explicitly, this doesn't help.
@giordano: Also, in case you meant C-c C-n in both buffers, that doesn't change anything either. Besides, I thought part of the point of the autogeneration was that you didn't have to do these sorts of manual steps?
 
Sorry, yes, I meant C-c C-n, not C-c C-c. If TeX-auto-save is set to t (and this is your case) then C-c C-n is run whenever you save a file (so normally you don't need to run it manually), I suggested you to do so just for extra safety.
Where are your files created? In the .auctex-auto subdirectory? In *Messages* buffer you should see some messages like Loading Loading /path/to/.auctex-auto/doc-main.el (source)...done, and the same for doc-preamble.el, do you see them?
 
9:34 AM
@giordano: Indeed, the .el files are generated in .auctex-auto. After opening doc-main.tex, the *Messages* buffer just displays Starting new Ispell process /usr/local/bin/aspell with default dictionary..., Spell Checking completed., Applying style hooks... done, Mark set. And similarly for doc-preamble.sty.
 
That's really strange, after the Applying style hooks... line you should have a sequence of messages about loading of the style files, but you don't get even one (so not even for the master file). I have to think about what can be the culprit on your system (I tried once more on my system with your settings, I can't reproduce your problem).
What appears in the *Messages* buffer if you manually load the style hook with M-: (TeX-run-style-hooks "doc-main") RET in doc-main.tex buffer? Which is the value of TeX-active-style in doc-main.tex buffer afterwards?
 
@giordano: I'm glad someone else is as confused as I am. Running (TeX-run-style-hooks "doc-main") produces the result (nil), and no change in either the document behavior or TeX-active-style. I also tested running (TeX-run-style-hooks "doc-preamble"), and that doesn't do anything either.
@giordano: I even tried M-x load-file with .auctex-auto/doc-preamble.el, and that doesn't do anything except print Loading /Users/antal/temp/auctest/.auctex-auto/doc-preamble.el (source)...done. And if I follow up by running the "doc-main" hooks or loading doc-main.el explicitly, also nothing.
 
I'm more and more confused. Please, do this additional test: in doc-main.tex buffer, check the value of TeX-style-hook-list variable. You should have an entry starting with ("doc-preamble", can you please post it?
 
@giordano: At this point, I'm sure you won't be surprised to learn that the entry is just ("doc-preamble"), and similarly there's also ("doc-main"). I think the problem must be somewhere else in my configuration; I'll try to see if I can narrow it down at all. (And thank you so much for working with me on this!)
 
Ok, so my guess is that you have another doc-preamble.el file that is shadowing the one your expect. You can either look in your system for another doc-preamble.el file (the list of searched directories is held in TeX-style-path) or rename doc-preamble.sty (and the reference in doc-main) and issue C-c C-n in both the new file and doc-main.tex to be extra sure the change is applied.
 
9:34 AM
@giordano: Alas, no. There don't seem to be any other doc-preamble files on my system, and when I renamed the files to use UUIDs in their names, nothing changed.
@giordano: However! Your advice pointed me one (big!) step further towards the problem! C-h C-v TeX-style-path gives Its value is ("/usr/local/var/auctex" "/Users/antal/.emacs.d/elpa/auctex-11.89.4/style" "/Users/antal/.emacs.d/auctex/auto" "/Users/antal/.emacs.d/auctex/style" "auto" "style"), but Original value was ("/usr/local/var/auctex" "/Users/antal/.emacs.d/elpa/auctex-11.89.4/style" "/Users/antal/.emacs.d/auctex/auto" "/Users/antal/.emacs.d/auctex/style" ".auctex-auto" "style"). See: ".auctex-auto" was replaced by "auto"! My question is now "what's overwriting this?"
@giordano (I've updated the question to include the TeX-style-path information, too, since it's important and hard to read in comments.)
 
Ok, that's a very useful information and the fact that TeX-auto-local is being overridden is most probably the culprit. However, I can't reproduce the behavior you're reporting on my system, when I set TeX-auto-local as you indicated (by the way, nice idea!) that path is included in TeX-style-path. You should carefully inspect your Emacs init file and find a really minimal configuration reproducing the bug
I just checked AUCTeX source code, TeX-style-path is never set (it's only defined as a custom variable with a default value), so I'm more persuaded that there is something in your init file that is changing its value.
 
@giordano: I found the solution! It was allllll the way back in your very first comment: the explicit requires were actually harmful in this situation. THANK YOU for your help, this has been broken for ages (I think for longer than I even knew).
 
Good to see you found the problem! Please note that in AUCTeX manual there isn't a single place where (require 'tex) is suggested, it's useless and sometimes (like this one) harmful. I couldn't reproduce your problem because I copied in my init file all your configuration excluding the requires. You really should not use all those requires ;-)
 
@giordano: It's there because I wanted to tweak the values of some variables that weren't configured (I can't remember if it's necessary for adding advice or not…) – would the normally-suggested way of doing that be to use an eval-after-load form?
 

last day (14 days later) »