Skip to content

Commit

Permalink
More selective wiki link refontification
Browse files Browse the repository at this point in the history
We only need to refontify wiki links in a region when
the range already contains text with a wiki link face
or if the wiki link regexp matches text in the region.
Otherwise, we can be sure there are no wiki links in
the region and can skip refontifying wiki links
(which is expensive in an after-change hook).
  • Loading branch information
jrblevin committed Dec 19, 2015
1 parent 1c76d45 commit acf7c5e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -5297,10 +5297,19 @@ given range."
;; and ends at safe places.
(multiple-value-bind (new-from new-to)
(markdown-extend-changed-region from to)
;; Unfontify existing fontification (start from scratch)
(markdown-unfontify-region-wiki-links new-from new-to)
;; Now do the fontification.
(markdown-fontify-region-wiki-links new-from new-to)))))
(goto-char new-from)
;; Only refontify when the range contains text with a
;; wiki link face or if the wiki link regexp matches.
(when (or (markdown-range-property-any
new-from new-to 'font-lock-face
(list markdown-link-face
markdown-missing-link-face))
(re-search-forward
markdown-regex-wiki-link new-to t))
;; Unfontify existing fontification (start from scratch)
(markdown-unfontify-region-wiki-links new-from new-to)
;; Now do the fontification.
(markdown-fontify-region-wiki-links new-from new-to))))))
(and (not modified)
(buffer-modified-p)
(set-buffer-modified-p nil)))))
Expand Down

0 comments on commit acf7c5e

Please sign in to comment.