在 Emacs 中新增 AUCTeX 的鍵盤快速鍵

在 Emacs 中新增 AUCTeX 的鍵盤快速鍵

免責聲明:這是一個關於 Emacs 和 AUCTeX 的問題。抱歉,如果這超出了 tex.sx 的範圍。

如何為 AUCTeX 新增指令?

我希望我的 AUCTeX 模式讓命令C-c C-f C-p插入 a \pname{ },其行為與更改字體的其他方式類似,例如C-c C-f C-efor \emph{ }.

手冊頁更改字體,解釋說

AUCTeX 提供了方便的鍵盤快速鍵來插入宏,這些宏指定用於排版文字某些部分的字體。它們以 開頭C-c C-f,最後一個C-組合告訴 AUCTeX 您想要哪一種字體

Font list:   KEY        TEXTFONT           MATHFONT

         C-a                          \mathcal{ }  
         C-b        \textbf{ }         \mathbf{ }  
         C-c        \textsc{ }                     
         C-e          \emph{ }                     
         C-f        \textsf{ }         \mathsf{ }  
         TAB        \textit{ }         \mathit{ }  
         RET        \textmd{ }                     
         C-n    \textnormal{ }     \mathnormal{ }  
         C-r        \textrm{ }         \mathrm{ }  
         C-s        \textsl{ }         \mathbb{ }  
         C-t        \texttt{ }         \mathtt{ }  
         C-u        \textup{ }                     
         C-d  -- delete font

我想將命令綁定C-c C-f C-p\pname{ }AUCTeX 模式。

答案1

AUCTeX 實際上讓這變得非常簡單:自訂LaTeX-font-list.

(add-to-list 'LaTeX-font-list
  '(?\C-p "\\pname{" "}"))

應該管用。LaTeX-mode如果有任何開啟的緩衝區,則必須在適當的緩衝區中重新運行。


請注意,這必須做完了 LaTeX-font-list已定義於latex.el.這是一個簡單的配置use-package:

(use-package latex
  :ensure auctex
  :config
  (add-to-list 'LaTeX-font-list
               '(?\C-p "\\pname{" "}")))

相關內容