From a2a1b5fc4f42f82cce9baa8fdadef890c11966ca Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Thu, 25 Feb 2016 13:06:50 +0900 Subject: [PATCH] Save match data in markdown-syntax-propertize-extend-region --- markdown-mode.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 86291138..bcb61fa2 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1455,19 +1455,20 @@ This helps improve syntax analysis for block constructs. Returns a cons (NEW-START . NEW-END) or nil if no adjustment should be made. Function is called repeatedly until it returns nil. For details, see `syntax-propertize-extend-region-functions'." - (save-excursion - (let* ((new-start (progn (goto-char start) - (if (re-search-backward "\n\n" nil t) - (match-end 0) (point-min)))) - (new-end (progn (goto-char end) - (if (re-search-forward "\n\n" nil t) - (match-beginning 0) (point-max)))) - (code-match (markdown-code-block-at-pos new-start)) - (new-start (or (and code-match (cl-first code-match)) new-start)) - (code-match (markdown-code-block-at-pos end)) - (new-end (or (and code-match (cl-second code-match)) new-end))) - (unless (and (eq new-start start) (eq new-end end)) - (cons new-start new-end))))) + (save-match-data + (save-excursion + (let* ((new-start (progn (goto-char start) + (if (re-search-backward "\n\n" nil t) + (match-end 0) (point-min)))) + (new-end (progn (goto-char end) + (if (re-search-forward "\n\n" nil t) + (match-beginning 0) (point-max)))) + (code-match (markdown-code-block-at-pos new-start)) + (new-start (or (and code-match (cl-first code-match)) new-start)) + (code-match (markdown-code-block-at-pos end)) + (new-end (or (and code-match (cl-second code-match)) new-end))) + (unless (and (eq new-start start) (eq new-end end)) + (cons new-start new-end)))))) (defun markdown-font-lock-extend-region-function (start end _) "Used in `jit-lock-after-change-extend-region-functions'. Delegates to