I want to add better support for expl3
to AUCTeX. I have regular expressions that properly group according to the naming conventions for:
- functions
(\\(?:__)?[a-z]+_)([a-z_]+)(:[nNpTFwcVvxof]*)
, - variables
(\\[cgl]__?)([a-z][a-z_]+)(_[A-Za-z]+)
, and - key-value segments
\s*([a-z\-]+)\s+(\.[a-z_]+):([nNpTFwcVvxof]*)\s+=
How can I apply faces to both
- the match as a whole and
- the individual groups (overriding the whole match where appropriate)?
Just a proof-of-concept using the function-regexp would be very helpful :)
rx
Forms
(setq LaTeX-expl3-function-regexp
(rx symbol-start
(group "\\" (optional "__") (+ alpha) "_")
(group (+ (any alpha "_")))
(group ":" (* (any "nNpTFwcVvxofD")))
symbol-end)
LaTeX-expl3-variable-regexp
(rx symbol-start
(group "\\" (any "cgl") "_" (optional "_"))
(group (or (seq (any alpha) "_") "@@_"))
(group (any alpha) (+ (any alpha "_")))
(group "_" (+ alpha))
symbol-end)
LaTeX-expl3-keyval-regexp
(rx (* whitespace)
(group (any alpha "-"))
(+ whitespace)
(group "." (+ (any alpha)))
(group ":" (* (any "nNpTFwcVvxofD")))
(+ whitespace) "="))
font-lock-keywords
? If so, just use anOVERRIDE
value oft
for the group pattern, and place it after the whole-match pattern. SeeC-h v font-lock-keywords
. – Drew Apr 2 '15 at 3:56font-lock-mode
. Specifically, I'm not sure how to go about using a single matching regexp and supplying multiple group/face/override values. – Sean Allred Apr 2 '15 at 4:44(info "(elisp) Search-based Fontification")
? – politza Apr 2 '15 at 5:31font-lock-keywords
entries. You can worry about combining them later. The point is to make the second one override anything done by the first one. – Drew Apr 2 '15 at 14:10font-lock-keywords
variable. Use the(MATCHER HIGHLIGHT ...)
format, whereHIGHLIGHT
stands for(SUBEXP FACENAME [OVERRIDE [LAXMATCH]])
. – Malabarba Apr 2 '15 at 20:32