Subject: bug#20096: 25.0.50; Add Font-Lock support for subr-x macros

From: Stefan Monnier <[email-masked]>
Date: Sat, 14 Mar 2015 09:56:33 -0400

>> Instead, The Right Thing to do, might be to change elisp-mode's
>> font-lock rules so they check obarray for macros (i.e. use mapatoms +
>> regexp-opt to generate a regexp matching all macros, and probably
>> update it from after-load-functions)?
> I don't understant what you mean with generating a macro matching all
> macros,

That's because I said "generate a regexp matching all macros", as you
can clearly see in the excerpt you quoted (see above).

> but the attached patch uses a regexp defconst with a matcher
> function for font-lock-keywords.

Looks good.

> +(defun lisp--el-update-after-load (_file)
> +  "Update `lisp--el-macro-regexp' and adjust font-lock in existing buffers."
> +  (lisp--el-update-macro-regexp)
> +  (dolist (buf (buffer-list))
> +    (when (derived-mode-p 'emacs-lisp-mode)
> +      (font-lock-flush))))

I think we should only flush if the set of macros has changed.
Other than that, the patch looks good.
Have you tried it? Does it work well in practice?

        Stefan