TLDR: Use latex-mode
or LaTeX-mode
(they mean the same thing), no need to change auto-mode-alist
, and use LaTeX-mode-hook
for hooking into AucTeX.
Setting up AucTeX can be quite confusing, because it uses advice to override Emacs' built-in support for TeX and friends.
So, after installing AucTeX from ELPA, you should see the following in C-h f latex-mode
:
This function has :override advice: ‘TeX-latex-mode’.
Same for all the other tex modes, though the list of modes that AucTeX overrides depends on the value of the TeX-modes
variable.
The function LaTeX-mode
is not defined in AucTeX (any more?): it's defined in core Emacs, with a cryptic comment about compatibility:
;; The following three autoloaded aliases appear to conflict with
;; AUCTeX. However, even though AUCTeX uses the mixed case variants
;; for all mode relevant variables and hooks, the invocation function
;; and setting of `major-mode' themselves need to be lowercase for
;; AUCTeX to provide a fully functional user-level replacement. So
;; these aliases should remain as they are, in particular since AUCTeX
;; users are likely to use them.
;; Note from Stef: I don't understand the above explanation, the only
;; justification I can find to keep those confusing aliases is for those
;; users who may have files annotated with -*- LaTeX -*- (e.g. because they
;; received them from someone using AUCTeX).
;;;###autoload
(defalias 'TeX-mode #'tex-mode)
;;;###autoload
(defalias 'plain-TeX-mode #'plain-tex-mode)
;;;###autoload
(defalias 'LaTeX-mode #'latex-mode)
What this all means is that, at least in 2021, you do not need to change auto-mode-alist
to use AucTeX; just installing it is enough for it to override Emacs' builtin functionality.
Unfortunately, there's one last source of confusion. Even though LaTeX-mode
is now mostly just a useless alias for latex-mode
, it turns out that code in AucTeX that overrides latex-mode
does not call latex-mode-hook
(it calls LaTeX-mode-hook
, which is different. So the LaTeX-
variables, which are the AucTeX ones (as opposed to the lowercase ones that are builtin with Emacs), are still useful.
LaTeX-mode
seems to be an alias oflatex-mode
, andTeX-latex-mode
is a mode defined by AUCTeX (version 12.3). Anyways, I am completely confused. If i want to set keybindings, which map do I use:latex-mode-map
orLaTeX-mode-map
or both? – Brevity