简体   繁体   中英

LaTeX-mode hooks not loading in emacs (24.3.50) with AUCTeX (11.87.3)

Since I updated to emacs 24 I cannot get AUCTeX to load the LaTeX-mode hooks, eg

(add-hook 'LaTeX-mode-hook 'visual-line-mode)

despite:

  1. Ch m tells me that my major mode is Major mode in AUCTeX for editing LaTeX files.
  2. the AUCTeX mode help states:

     Entering LaTeX mode calls the value of `text-mode-hook', then the value of `TeX-mode-hook', and then the value of `LaTeX-mode-hook'. 

    (Indeed, the text-mode hooks are not loaded either.)

Hooks for other modes (eg for Markdown or Python) do work.

And, of course, I have tested that manual activation, eg Mx visual-line-mode , does work.

Thanks!

This is strange Ch m gives me

Entering Latex mode runs the hook text-mode-hook', then tex-mode-hook', and finally `latex-mode-hook'.

Notice that it is latex-mode-hook and not LaTeX-mode-hook .

EDIT - I do not have auctex installed maybe that explains why the help messages are different for us, ignore the part above. You can try the below as an alternative

(add-hook 'latex-mode-hook 'visual-line-mode)

As is noted in the comments in the other answer, this issue is caused by AucTeX being unable to create XPM images. This occurs when when Emacs is not compiled with the libxpm library, which might be the case when you run Emacs primarily inside your favorite terminal emulator.

Anyways, you can still correct this issue without recompiling Emacs. In fact, the images are only used for the AucTeX toolbar. Thus, disabling it will effectively remove the problem altogether. You can do this by adding:

(unless (image-type-available-p 'xpm)
  (setq LaTeX-enable-toolbar nil))

To your .emacs (or .emacs.d/init.el ) file.

This snippet simply checks if XPM images are available in the Emacs installation and if not, it disables the toolbar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM