origami.el
origami.el copied to clipboard
Avoid "Match data clobbered by buffer modification hooks" error
I found a reliable reproduction scenario and a code change that fixes #56 for me.
Reproduction scenario:
- Visit a C++ file that contains a syntax error. (Presumably the programming language is not important.)
- Do
revert-buffer
. This is a workaround for the issue, so we get to a state where query-replace works. - Do a
query-replace
that replaces multiple occurrences. This succeeds. - Undo the replacement.
- Do
compile
. The syntax error is reported. - Do
next-error
to move to the (first) syntax error. - Do a
query-replace
that replaces multiple occurrences. Only the first occurrence is replaced, and the error message "Match data clobbered by buffer modification hooks" is generated. This reproduces the problem.
The fix that works for me is to edit function origami-header-overlay-range
in origami.el by wrapping the body of the save-excursion
call in a save-match-data
call, yielding
(save-excursion
(save-match-data
(goto-char (overlay-end fold-overlay))
(when (looking-at ".")
(forward-char 1)
(when (looking-at "\n")
(forward-char 1)))
(point))