簡體   English   中英

Emacs / Auctex:自動啟用/禁用LaTeX-Math模式

[英]Emacs/Auctex: Automatically enabling/disabling LaTeX-Math-mode

我正在將Emacs與AucTeX結合使用(運行Ubuntu 10.04,如果這很重要的話)。

有沒有人知道是否有辦法自動啟用LaTeX-math-mode(AucTeX的次要模式),如果該點在任何數學環境中(即$...$ ,a $$...$$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)

以下改進留作練習:

  • 使它成為次要模式。

  • 使其對意外輸入更加穩健(我只測試了基本操作)。

  • 如果用戶按下未綁定的鍵序列,則顯示更好的錯誤消息。

  • 如果用戶按Chf1則顯示幫助。

LaTeX-math-mode“用於輸入帶有許多數學符號的文本的特殊次要模式”。 (對於那些不知道怎么做的人,你按下例如'A並得到\\ forall。)所以我想如果你沒有輸入數學也沒有傷害它。

因此,信息頁面建議:

(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

恕我直言,唯一的缺點是你必須按兩次前綴:``得到`,至少可以使用在LaTeX-math-abbrev-prefix定制的標准前綴`。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM