emacs AUCTeX宏方化
我最近开始使用优秀的软件包emacs AUCTeX宏方化,emacs,latex,syntax-highlighting,auctex,Emacs,Latex,Syntax Highlighting,Auctex,我最近开始使用优秀的软件包xargs 它提供了\newcommandx。它的语法与默认的\newcommand类似。 我想字体锁定来反映这一点。 是的 但这只是命令名本身,而不是它的主体 (\newcommand使用'font-lock-function-name-face为主体设置字体, 在我看来,这是大胆的)。我想要\newcommmandx用'font-lock-function-name-face对其主体进行格式化 总结一下问题:如何使\newcommandx的字体设置与\newcomm
xargs
它提供了\newcommandx
。它的语法与默认的\newcommand
类似。
我想字体锁定
来反映这一点。
是的
但这只是命令名本身,而不是它的主体
(\newcommand
使用'font-lock-function-name-face
为主体设置字体,
在我看来,这是大胆的)。我想要\newcommmandx
用'font-lock-function-name-face
对其主体进行格式化
总结一下问题:如何使
\newcommandx
的字体设置与\newcommand
的字体设置完全相同(即在我的情况下为粗体)?以下是一个示例,您可以根据需要进行修改。有关预定义关键字的完整列表,请参见auctex-11.86
中font-latex.el
的第280至436行。以下示例用于添加其他关键字,和/或为波浪/方括号中的内容定义自己的颜色
;; \EFFECT{[font-lock-function-name-face]}
(setq font-latex-match-function-keywords
'(
("newcommandx" "*|{\\[[{")
)
)
;; \EFFECT{[font-lock-constant-face]}
(setq font-latex-match-reference-keywords
'(
("fancypagestyle" "[{")
("fancyhead" "[{")
("fancyfoot" "[{")
)
)
;; \EFFECT{[font-lock-type-face]}
(setq font-latex-match-textual-keywords
'(
("parentext" "{")
("hybridblockquote" "[{")
("parskip" "")
("footskip" "")
)
)
;; \EFFECT{[font-lock-variable-name-face]}
(setq font-latex-match-variable-keywords
'(
("newgeometry" "[{")
("quotingsetup" "[{")
("TabPositions" "[{")
("rfoot" "")
)
)
;; \font-latex-warning-face
(setq font-latex-match-warning-keywords
'(
("fixme" "{")
)
)
;; only affects inside wavy brackets
(setq font-latex-user-keyword-classes
'(("my-warning-commands"
(("fixme" "{"))
(:foreground "purple" :background "yellow")
command)))
另见:
我选择了以下方法来定制我的所有特殊关键字:
(defvar lawlist-face-01 (make-face 'lawlist-face-01))
(set-face-background 'lawlist-face-01 "black")
(set-face-foreground 'lawlist-face-01 "white")
(set-face-bold-p 'lawlist-face-01 t)
(set-face-italic-p 'lawlist-face-01 t)
(set-face-underline-p 'lawlist-face-01 t)
(set-face-underline 'lawlist-face-01 "yellow")
(defvar lawlist-face-02 (make-face 'lawlist-face-02))
(set-face-attribute 'lawlist-face-02 nil :background "gray" :foreground "red" :font "Courier" :height 180 :bold t :underline "yellow" :italic t)
(font-lock-add-keywords 'latex-mode '(
("\\\\test01\\|insert\\|BUGS\\|FIXME\\|TODO\\|and\\|or\\|not" 0 lawlist-face-01 prepend) ;; 0 = highlight all
("\\\\test02\\|INSERT\\|document-name\\|\\\\begin{document}" 0 lawlist-face-02 prepend) ;; 0 = highlight all
("\\test01{\\([^}]*\\)}" 1 lawlist-face-02 prepend) ;; 1 = colorize contents of wavy brackets
))
我已经更新了答案,专门针对您的问题,并在OSX Mountain Lion上用Emacs/Aquamacs的夜间构建对其进行了测试。在本例中,
\newcommandx{cmd}[args]{def}
现在的行为类似于\newcommand{cmd}[args]{def}
。请参见auctex--11.86
中font-latex.el
的第301行。
(defvar lawlist-face-01 (make-face 'lawlist-face-01))
(set-face-background 'lawlist-face-01 "black")
(set-face-foreground 'lawlist-face-01 "white")
(set-face-bold-p 'lawlist-face-01 t)
(set-face-italic-p 'lawlist-face-01 t)
(set-face-underline-p 'lawlist-face-01 t)
(set-face-underline 'lawlist-face-01 "yellow")
(defvar lawlist-face-02 (make-face 'lawlist-face-02))
(set-face-attribute 'lawlist-face-02 nil :background "gray" :foreground "red" :font "Courier" :height 180 :bold t :underline "yellow" :italic t)
(font-lock-add-keywords 'latex-mode '(
("\\\\test01\\|insert\\|BUGS\\|FIXME\\|TODO\\|and\\|or\\|not" 0 lawlist-face-01 prepend) ;; 0 = highlight all
("\\\\test02\\|INSERT\\|document-name\\|\\\\begin{document}" 0 lawlist-face-02 prepend) ;; 0 = highlight all
("\\test01{\\([^}]*\\)}" 1 lawlist-face-02 prepend) ;; 1 = colorize contents of wavy brackets
))