Skip to content

Commit 09406b1

Browse files
committed
org-macs: Make sure that fontification does not move point
* lisp/org-macs.el (org-looking-at-fontified): (org-buffer-substring-fontified): Wrap fontification call into `save-excursion' for safety.
1 parent f3f60e4 commit 09406b1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lisp/org-macs.el

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ so values can contain further %-escapes if they are define later in TABLE."
12011201
"Return fontified region between BEG and END."
12021202
(when (bound-and-true-p jit-lock-mode)
12031203
(when (text-property-not-all beg end 'fontified t)
1204-
(save-match-data (font-lock-fontify-region beg end))))
1204+
(save-excursion (save-match-data (font-lock-fontify-region beg end)))))
12051205
(buffer-substring beg end))
12061206

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

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

0 commit comments

Comments
 (0)