Skip to content

Commit

Permalink
org-macs: Make sure that fontification does not move point
Browse files Browse the repository at this point in the history
* lisp/org-macs.el (org-looking-at-fontified):
(org-buffer-substring-fontified): Wrap fontification call into
`save-excursion' for safety.
  • Loading branch information
yantar92 committed Sep 1, 2022
1 parent f3f60e4 commit 09406b1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lisp/org-macs.el
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ so values can contain further %-escapes if they are define later in TABLE."
"Return fontified region between BEG and END."
(when (bound-and-true-p jit-lock-mode)
(when (text-property-not-all beg end 'fontified t)
(save-match-data (font-lock-fontify-region beg end))))
(save-excursion (save-match-data (font-lock-fontify-region beg end)))))
(buffer-substring beg end))

(defun org-looking-at-fontified (re)
Expand All @@ -1211,9 +1211,10 @@ so values can contain further %-escapes if they are define later in TABLE."
(when (text-property-not-all
(match-beginning 0) (match-end 0)
'fontified t)
(save-match-data
(font-lock-fontify-region (match-beginning 0)
(match-end 0)))))))
(save-excursion
(save-match-data
(font-lock-fontify-region (match-beginning 0)
(match-end 0))))))))

(defsubst org-no-properties (s &optional restricted)
"Remove all text properties from string S.
Expand Down

0 comments on commit 09406b1

Please sign in to comment.