Subject: bug#63573: 13.2.0; automatic style generation & loading unclear / does not work as expected

From: Sebastian Drude <[email-masked]>
Date: Thu, 25 May 2023 19:10:27 -0300

Dear Ikumi,

thanks a lot for your helpful answers, and sorry for my late reply.

My comments below.

Thanks again, best greetings,
Sebastian

> TeX-normal-mode generates style files for the current buffer only.

Right.  I would have expected that also missing AucTeX style files for 
the LaTeX-styles of the current buffer would be generated.

> AUCTeX generates style files, when `TeX-auto-save' is non-nil, only when
> it saves the document file; it doesn't when it opens the document file.

Okay.  Still, I have opened and closed the file several times.

>> I have to do that with *TeX-auto-generate* on the directory.
>> Then, the style file for /localcommands.tex/ and
>> /localbibliography.bib/ are generated (I put them into the
>> ./auto/-directory).
> Those are expected behaviors.

Fine.

>> But there is no style file for localpackages.tex. For testing, it
>> contains only one command: \usepackage{/IL-format/}. Even when I run
>> *TeX-auto-generate* manually directly on the localpackages.tex file,
>> no style file seems to be generated.  This appears really odd and
>> unexpected to me.
> Add local variables section to localpackages.tex file like this:
> ----------------------------------------------------------------------
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: "main"
> %%% End:
> ----------------------------------------------------------------------
> You can use C-c _ (TeX-master-file-ask) in the buffer to add this part.
>
> Without the "mode: latex" tag, AUCTeX doesn't recognize that this is
> LaTeX file and regards it as plain TeX file instead. That's the reason
> that `TeX-auto-generate' didn't work for you; plain TeX parsing routine
> doesn't know \usepackage.

Okay, this makes sense, and thanks, this worked.

>> The style file for /IL-format.sty/ is in ~/.emacs.d/auctex/auto/, so
>> it should be accessible to AucTeX, but it is not loaded: its commands
>> are not available when editing main.tex.
> The above local variable section solves this issue at the same time.

Correct!

>> The expected behavior, from what I understand from the documentation
>> (but this is not really spelled out, or am I missing something?  where
>> is that explained in detail?)
> I admit that its detail isn't documented.
> https://www.gnu.org/software/auctex/manual/auctex/Multifile.html#Multifile
> ----------------------------------------------------------------------
> [...] Each time you save a file, AUCTeX will write information about the
> file into the ‘auto’ directory. When you load a file, AUCTeX will read
> the information in the ‘auto’ directory about the file you loaded and
> the master file specified by TeX-master. [...]
>
> AUCTeX will create the ‘auto’ directory automatically if TeX-auto-save
> is non-nil.

Yes, I read that, but indeed, the info on my problems are not really 
addressed.

> ----------------------------------------------------------------------
> https://www.gnu.org/software/auctex/manual/auctex/Parsing-Files.html#Parsing-Files
> ----------------------------------------------------------------------
> [...] The latter command will make AUCTeX store the parsed information
> in an ‘auto’ subdirectory in the directory each time the TeX files are
> stored
> ----------------------------------------------------------------------
> https://www.gnu.org/software/auctex/manual/auctex/Automatic-Local.html#Automatic-Local
> ----------------------------------------------------------------------
> AUCTeX can update the style information about a file each time you save
> it if TeX-auto-save option is enabled. Saved information will be stored
> in the directory TeX-auto-local, set to ‘"auto"’ by default.
> ----------------------------------------------------------------------
>
>> Where is the generation of style files and their loading described?  I
>> found the information in the AucTeX manual (info) not very helpful for
>> answering these questions.  But as I said, probably I am missing
>> something.  Please point me to the documentation that I was not able
>> to find.
> Sorry for inconvenience. Maybe AUCTeX document should have more detailed
> information about such topics.

Agreed.  Once more, thank you for being so helpful (and quick), this 
makes up for the not very detailed info in the manual.

> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine