reddit / emacs

tracking down file-notify-handle-event errors when buffer names change

titaniumbones · 2022-06-08 11:09
I have `uniquify-buffer-name-style` set to `forward`, so when I open a second file with the same name as one that is already open, the first buffer is renamed from (say) `Notes.org` to `my-first-project/Notes.org`, while the second gets named to `my-second-file/Notes.org`. All of that is perfectly normal! For the last couple of months, though, this process leads to a series of persistent and intrusive errors from `file-notify--handle-event`: ``` file-notify--handle-event: No buffer named Notes.org ``` I gather that somewhere in my config, and somewhere in my various third party packages, there is something setting a file-notify watch on the buffer, and that watch gets orphaned when the buffer is renamed. But I'm unable to find the setting. I've grepped through my config files for file-notify, and the one direct reference to file-notify is in my setup for `citar`; as far as i can tell, citar only watches my bibtex files. However, my errors almost always seem to be org files (where I spend most of my time editing) Any idea how I might be able to track this down? I have tried `(debug-on-entry 'file-notify--event-handler)` but I then the error of course becomes even more intrusive and the context isn't incredibly helpful: ``` Debugger entered--entering a function: * file-notify--handle-event((27 . 0) (changed) "brainstorming.org" 0) file-notify--callback-inotify(((27 . 0) (modify) "brainstorming.org" 0)) file-notify-handle-event((file-notify ((27 . 0) (modify) "brainstorming.org" 0) file-notify--callback-inotify)) funcall-interactively(file-notify-handle-event (file-notify ((27 . 0) (modify) "brainstorming.org" 0) file-notify--callback-inotify)) command-execute(file-notify-handle-event nil [(file-notify ((27 . 0) (modify) "brainstorming.org" 0) file-notify--callback-inotify)] t) ``` trying the same with `file-notify-handle-event` (the single-hyphen function!) gives: ``` file-notify-handle-event((file-notify ((5 . 0) (modify) ".saves-1217542-anarres~" 0) file-notify--callback-inotify)) funcall-interactively(file-notify-handle-event (file-notify ((5 . 0) (modify) ".saves-1217542-anarres~" 0) file-notify--callback-inotify)) command-execute(file-notify-handle-event nil [(file-notify ((5 . 0) (modify) ".saves-1217542-anarres~" 0) file-notify--callback-inotify)] t) read--expression("Eval: ") byte-code("\301\302!\303\10!B\207" [current-prefix-arg read--expression "Eval: " eval-expression-get-print-arguments] 3) command-execute(eval-expression) ``` I guess I don't fully understand this output -- it looks like a tiny gremlin is secretly typing `C-M-:` and then `(file-notify-handle-event ....)`! As always, thanks in advance for the help!
ieure · 2022-06-08 15:04
> I guess I don't fully understand this output -- it looks like a tiny gremlin is secretly typing C-M-: and then (file-notify-handle-event ....)! The error is happening inside the callback function which handles the file change notification. You can debug `inotify-add-watch` and open a new file to see what all is putting watches on them. It might be `auto-revert-mode`.
titaniumbones · 2022-06-09 17:21
thanks! I'm going to try to do this today when I get a second.