Emacs/Auctex : Automatically enabling/disabling LaTeX-Math-mode

标签 emacs auctex

我将 Emacs 与 AucTeX 结合使用(运行 Ubuntu 10.04,如果这很重要)。

有谁知道如果点在任何数学环境中(即在 $...$$$...$$begin{equation}...\end{equation} 等在)?

我想有一个相对简单的答案,因为语法突出显示使用相同的标准来着色数学内容,但我找不到任何东西。

最佳答案

如果 andre-r的回答不能满足你,这里有一些设置 ` 的代码在文本模式下自插入并在数学模式下充当数学模式前缀。 LaTeX-math-mode必须关闭。

(defun LaTeX-maybe-math ()
  "If in math mode, act as a prefix key for `LaTeX-math-keymap'.
Otherwise act as `self-insert-command'."
  (interactive)
  (if (texmathp)
      (let* ((events (let ((overriding-local-map LaTeX-math-keymap))
                       (read-key-sequence "math: ")))
             (binding (lookup-key LaTeX-math-keymap events)))
        (call-interactively binding))
    (call-interactively 'self-insert-command)))
(define-key LaTeX-mode-map "`" 'LaTeX-maybe-math)

以下改进留作练习:
  • 使其成为次要模式。
  • 使其对意外输入更加健壮(我只测试了基本操作)。
  • 如果用户按下未绑定(bind)的键序列,则显示更好的错误消息。
  • 如果用户按下 C-h 则显示帮助或 f1 .
  • 关于Emacs/Auctex : Automatically enabling/disabling LaTeX-Math-mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3465190/

    相关文章:

    Emacs、命名空间和定义

    node.js - 在 Emacs nodejs 模式下得到垃圾提示

    emacs - 在 Emacs-AUCTeX 中更改单词的格式而不实际选择它

    emacs - 将 Emacs AUCTeX 与 Sumatra PDF 同步

    emacs - AUCTex 问题中的预览

    emacs: C-c % 在 auctex 中做什么以及如何让它表现得更好?

    emacs - 用Clojure编写的Clojure编辑器

    emacs - P4CONFIG 与 emacs

    emacs - 在 emacs 中为文本片段着色

    Emacs + AUCTeX : How to get colored pdflatex output?