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:"