From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: File watch support in autorevert.el Date: Fri, 11 Jan 2013 09:34:33 -0500 Message-ID: References: <878v819kok.fsf@gmx.de> <83fw28uj9c.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1357914891 2973 80.91.229.3 (11 Jan 2013 14:34:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Jan 2013 14:34:51 +0000 (UTC) Cc: Michael Albinus , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 11 15:35:07 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TtfhH-0001R0-4x for ged-emacs-devel@m.gmane.org; Fri, 11 Jan 2013 15:35:03 +0100 Original-Received: from localhost ([::1]:59587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttfh1-0004eb-4U for ged-emacs-devel@m.gmane.org; Fri, 11 Jan 2013 09:34:47 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttfgx-0004eJ-9n for emacs-devel@gnu.org; Fri, 11 Jan 2013 09:34:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttfgs-0001JF-11 for emacs-devel@gnu.org; Fri, 11 Jan 2013 09:34:43 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:42729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttfgp-0001Hw-Cd; Fri, 11 Jan 2013 09:34:35 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtkGAG6Zu09MCpYP/2dsb2JhbABEgXuyFoEIghYBBVYjEAs0EhQYDRABE4ghugmQRAOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="212295556" Original-Received: from 76-10-150-15.dsl.teksavvy.com (HELO pastel.home) ([76.10.150.15]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Jan 2013 09:34:34 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 08101593DB; Fri, 11 Jan 2013 09:34:33 -0500 (EST) In-Reply-To: <83fw28uj9c.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 Jan 2013 12:05:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156215 Archived-At: > . The code as written is too naive: it blindly assumes that every > single notification reported by the filesystem for a given watch is > necessarily the one requested in the auto-revert-notify-add-watch > call. But that assumption is false, at least on Windows, where the > implementation actually watches events to the entire parent > directory of the file we are interested in. So Emacs reverts the > file whenever _any_ file in the same directory was changed. I > believe similar problems can happen with inotify, albeit much more > rarely. For that reason, I think auto-revert-notify-handler should > filter events by ASPECTS/ACTION member, and on Windows also by FILE > member of the event. That seems like a good candidate for something the common API could hide/provide, I think. > . It isn't clear to me that using IN_CLOSE_WRITE with inotify is TRT: > AFAIU, that would mean we only revert a file when the application > writing to it closes its descriptor. IOW, if the application makes > several changes to the file during a prolonged operation, and > doesn't close and reopen the file in between, we will only see the > changes at the end, but not during the operation. Wouldn't it be > better to use IN_MODIFY instead? For auto-revert-tail-mode, IN_CLOSE_WRITE is definitely insufficient since the common use case is when we watch a log file, so the CLOSE may never happen. The non-inotify code does something akin to the IN_MODIFY, indeed. But at the same time, it's often preferable to wait a bit longer for the application to finish writing the new version of the file. I think the perfect behavior lies somewhere in-between: when we get an IN_CLOSE_WRITE, we should revert immediately, but when we get an IN_MODIFY we should revert "soon". Stefan