From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: auto-revert error on macOS when auto-revert-use-notify is t Date: Fri, 29 Dec 2017 11:02:10 +0100 Message-ID: <87po6xvom5.fsf@gmx.de> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1514541630 19825 195.159.176.226 (29 Dec 2017 10:00:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Dec 2017 10:00:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: "emacs-devel@gnu.org" To: zhang cc Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 29 11:00:26 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUrSh-0004du-Lp for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 11:00:23 +0100 Original-Received: from localhost ([::1]:35137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUrUg-0002AE-E2 for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 05:02:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUrUY-00029b-UO for emacs-devel@gnu.org; Fri, 29 Dec 2017 05:02:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUrUU-000801-Jd for emacs-devel@gnu.org; Fri, 29 Dec 2017 05:02:19 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:63330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUrUU-0007ww-AB for emacs-devel@gnu.org; Fri, 29 Dec 2017 05:02:14 -0500 Original-Received: from detlef.gmx.de ([212.86.38.127]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MZxch-1eEAWL3ZWR-00LivV; Fri, 29 Dec 2017 11:02:11 +0100 In-Reply-To: (zhang cc's message of "Fri, 29 Dec 2017 05:08:00 +0000") X-Provags-ID: V03:K0:yOKkd2fJ+wWS3nQK8JYwUIvvsbFrUGjt4dZkMf+KtNF30dJ8dux 0V0JdQniEW7PbLvtVzSxRa7C4z9GAW2BBH7ol8Mm8kqtK+VxzW1vV547mFZ4YDbGX9X8xwI C79lcWBjND5JjC+5TeaKl7W0cgUmfm5Vl2ldwNfsMxZBqBXGkVa3y6YVnbywiVZUgsfZLdw N0Ely+dgNK4W6G2fufN5Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:vTAi6jVJO24=:x93q2LHVM+BY3kHi90x+Be OvQ6HKFvcmD44vUYK7vJ11tkk7OThlO1C9FfkNLY48VbWOBEuEaOnx36aOsVASDLJXt49Ehb6 A5MjkVJe0GZTtA/nFMphvkiRALb/MEDVWGR7/kcZugdXNnHdTDA0MiwFaGsUCNISYJgtreP8T c0F3ul9ZR3ti7d0RsFAM7kLHfo8lzoZe4WPzc9FyQGBp8D1TwkPkfAXDutVq9z+adeMZfzcXU xhAF1kb5u6ML6AHf32y/eTsD/pGSReAGAhYfBRbaIvOU8btLtaLpQQm8UFQ7N775mg9K9FIk1 wpJ2tD7lJyQ1kSUkDT5ESfcU/Ou4GSqoMQ0J7VNXkGaeN3BHnEMbdqv44nTmSCJE7Y648ukU8 BTmLV75qMzYjPwtym6HxzH8PfP6/BzUbkIEFeyBbsCClrq5m5atBlMWSwcu0keE+q5Ch/Evnz +VqvRHvTVVQH62wPE3DnRsBBIMDMXTMnx/GNhTITRZNBp4AGTe84az9jvyT2gpW162IwZQgOU tKXfrnRH/NKXpQ42EhxqrUtJs0Hjd++L4NZ7Fu+zae/XUoFsHzmdQQp4FZWQFu9cachznYFOa ffUyPtdiqH2ZGhYVMF4p3kIWc/Sfdfcy2imRL11FObUxBNI7W4JcGbtY1RoibCvkZXDDPRJKh Pj4din+Zcy/HHT1u0ffnKG14lH4t/T9u9dQku5OjVxb6Le6AhYhvL/wU1Lc4ApN8OBI7YdipE 7QLQiTnBWqS/Ybm91LBcxgq26qduN1uyuU03Q7J9fc2oqon3QLRg3F1LXxZDLBGu/wtSW/3s X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.21 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221450 Archived-At: zhang cc 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 # 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) #)(13 > (#)) > maphash(#f(compiled-function (key value) #) > #) > 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 <~/.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.