0

With latex-mode, is there any way to obtain more than three (3) levels of highlighting?

I would like to control more than three levels of highlighting, however, it appears as though latex-mode may be limited to three (3) levels. I say this because Emacs complains when attempting a fourth level -- Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument listp prepend). The following is just an example of an attempt to control four (4) levels, which gave the error message listed above.

(defvar lawlist-face-a (make-face 'lawlist-face-a))
(set-face-attribute 'lawlist-face-a nil :foreground "orange")

(defvar lawlist-face-b (make-face 'lawlist-face-b))
(set-face-attribute 'lawlist-face-b nil :foreground "cyan")

(defvar lawlist-face-c (make-face 'lawlist-face-c))
(set-face-attribute 'lawlist-face-c nil :foreground "blue")

(defvar lawlist-face-d (make-face 'lawlist-face-d))
(set-face-attribute 'lawlist-face-d nil :foreground "red")


(font-lock-add-keywords 'latex-mode '(

("\\(\\\\begin\\|\\\\end\\)\\(\{\\)\\(document\\)\\(\}\\)" (1 lawlist-face-a) (2 lawlist-face-b) (3 lawlist-face-c) (4 lawlist-face-d) prepend)

))

I tried adding (setq font-lock-support-mode 'lazy-lock-mode), which caused a freeze. I also tried adding (setq font-lock-maximum-decoration t), which didn't seem to have any appreciable effect.

4

1 回答 1

2

The prepend atom needs to be outside the quoted list, as the last argument to font-lock-add-keywords:

(font-lock-add-keywords
 'latex-mode
 '(("\\(\\\\begin\\|\\\\end\\)\\(\{\\)\\(document\\)\\(\}\\)" (1 lawlist-face-a) (2 lawlist-face-b) (3 lawlist-face-c) (4 lawlist-face-d)))
 'prepend)
于 2013-05-19T18:17:08.680 回答