Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hl-todo-mode: Fontify using hl-todo--regexp only #29

Merged
merged 1 commit into from
Oct 8, 2018
Merged

Conversation

tarsius
Copy link
Owner

@tarsius tarsius commented Oct 3, 2018

Previously we used font-lock-flush and font-lock-ensure instead. Most built-in minor-modes that call font-lock-add-keywords (with nil as MODE), only call the former, which doesn't appear to always get the job done. Additionally calling font-lock-ensure as we did isn`t much; it re-fontifies the complete buffer, which can be costly and it has been reported that it sometimes fails to actually do so.

Directly fontifying just our own keyword using hl-todo--regexp for the complete buffer seems to be a good compromise and should also be more reliable.

This should fix #22 and #26.

smerge-mode uses the same approach but that's not necessarily so because its author has the same doubts about font-lock-flush and font-lock-ensure that I have. That package uses a regexp that matches across more than one line, in which case things get even more complicated. Anyway, if it works for multi-line matches then matches within a single line should be no problem at all. Still, I would not necessarily recommend that all keyword-adding minor-modes use this approach.

This should be much faster than using font-lock-flush and font-lock-ensure and not much slower than using just the former.

Previously we used `font-lock-flush' and `font-lock-ensure' instead.
Most built-in minor-modes that call `font-lock-add-keywords' (with
`nil' as MODE), only call the former, which doesn't appear to always
get the job done.  Additionally calling `font-lock-ensure' as we did
isn't much; it re-fontifies the complete buffer, which can be costly
and it has been reported that it sometimes fails to actually do so.

Directly fontifying just our own keyword using `hl-todo--regexp' for
the complete buffer seems to be a good compromise and should also be
more reliable.
@tarsius tarsius merged commit 38d8b57 into master Oct 8, 2018
@tarsius tarsius deleted the faster branch October 8, 2018 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad performance with large files
1 participant