Protect match data in markdown-fontify-region-wiki-links
commit9468375dbde2d967dbc0609c515938e7df95f23a
authorJason Blevins <jrblevin@sdf.org>
Tue, 22 Jan 2013 17:06:15 +0000 (22 12:06 -0500)
committerJason Blevins <jrblevin@sdf.org>
Tue, 22 Jan 2013 17:10:57 +0000 (22 12:10 -0500)
treeebe35255280832e3c8f68d7c2552240e7216a0d2
parent0714194d9ab01258a458a55f39eeca0e68c33b37
Protect match data in markdown-fontify-region-wiki-links

Thanks to Vegard Vesterheim <vegard.vesterheim@uninett.no> for the
following report, and to Carsten Dominik for the patch:

I had problems editing tables (using the minor mode orgtbl-mode) in
markdown files.

To reproduce:
- visit an empty buffer in markdown mode
- M-x orgtbl-mode
- create a new table (C-c |)
- try to edit a cell
- observe that the edited text is misplaced at the end of the line

I originally reported this to the orgmode people, and supplied a simple
patch to fix it. Se this thread:

http://lists.gnu.org/archive/html/emacs-orgmode/2012-12/msg00598.html

The underlying problem seems to be that markdown-mode does not protect
the match data properly. Quoted from Carsten in the thread:

 "Markdown defines an after-change-function
 `markdown-check-change-for-wiki-link'.  This function is called after
 each buffer change.  The function contains a call to
 `markdown-fontify-region-wiki-links'.  If such a function would be
 called through the general font-lock stuff, the match data would be
 protected.  However, here it is called directly from a change function.
 So this function should protect match data explicitly:"
markdown-mode.el