2

I am interested in installing AUCTeX on Emacs to support writing LaTeX documents. However, I would prefer to avoid the automatic activation of AUCTeX when opening LaTeX documents and only activate it manually when needed.

Is there a way to install AUCTeX on Emacs without automatically activating it when I open LaTeX documents? What variables or settings should I consider to achieve this behavior?

I mean that I would like the .tex files to be opened with the default latex-mode and not with AUCTex.

I tried:

(setq package-load-list
      '((auctex nil)
        all))

(package-initialize)

With these lines, when running the package-list-packages command, the AUCTeX package appears disabled, but the .tex files are opened with the syntax highlighting and functions provided by AUCTeX.

I tried also to look at the variable auto-mode-alist but in both cases, auctex installed or NOT, I found:

 ("\\.tex\\'" . latex-mode)

I suspect that auctex overwrites the default latex-mode.

Edit. When I run M-x decribe-mode I get:

Minor modes enabled in this buffer: Auto-Save Font-Lock

The major mode is LaTeX/P mode defined in tex-mode.el:

This function has :override advice: ‘TeX-latex-mode’.

This is an :override advice, which means that ‘latex-mode’ isn’t run at all, and the documentation below may be irrelevant.

But if I run M-x decribe-variable <RET> major-mode <RET> I get:

major-mode is a variable defined in ‘C source code’.

Its value is ‘latex-mode’ not LaTeX/P mode.

This is a little strange to me.

2
  • 1
    Do C-h f latex-mode to verify your suspicion.
    – NickD
    Feb 3 at 15:44
  • @NickD I updated my question. I think my suspicion was well-founded.
    – Gabriele
    Feb 3 at 17:10

2 Answers 2

3

From the manual:

1.2.4 Loading the package

[...]
Once activated, the modes provided by AUCTeX are used per default for all supported file types. If you want to change the modes for which it is operative instead of the default, use

M-x customize-option <RET> TeX-modes <RET>

Note that you have to use customize to set this option; don't setq it in your init file (or use setopt if you have a recent Emacs).

1

I followed the Arash Esbati answer and I noticed that the variable Tex-modes:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(TeX-modes nil)
...

is now set in my .emacs.

I tried to uninstall and reinstall auctex leaving this string in my .emacs and it works. Once set, the variable inhibits AUCTeX modes to be activated by default.

To activate the AUCTeX features you may run, e.g., M-x TeX-latex-mode. If you want to restore the default latex-mode just type M-x latex-mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.