From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: File watch support in autorevert.el Date: Sat, 12 Jan 2013 14:08:42 +0100 Message-ID: <87d2xatup1.fsf@gmx.de> References: <878v819kok.fsf@gmx.de> <83fw28uj9c.fsf@gnu.org> <87mwwfmij0.fsf@gmx.de> <837gnitz6o.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1357996139 1427 80.91.229.3 (12 Jan 2013 13:08:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Jan 2013 13:08:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 12 14:09:16 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 1Tu0po-0004MU-Gs for ged-emacs-devel@m.gmane.org; Sat, 12 Jan 2013 14:09:16 +0100 Original-Received: from localhost ([::1]:55985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tu0pY-0007uu-FK for ged-emacs-devel@m.gmane.org; Sat, 12 Jan 2013 08:09:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tu0pP-0007uY-PQ for emacs-devel@gnu.org; Sat, 12 Jan 2013 08:08:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tu0pL-0005r0-S2 for emacs-devel@gnu.org; Sat, 12 Jan 2013 08:08:51 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:52956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tu0pL-0005pq-HD for emacs-devel@gnu.org; Sat, 12 Jan 2013 08:08:47 -0500 Original-Received: from mailout-de.gmx.net ([10.1.76.30]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0MZiPg-1TgD203XrC-00LYrK for ; Sat, 12 Jan 2013 14:08:46 +0100 Original-Received: (qmail invoked by alias); 12 Jan 2013 13:08:45 -0000 Original-Received: from p57BB82EE.dip0.t-ipconnect.de (EHLO detlef.gmx.de) [87.187.130.238] by mail.gmx.net (mp030) with SMTP; 12 Jan 2013 14:08:45 +0100 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX1/auQ5xoJXasZ5LgLdzy7Fy+MXf/iumRzLnHLHrva NvP6BiW62YDmpj In-Reply-To: <837gnitz6o.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 12 Jan 2013 13:31:43 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.20 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:156266 Archived-At: Eli Zaretskii writes: > I needed to make 2 changes to get this to work on Windows, see trunk > revision 111499. Actually, I don't understand how it worked with > inotify before my changes, since you were looking for 'modify' in the > descriptor rather than in the action. Did I miss something? You're right, I've introduced a bug here at the very end of my tests last night. > Btw, should we perhaps do something more sophisticated than > string-equal to compare file names? On Windows, we probably should > compare case-insensitively, but what about file-truename and friends > on Posix platforms? What about `file-equal-p'? Like --8<---------------cut here---------------start------------->8--- ~/src/emacs> bzr diff lisp/autorevert.el === modified file 'lisp/autorevert.el' --- lisp/autorevert.el 2013-01-12 11:25:39 +0000 +++ lisp/autorevert.el 2013-01-12 13:06:19 +0000 @@ -531,17 +531,11 @@ (when (featurep 'inotify) (cl-assert (memq 'modify action))) (when (featurep 'w32notify) (cl-assert (eq 'modified action))) (cl-assert (bufferp buffer)) - (when (stringp file) - (cl-assert (string-equal - ;; w32notify returns the basename of the file - ;; without its leading directories; inotify - ;; returns its full absolute file name. - (file-name-nondirectory (directory-file-name file)) - (file-name-nondirectory (directory-file-name - (buffer-file-name buffer)))))) - - ;; Mark buffer modified. (with-current-buffer buffer + (when (and (stringp file) (stringp buffer-file-name)) + (cl-assert (file-equal file buffer-file-name))) + + ;; Mark buffer modified. (setq auto-revert-notify-modified-p t)))))) (defun auto-revert-active-p () --8<---------------cut here---------------end--------------->8--- The disadvantage might be performance, because `file-equal-p' performs operations on the filesystem, like `file-attributes' etc. When all files in a directory are watched, there will be a lot of events to be ignored. Is this acceptable? Best regards, Michael.