font-lock-keyword-face
is used by AUCTeX for all keywords, and I have not been able to find a way to create a new keyword that is a different color.
I have defined the foreground of font-lock-keyword-face
to be the color red (with a white background), which affects every defined keyword.
I would like to create my own keyword that stands out from all the rest — e.g., :foreground "yellow" :background "black".
\insert-data
It looks like there are only three (3) major groups available:
-
keywords
(controlled byfont-lock-keyword-face
); -
warnings
(controlled byfont-latex-warning-face
); and -
undefined-keywords
(controlled byfont-latex-sedate-face
).
All the examples on the internet appear to focus on changing the color inside square / wavy brackets using the variable font-latex-user-keyword-classes
. I have not found any working examples where a new keyword group (with different colors) is created.
NONE of the following examples create a fourth (4th) major group:
;; \EFFECT{[font-lock-type-face]}
(setq font-latex-match-textual-keywords
'(
("parentext" "{")
("hybridblockquote" "[{")
)
)
;; \EFFECT{[font-lock-variable-name-face]}
(setq font-latex-match-variable-keywords
'(
("setlist" "[{")
("setlist*" "[{")
)
)
;; \EFFECT{[font-lock-constant-face]}
(setq font-latex-match-reference-keywords
'(
("citet" "[{")
("degrees" "")
("units" "{")
)
)
;; \font-latex-warning-face
(setq font-latex-match-warning-keywords
'(
("fixme" "{")
("INSERT" "")
)
)
;; only affects inside wavy square brackets
(setq font-latex-user-keyword-classes
'(("my-warning-commands"
(("fixme" "{"))
(:foreground "purple")
command)))
Best Answer
Here is an example of setting somethings up for
hi-lock
mode.First define a face:
Then you can define a macro to apply your faces to specified regular expressions.
I define various macros to address highlighting different features. And then I write an
interactive
macro which assembles and applies these.FYI I believe all the various faces I use here are faces I've defined. Even in the examples below. But faces are defined as I've illustrated above.
adding to font-lock features
Here's some code that I've used to add elements to
font-lock
features. But, it's been so long since I wrote this, I don't really know if the following is sufficient to get all the desired resultsIf the above seem too elaborate, you can do something a bit more direct as in
EDIT
I think what you probably want to do is something more like
You probably want to set
<level-of-subexpression>
to 0, but using subexpressions you can get nice effects as in myhello World
example.