abo*_*abo 4 emacs latex syntax-highlighting auctex
我最近开始使用xargs
提供的优秀软件包\newcommandx.它共享类似于默认语法的语法\newcommand.我想font-lock反映一下.我做到了
(custom-set-variables
'(font-latex-user-keyword-classes
(quote (("cx" ("newcommandx" "*|{\\[[{")
(:family "font-lock-type-face") command)))))
Run Code Online (Sandbox Code Playgroud)
但是,这只是fontifies命令名称本身,而不是它的身体(\newcommandfontifies与身体'font-lock-function-name-face,这在我的情况是粗体).我想\newcommandx用它来塑造它的身体'font-lock-function-name-face.
总结一个问题:如何使fontification \newcommandx完全相同\newcommand(即在我的情况下是大胆的身体)?
以下是您可以根据需要进行修改的示例.见线280至436 font-latex.el内的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)))
Run Code Online (Sandbox Code Playgroud)
另见: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
))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
810 次 |
| 最近记录: |