gpt4 book ai didi

emacs AUCTeX 宏字体化

转载 作者:行者123 更新时间:2023-12-05 01:08:56 33 4
gpt4 key购买 nike

我最近开始使用优秀的包 xargs提供 \newcommandx .它共享类似于默认 \newcommand 的语法。 .
我要 font-lock来反射(reflect)这一点。
我做了

(custom-set-variables
'(font-latex-user-keyword-classes
(quote (("cx" ("newcommandx" "*|{\\[[{")
(:family "font-lock-type-face") command)))))

但这只是使命令名称本身字体化,而不是它的正文
( \newcommand'font-lock-function-name-face 对正文进行字体化,
在我的情况下是大胆的)。我要 \newcommandx'font-lock-function-name-face 字体化它的 body .

总结一下问题:如何为 \newcommandx做字体化与 \newcommand 完全相同(即在我的情况下大胆的 body )?

最佳答案

下面是一个示例,您可以对其进行修改以满足您的需要。参见 font-latex.el 的第 280 到 436 行内auctex-11.86预定义关键字的完整列表。以下示例用于添加其他关键字,和/或为波浪形/方括号的内容定义您自己的颜色。

;; \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)))

另见: http://www.gnu.org/software/auctex/manual/auctex/Fontification-of-macros.html

我选择了以下方法来自定义我的所有特殊关键字:
(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
))

关于emacs AUCTeX 宏字体化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16338466/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com