emacs AUCTeX macros fontification

你。 提交于 2019-12-04 11:12:05

Here is an example that you can modify to suit your needs. See lines 280 to 436 of font-latex.el within auctex-11.86 for a complete list of predefined keywords. The following examples are used to add additional keywords, and/or define your own coloration for the contents of wavy / square brackets.

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

See also: http://www.gnu.org/software/auctex/manual/auctex/Fontification-of-macros.html


I have chosen the following method to customize all of my special keywords:

(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
))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!