![](/img/trans.png)
[英]How to disable auctex fontification, without losing color highlighting?
[英]emacs AUCTeX macros fontification
我最近開始使用提供\\newcommandx
的優秀包xargs
。 它共享類似於default \\newcommand
的語法。 我想使用font-lock
來反映這一點。 我做到了
(custom-set-variables
'(font-latex-user-keyword-classes
(quote (("cx" ("newcommandx" "*|{\\[[{")
(:family "font-lock-type-face") command)))))
但這只是命令名稱本身,而不是它的主體( \\newcommand
使用'font-lock-function-name-face
,在我的例子中為粗體) \\newcommand
構造主體。 我希望\\newcommandx
用'font-lock-function-name-face
來表現它的身體。
要總結的問題是:如何使fontification為\\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)))
另見: 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
))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.