Skip to content

Commit

Permalink
Save match data in markdown-check-change-for-wiki-link
Browse files Browse the repository at this point in the history
  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 <jrblevin@sdf.org>
  • Loading branch information
madsen authored and jrblevin committed Sep 29, 2011
1 parent ae0987d commit eacccad
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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."
Expand Down

0 comments on commit eacccad

Please sign in to comment.