2

If you want to match foo= and then highlight the foo part, font-lock allows you to do that by grouping sub-expressions in the regexp and then highlighting only a specified sub-expression. Look for SUBEXP in C-h v font-lock-keywords. C-hig (elisp)Search-based Fontification says: ‘(MATCHER . SUBEXP)’ In this kind of element, MATCHER is either a regular ...


1

If a regexp doesn't work, you can use function that does the matching for you. If it behave as a match function, i.e. set match-data and return non-nil when it match something, you can continue to use the font-lock keyword to specify which face to apply to which part of the match. See the documentation for font-lock-keywords for more details. One such ...


Only top voted, non community-wiki answers of a minimum length are eligible