I run into the error Match data clobbered by buffer modification hooks when editing tex files. The way to reproduce is as follows.
In terminal,
cd
mkdir tèst/
cd tèst/
touch test.tex
echo "\input ./universalMacros.tex\n\proof\n% some comment\n\nbye" > test.tex
emacs -Q test.tex
In emacs, use M-: to execute the following
(progn (re-search-forward "proof") (replace-match "prf"))
Then the error appears.
In fact, if the file contains a comment, and is saved, then this error appears, but if the file is modified but not saved, or if the file has no comments, then no error appears when doing replace-match.
Moreover, I tried (setq CHANGE-HOOK nil)
where CHANGE-HOOK runs through before-change-functions
, after-change-functions
and first-change-hook
, and the error is still there.
However, if I run
(let ((inhibit-modification-hooks t)) (progn (re-search-forward "proof") (replace-match "prf")))
then there is no error. So I suppose there are some modification hooks that I miss that are related to font-locks. But I am not sure how to resolve the problem.
Note: this error only appears if the path to the file contains strange characters, which makes it even more bizarre.
EDIT: The error message I received is
Debugger entered--Lisp error: (error "Match data clobbered by buffer modification hooks")
replace-match("prf")
(progn (re-search-forward "proof") (replace-match "prf"))
eval((progn (re-search-forward "proof") (replace-match "prf")) nil)
eval-expression((progn (re-search-forward "proof") (replace-match "prf")) nil nil 127)
funcall-interactively(eval-expression (progn (re-search-forward "proof") (replace-match "prf")) nil nil 127)
call-interactively(eval-expression nil nil)
command-execute(eval-expression)
As seen from the error message, this is from replace-match
so I don't think this is related to re-search-forward
. (I tried to call it like (re-search-forward "proof" nil t)
and the error still happens.
If I left out some detail, then please tell me, and I will provide it. Thanks.
Any help or comment is sincerely appreciated; thanks in advance.