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.

bernie
  • 609
  • 4
  • 11
  • 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: https://www.gnu.org/software/auctex/manual/auctex/Modes-and-Hooks.html – lawlist Jun 21 '16 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 '16 at 19:10
  • But you're correct, changing tex-mode-hook to LaTeX-mode-hook made things work – bernie Jun 21 '16 at 19:12
  • I guess i missed the line :override advice: \TeX-latex-mode'indescribe-mode` – bernie Jun 21 '16 at 19:26
  • BTW, instead of (lambda () (show-paren-mode 1)) you can just write #'show-paren-mode. – Stefan Jun 25 '16 at 23:08
  • I never understood what #' means. Can I omit the #? – bernie Jun 28 '16 at 15:20

1 Answers1

8

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).

Stefan
  • 26,404
  • 3
  • 48
  • 85