Considering the well-polished work on the support of tex file in Emacs by AUCTeX, it is quite confusing the support on .cls
and .sty
files is rather weak. For example, the \if
statement is never indented correctly and many macros used in class file such as \RequirePackage
is not highlighted in the right way. All of these make writing some LaTeX code in Emacs not a so pleasent thing. In this regard, the vimtex plugin of vim performs much better. I'm curious why this happens since the .cls
or .sty
file are essentially same with the tex file and there should not be too many difficulties to add some basic support for these files. Is there any plans to change this situation? Or do I overlook some existence solutions?
AUCTeX doesn't have a full-fledged TeX parser. Therefore, it's not easy to implement something which indents the \if
statements correctly.
Reg. fontification of package writing macros: This is rather easy. I'd guess they are just missing as package writers don't turn fontification on -- it gives strange results in a .dtx
or .sty
file.
At any rate, I suggest you drop a line to bug-auctex@gnu.org
. It should be discussed there.
-
Thank you for the answer. It seems a little strang to work with a language without syntax highlights nowadays. But considering the long history of tex, the package writers look like having getting used to it... – xiangsheng Mar 23 '19 at 3:36
\RequirePackage
to parse the style files. But this makes the thing more strange. If auctex does use these extra keywords to parse files, why doesn't it highlight the same keywords in the file? – xiangsheng Mar 20 '19 at 16:33\RequirePackage
is highlighted, but in fact any words starting with\
are highlighted in a default color. I expect\RequirePackage
should be highlighted as\usepackage
. Yes, I can get the right highlight if I add the keyword into some emacs variables likefont-latex-match-function-keywords
. But as Arashi Esbati in answers says, I guess auctex does turn on such fontification out of box for some reasons. – xiangsheng Mar 23 '19 at 3:09