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

From: Ikumi Keita <[email-masked]>
Date: Fri, 19 May 2023 20:25:15 +0900

Hi Sebastian,

>>>>> Sebastian Drude <[email-masked]> writes:
> When opening (‘finding’) the file, AucTeX does not produce the Style
> files for this file; I have to do that manually with *TeX-normal-mode*
> (C-c C-n).  But that does only produce the /./auto/main.el/ style, not
> any other style files loaded by main.

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

> I am using the langscibook class and their skeleton, which uses
> customization files starting with “local”, in particular:

> \input{/localpackages/}
> \input{/localcommands/}
> \addbibresource{/localbibliography.bib/}

> The AucTeX-style-files for these are not automatically generated
> (why?);

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.

> 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.

> 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.

> 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.

> 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.
----------------------------------------------------------------------
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.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine