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

From: Sebastian Drude <[email-masked]>
Date: Thu, 18 May 2023 12:32:29 -0300

Hello, friendly AucTeX help community,

I am not sure whether I did miss something or something is genuinely not 
working as it should.

I am testing with a minimal (La)TeX-file, main.tex, with the following 
local variables set at the bottom:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-engine: xetex
%%% TeX-auto-save: t
%%% TeX-parse-self: t
%%% End:

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.

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?); 
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).

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.

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.

Even when I manually add "IL-format" to the TeX-run-style-hooks in the 
TeX-add-style-hook in ./auto/main.el and load the main.tex file again, 
the commands are not available.

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?) would be that the main style file and the 
dependent style files are generated automatically in ./auto when I open 
and parse the file /main.tex/, at least when I parse it manually with 
*TeX-normal-mode*.

Then I would expect a style file for the /localpackages.tex/ file to be 
generated, at least when I manually generate all style files in my 
current directory, and in particular when I run *TeX-auto-generate* 
directly on that file.

And finally, I would AucTeX expect to load the existing style file for 
my own macro package /IL-format.sty/ in /~/.emacs.d/auctex/auto//, in 
particular when I put that file in the list of TeX-run-style-hooks in 
the style file /./auto/main.el/ that is loaded when parsing /main.tex/.

I annex the relevant files, and the configuration below shows that my 
paths should be configured correctly.

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.

Thanks in advance for all help!

Sebastian

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.30, cairo version 1.16.0)
  of 2022-01-24, modified by Debian
Package: 13.2.0

current state:
==============
(setq
  AUCTeX-date "2023-04-24"
  window-system 'x
  LaTeX-version "2e"
  TeX-style-path '("~/.emacs.d/auctex" 
"/home/sebastian/.emacs.d/elpa/auctex-13.2.0/style"
           "/home/sebastian/.emacs.d/auctex/auto" 
"/home/sebastian/.emacs.d/auctex/style" "auto" "style")
  TeX-auto-save t
  TeX-parse-self t
  TeX-master t
  TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) 
%`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t"
              TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) 
:help "Run plain TeX")
             ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode 
doctex-mode) :help "Run LaTeX")
             ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" 
TeX-run-compile nil (texinfo-mode) :help
              "Run Makeinfo with Info output")
             ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" 
TeX-run-compile nil (texinfo-mode) :help
              "Run Makeinfo with HTML output")
             ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' 
%(output-dir) %t" TeX-run-TeX nil
              (ams-tex-mode) :help "Run AMSTeX")
             ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) 
%(execopts)%t" TeX-run-TeX nil (context-mode)
              :help "Run ConTeXt once")
             ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" 
TeX-run-TeX nil (context-mode) :help
              "Run ConTeXt until completion")
             ("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode context-mode) :help "Run BibTeX")
             ("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help "Run Biber")
             ("Texindex" "texindex %s.??" TeX-run-command nil 
(texinfo-mode) :help "Run Texindex")
             ("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil 
(texinfo-mode) :help "Run Texi2dvi or Texi2pdf")
             ("View" "%V" TeX-run-discard-or-function t t :help "Run 
Viewer")
             ("Print" "%p" TeX-run-command t t :help "Print the file")
             ("Queue" "%q" TeX-run-background nil t :help "View the 
printer queue" :visible TeX-queue-command)
             ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help "Generate PostScript file")
             ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Convert DVI file to PostScript")
             ("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Convert DVI file to PDF with dvipdfmx")
             ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Convert PostScript file to PDF")
             ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Run makeglossaries to create glossary file")
             ("Index" "makeindex %(O?idx)" TeX-run-index nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Run makeindex to create index file")
             ("upMendex" "upmendex %(O?idx)" TeX-run-index t
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Run upmendex to create index file")
             ("Xindy" "texindy %s" TeX-run-command nil
              (plain-tex-mode latex-mode doctex-mode ams-tex-mode 
texinfo-mode) :help
              "Run xindy to create index file")
             ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) 
:help "Check LaTeX file for correctness")
             ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode) 
:help
              "Check LaTeX file for common mistakes")
             ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil 
t :help "Spell-check the document")
             ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete 
generated intermediate files")
             ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
              "Delete generated intermediate and output files")
             ("Other" "" TeX-run-command t t :help "Run an arbitrary 
command"))
  )