From c827341dfb51b37e9ff7bbb2de84c54fff157d5d Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 17 Apr 2023 12:45:07 +0200 Subject: [PATCH] org-cite-activate: Ensure that we keep the correct match-data * lisp/oc.el (org-cite-activate): Discard match data set by activate function. We already move the point after citation by force, so can as well ensure that match-data remain accurate for later font-lock use. Reported-by: Lin Jian Link: https://orgmode.org/list/87sfczztg6.fsf@linj.tech --- lisp/oc.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/oc.el b/lisp/oc.el index 260a4d3e1..8a7b66209 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -1232,7 +1232,9 @@ from the processor set in `org-cite-activate-processor'." (let ((cite (org-with-point-at (match-beginning 0) (org-element-citation-parser)))) (when cite - (funcall activate cite) + ;; Do not alter match data as font-lock expects us to set it + ;; appropriately. + (save-match-data (funcall activate cite)) ;; Move after cite object and make sure to return ;; a non-nil value. (goto-char (org-element-property :end cite)))))))