# Emacs+AUCTeX: improve emacs support on cls and sty file

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?

• Ensure you read gnu.org/software/auctex/manual/auctex/FAQ.html where there is at least one hint related to style support etc
– user170109
Mar 19, 2019 at 14:50
• Thank you for the comment. The link seems only to say that auctex can use the keywords like `\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? Mar 20, 2019 at 16:33
• You could check relevant settings such as LaTeX environments and TeX groups in comments will be indented syntactically correct if the variable LaTeX-syntactic-comments is set to t. If you disable it, comments will be filled like normal text and no syntactic indentation will be done. The check for the indentation function may be enabled or disabled by customizing the variable LaTeX-indent-environment-check.
– user170109
Mar 21, 2019 at 21:21
• One common trick you may or may not have tried is sometimes the syntax highlighting goes wrong and normal text is coloured as being mathematics and vice-versa. C-c C-n (which runs TeX-normal-mode) refreshes the highlighting and may fix this (until it happens again). There are a number of similar comments linked starting here tex.stackexchange.com/questions/88609/…
– user170109
Mar 21, 2019 at 21:37
• As I understand, the syntax highlighting does not go wrong, instead they just not get setted. Keywords like `\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 like `font-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. Mar 23, 2019 at 3:09

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.