6

I was playing around with my .emacs, and I cannot figure out why the following does not work with .tex files:

(add-hook 'tex-mode-hook
  (lambda () 
    (show-paren-mode t)))

On the other hand, the following does work on elisp files.

(add-hook 'emacs-lisp-mode-hook
  (lambda () 
    (show-paren-mode t)))

Actually, just having the elisp hook is sufficient to enable paren mode on .tex files. I'm not sure what's going on.

Running 24.5.1 on OS X with auctex installed.

6
  • Everyone who uses AUCTex gets confused between the built-in tex-mode.el and AUCTex which does not ship with Emacs. The hooks that AUCTex uses are similar looking, but are different -- here is a link t the manual describing common hooks used in AUCTex: gnu.org/software/auctex/manual/auctex/Modes-and-Hooks.html
    – lawlist
    Jun 21, 2016 at 19:08
  • When in a .tex file, I used M-x describe-mode, and it stated that both tex-mode-hook and latex-mode-hook are invoked however.
    – bernie
    Jun 21, 2016 at 19:10
  • But you're correct, changing tex-mode-hook to LaTeX-mode-hook made things work
    – bernie
    Jun 21, 2016 at 19:12
  • I guess i missed the line :override advice: `TeX-latex-mode' in describe-mode
    – bernie
    Jun 21, 2016 at 19:26
  • BTW, instead of (lambda () (show-paren-mode 1)) you can just write #'show-paren-mode.
    – Stefan
    Jun 25, 2016 at 23:08

1 Answer 1

6

If you have AUCTeX installed, then you're presumably using AUCTeX's modes, so the hooks you need to use have names of the form TeX-mode-hook and LaTeX-mode-hook (note the capitalization).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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