When running bibtex-reformat I get Match data clobbered by buffer modification hooks. I know according to the post here that one of my change hooks is clobbering the match data. In fact, when I set inhibit-modification-hooks to t, I don't get the error anymore.

I am trying to figure out the culprit for this error. I tried removing all the hooks from after-change-functions, before-change-functions and first-change-hook and set back inhibit-modification-hooks to nil, but then the error comes back. Evidently, there's a change hook that is running which I don't know.

Is there another way of hunting down the culprit? Or somewhere else I should be looking?

  • Did you try setting debug-on-error to t and checking the backtrace to see what caused the problem?
    – Drew
    May 1, 2020 at 21:36
  • Yes, but that just shows an error inside bibtex-reformat not where the match data was clobbered.
    – Tohiko
    May 1, 2020 at 22:09
  • Load the source file (*.el, not *.elc) that defines bibtex-reformat. Then use M-x debug-on-entry bibtex-reformat and step through the debugger. That can help, if you pay attention and test the match-data from time to time using e. Also, be sure to start Emacs with emacs -Q, to remove any of your init file from the search for the problem.
    – Drew
    May 2, 2020 at 0:43
  • Thanks. I have been trying to do that but it’s not clear where the match data is being clobbered. Only that it’s being clobbered when ‘bibtex-reformat’ changes the buffer. Running with ‘emacs -Q’ does not show the error, but I would like to understand what in my setup is clobbering the data (hopefully using a better method than binary-search-commenting my huge init file). I am surprised that when setting all change hooks to nil the match data is still corrupted but it’s not when ‘inhibit-modification-changes’ is set. Am I missing a change hook?
    – Tohiko
    May 2, 2020 at 7:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.