I'm working on a project in Racket, and the syntax highlighting in Emacs' racket-mode is becoming an issue for me. Racket is a highly modular language, and one of the modules that I am not using contains builtins that I want to use as identifiers. I want some way to disable the syntax highlighting for that module, but it's difficult: the racket-mode package apparently uses Racket code to dynamically dump all of the keywords and builtins from several modules of the language into a
racket-keywords-and-builtins.el to then be passed through
racket-font-lock.el to produce the actual syntax highlighting rules.
The element of
font-lock-keywords that I want change is
(#21="long-ass-regular-expression" . font-lock-builtin-face). It turns out that the variables from which the mode has constructed the
font-lock-keywords list are still in scope, so my tentative plan is as follows:
regexp-optto reconstruct the regular expression from the list that was used to generate it (in this case,
racket-builtins-2-of-2); bind this to a variable
- Take the set difference of
racket-builtins-2-of-2and a list of the builtins I don't want; pass this through
regexp-opt; bind it to a variable
- Replace the syntax highlighting rule in question with a modified one as follows:
(setq font-lock-keywords (append (remove (assoc racket-builtins-regexp font-lock-keywords) font-lock-keywords) `((,racket-builtins-regexp-prime . font-lock-builtin-face))))
This feels like a kludge. Is there a simpler/more idiomatic way of doing what I'm trying to do?