emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: auto-revert error on macOS when auto-revert-use-notify is t


From: Michael Albinus
Subject: Re: auto-revert error on macOS when auto-revert-use-notify is t
Date: Fri, 29 Dec 2017 11:02:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

zhang cc <address@hidden> writes:

Hi,

> Emacs: 26.0.90 
> OS: macOS 10.13.2
>
> 1. start Emacs with -Q
> 2. open a test file (like 1.c)
> 3. turn on auto-revert-mode by run global-auto-revert-mode
> 4. add auto-revert-use-notify as a watcher variable by
> debug-on-variable-change
> 5. open the test file with vim
> 6. modify the test file in vim and save it
> 7. Emacs enter debug with the following msg:
>
> Debugger entered--setting auto-revert-use-notify in buffer 1.c to nil:
>   debug--implement-debug-watch(auto-revert-use-notify nil set #<buffer
> 1.c>)
>   auto-revert-notify-handler((13 stopped "/Users/jun/test/1.c"))
>   file-notify--rm-descriptor(13)
>   file-notify-rm-watch(13)
>   #f(compiled-function (key value) #<bytecode 0x40a952e1>)(13
> (#<buffer 1.c>))
>   maphash(#f(compiled-function (key value) #<bytecode 0x40a952e1>)
> #<hash-table equal 7/65 0x40e7896d>)
>   auto-revert-notify-rm-watch()
>   auto-revert-notify-handler((13 stopped "/Users/jun/test/1.c"))
>   file-notify--rm-descriptor(13)
>   file-notify-rm-watch(13)
>   file-notify-callback((13 (rename delete) "/Users/jun/test/1.c"))
>   file-notify-handle-event((file-notify (13 (rename delete)
> "/Users/jun/test/1.c") file-notify-callback))
>   funcall-interactively(file-notify-handle-event (file-notify (13
> (rename delete) "/Users/jun/test/1.c") file-notify-callback))
>   call-interactively(file-notify-handle-event nil [(file-notify (13
> (rename delete) "/Users/jun/test/1.c") file-notify-callback)])
>   command-execute(file-notify-handle-event nil [(file-notify (13
> (rename delete) "/Users/jun/test/1.c") file-notify-callback)] t)

Well, this is not an error. The watchdog over "/Users/jun/test/1.c"
receives the `(rename delete)' events from writing the file. Due to
this, the watchdog is removed, as you see in the backtrace.

I could reproduce this behaviour on my GNU/Linux system. See the
following example, just from the shell:

--8<---------------cut here---------------start------------->8---
$ touch 1.c
$ ls -il 1.c*
3282165 -rw-r--r-- 1 albinus albinus 0 Dec 29 10:52 1.c
--8<---------------cut here---------------end--------------->8---

A zero length file 1.c has been created with inode 3282165.

--8<---------------cut here---------------start------------->8---
$ vim 1.c
$ ls -il 1.c*
3283516 -rw-r--r-- 1 albinus albinus 5 Dec 29 10:53 1.c
--8<---------------cut here---------------end--------------->8---

I have modified the file with vim, and saved. Now the inode is 3283516,
which means a *new* file with the same name. While saving the file, a
temporary file has been created, and renamed then to the original file
name. From Emacs' file-notify point of view, this is a new file.

If you want to keep the original file, you must apply backup-by-copy in
vim. Apply the following settings in ~/.vimrc, and rerun the test:

--8<---------------cut here---------------start------------->8---
$ cat <<EOF >~/.vimrc
set backup
set backupcopy=yes
EOF
$ vim 1.c
$ ls -il 1.c*
3283516 -rw-r--r-- 1 albinus albinus 9 Dec 29 10:58 1.c
3283482 -rw-r--r-- 1 albinus albinus 5 Dec 29 10:53 1.c~
--8<---------------cut here---------------end--------------->8---

You'll see that the inode 3283516 is kept.

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]