浏览代码

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.
Ihor Radchenko 2 年之前
父节点
当前提交
09406b1c98
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      lisp/org-macs.el

+ 5 - 4
lisp/org-macs.el

@@ -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)
@@ -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.