Refresh font-lock rather than recomputing from defaults
commit2dde7b39fe4b503202995748782a029b6bb7fb26
authorJason Blevins <jblevins@xbeta.org>
Sat, 11 Nov 2017 01:20:41 +0000 (10 20:20 -0500)
committerJason Blevins <jblevins@xbeta.org>
Sat, 11 Nov 2017 01:20:41 +0000 (10 20:20 -0500)
treeeb1c42a5d525eb35ddb959e96aad41fa8d34129d
parenta01883ff12375bba792a0ff5dde4a2032d5c4286
Refresh font-lock rather than recomputing from defaults

We can use font-lock-flush now to simply refresh the fontification of
the current part of the buffer.  Previously, we needed to use the more
heavy-handed font-lock-refresh-defaults, because we were regenerating
the list of font-lock-keywords from scratch and reloading each time.
Now, keywords are added and removed as needed, or else are based on
functions with feature-specific conditionals.

We also don’t need to check that font-lock-mode is enabled, because
font-lock-flush does that already.

The result is that user-defined keywords such as these are not
clobbered:

(font-lock-add-keywords nil '(("\\W@\\w+" . font-lock-variable-name-face)))

Closes GH-222.
markdown-mode.el