简体   繁体   English

LaTeX模式挂钩无法通过AUCTeX(11.87.3)加载到emacs(24.3.50)中

[英]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 由于我更新为emacs 24,因此无法让AUCTeX加载LaTeX模式挂钩,例如

(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. Ch m告诉我,我的主要模式是Major mode in AUCTeX for editing LaTeX files.
  2. the AUCTeX mode help states: AUCTeX模式帮助说明:

     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. 其他模式(例如Markdown或Python)的钩子也可以工作。

And, of course, I have tested that manual activation, eg Mx visual-line-mode , does work. 而且,当然,我已经测试了手动激活(例如Mx visual-line-mode )是否有效。

Thanks! 谢谢!

This is strange Ch m gives me Ch m给我的感觉很奇怪

Entering Latex mode runs the hook text-mode-hook', then tex-mode-hook', and finally `latex-mode-hook'. 进入Latex模式运行钩子text-mode-hook', then tex-mode-hook',最后是'latex-mode-hook'。

Notice that it is latex-mode-hook and not LaTeX-mode-hook . 请注意,它是latex-mode-hook而不是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. 编辑 -我没有安装auctex,也许这解释了为什么帮助消息对我们来说有所不同,请忽略上面的部分。 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. 正如在其他答案的注释中指出的那样,此问题是由AucTeX无法创建XPM图像引起的。 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. 当未使用libxpm库编译Emacs时(当您主要在自己喜欢的终端仿真器中运行Emacs时可能会发生这种情况)。

Anyways, you can still correct this issue without recompiling Emacs. 无论如何,您仍然可以在不重新编译Emacs的情况下解决此问题。 In fact, the images are only used for the AucTeX toolbar. 实际上,图像仅用于AucTeX工具栏。 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. .emacs (或.emacs.d/init.el )文件。

This snippet simply checks if XPM images are available in the Emacs installation and if not, it disables the toolbar. 此代码段仅检查Emacs安装中是否存在XPM映像,否则,将禁用工具栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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