From eacccad35ac424916c2f44dac178c7d91894f17b Mon Sep 17 00:00:00 2001 From: "Christopher J. Madsen" Date: Thu, 29 Sep 2011 18:28:16 -0500 Subject: [PATCH] Save match data in markdown-check-change-for-wiki-link It's used in after-change-functions, which leads to weird bugs when the match data changes inside functions that didn't expect that (like dabbrev--safe-replace-match). Also, set inhibit-point-motion-hooks only once Signed-off-by: Jason Blevins --- markdown-mode.el | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index e7401c30..00ffbc19 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1928,8 +1928,7 @@ Designed to be used with the `after-change-functions' hook. CHANGE is the number of bytes of pre-change text replaced by the given range." (interactive "nfrom: \nnto: \nnchange: ") - (let* ((inhibit-point-motion-hooks t) - (inhibit-quit t) + (let* ((inhibit-quit t) (modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) @@ -1938,20 +1937,21 @@ given range." (current-point (point)) deactivate-mark) (unwind-protect - (save-restriction - ;; Extend the region to fontify so that it starts - ;; and ends at safe places. - (multiple-value-bind (new-from new-to) - (markdown-extend-changed-region from to) - ;; Unfontify existing fontification (start from scratch) - (markdown-unfontify-region-wiki-links new-from new-to) - ;; Now do the fontification. - (markdown-fontify-region-wiki-links new-from new-to))) - (unless modified - (if (fboundp 'restore-buffer-modified-p) - (restore-buffer-modified-p nil) - (set-buffer-modified-p nil)))) - (goto-char current-point))) + (save-match-data + (save-restriction + ;; Extend the region to fontify so that it starts + ;; and ends at safe places. + (multiple-value-bind (new-from new-to) + (markdown-extend-changed-region from to) + ;; Unfontify existing fontification (start from scratch) + (markdown-unfontify-region-wiki-links new-from new-to) + ;; Now do the fontification. + (markdown-fontify-region-wiki-links new-from new-to))) + (unless modified + (if (fboundp 'restore-buffer-modified-p) + (restore-buffer-modified-p nil) + (set-buffer-modified-p nil)))) + (goto-char current-point)))) (defun markdown-fontify-buffer-wiki-links () "Refontify all wiki links in the buffer."