0

现代文字处理器的一个很好的特性是可以在不实际选择单词的情况下更改单词的格式(例如,从罗马到斜体)。只需将文本光标放在单词中并告诉文字处理器(通过键盘快捷键)更改其格式。(智能编辑,我相信有时会被称为。)

在 Emacs-AUCTeX 中有没有办法做到这一点?(更改格式的常用方法——即插入格式命令——是选择单词[标记其区域],然后按下命令的组合键[例如C-c C-f C-i插入\textit{}]。)

4

2 回答 2

1

如果没有直接的解决方案,Emacs 提供两种方法,一旦知道命令/键的连续性:

要么将它们存储到键盘宏中,只需一个键即可调用 - 或者将所有命令放入一个函数中,使其成为命令,分配一个键。

于 2013-09-01T07:46:48.433 回答
1

快捷方式C-c C-f调用TeX-font. 然后它根据最后一个关键和弦强调/斜体/无论如何。所以解决方案是建议这个函数:

(defvar TeX-font-current-word t)

(defadvice TeX-font (before TeX-font-word (replace what))
  "If nothing is selected and `TeX-font-current-word' is not nil,
mark current word before calling `TeX-font'."
  (when (and TeX-font-current-word 
             (not replace)
             (not (region-active-p))
             (not (looking-at "\\s-")))
    (unless (looking-back "\\s-") (backward-word))
    (mark-word)))

(ad-activate 'TeX-font)

现在,当没有选择区域时,TeX-font将像选择当前单词一样工作。您可以通过设置/TeX-font-current-word来打开/关闭此行为。tnil

于 2013-09-01T09:52:38.227 回答