file-notify-add-watch from filenotify.el to watch a dired directory so it can revert when a file is modified within the directory. This generally works, but I've noticed that it only works sometimes when renaming a file. Code is here.
When I watch two directories (
~/readings, for example) and add a file
~/, filenotify catches that and reverts the buffer. When I run
mv test.txt readings, the event passed to the filenotify callback contains the sexp
'((<desc>) renamed "~/readings/test.txt" "~/readings/test.txt"). When I move it back with
mv readings/test.txt . (while in
~/), the event passed to the callback is
'((<desc>) renamed "~/test.txt" "~/test.txt"). So it seems to be passing not the previous and the new file, but just two of the new file's path. This could be a bug, but I'm not sure. For easier reading (
=> indicates the events passed to the callback within emacs):
$ echo hey > test.txt => ((32) created "~/test.txt") => ((32) changed "~/test.txt") $ mv test.txt readings => ((34) created "~/readings/test.txt") $ mv readings/test.txt . => ((32) renamed "~/test.txt" "~/test.txt")
I'm pretty sure this is a bug, but I wanted to make sure I wasn't using filenotify incorrectly. Adding the watch, I do:
(file-notify-add-watch (expand-file-name dired-directory) '(change attribute-change) #'my-callback)
34, the two descriptors shown in the output above.
Is this a bug? Or is there some element of
file-notify-add-watch I'm using incorrectly? I would expect
mv <file> <folder> to create a
rename notification with both the previous and current version, but it's not doing that. I'm using emacs 25.0.50 on linux with
'inotify as a file notification library.