From: Mark Wooding Date: Mon, 28 Dec 2015 15:28:44 +0000 (+0000) Subject: el/dot-emacs.el: Advice to fix `markdown-mode' to preserve match data. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/a1e4004ca8710d6868f137f019f1625e1b00c15c?ds=sidebyside el/dot-emacs.el: Advice to fix `markdown-mode' to preserve match data. `markdown-mode' adds a hook to `after-change-functions', which checks for completed wiki links and tries to highlight them. This clobbers the match data, and, although it tries to save the position of the point, it seems that `replace-match' arranges to leave point at the end of the match by looking at the match data after the hook functions have run. The result is that point ends up in the wrong place after `replace- match'. During `query-replace' and friends, the effect is that only the first change in any given line is actually replaced, regardless of how many matches there might be. Giving the broken function a few choice words of advice fixes everything. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 2fb1520..d657295 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -226,6 +226,13 @@ (defmacro mdw-advise-to-inhibit-raise-frame (function) (mdw-advise-to-inhibit-raise-frame select-frame-set-input-focus) +;; Bug fix for markdown-mode, which breaks point positioning during +;; `query-replace'. +(defadvice markdown-check-change-for-wiki-link + (around mdw-save-match activate compile) + "Save match data around the `markdown-mode' `after-change-functions' hook." + (save-match-data ad-do-it)) + ;; Transient mark mode hacks. (defadvice exchange-point-and-mark