unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jari Aalto <jari.aalto@cante.net>
To: emacs-devel@gnu.org
Subject: [PATCH] autorevert.el -- revert fix for Windows platform
Date: 22 Mar 2007 13:27:21 +0200	[thread overview]
Message-ID: <7it9frhi.fsf@cante.net> (raw)


For some reason the `verify-visited-file-modtime' test in
auto-revert-buffers is not enough to notice a file change under
Windows / native Emacs 21.3. Here is patch to compare the bufer size
against files size on disk. It cures the revert problem.

The patch is against CVS 2007-03-22

2007-03-22 Thu Jari Aalto <jari aalto A T cante net>

	* autorevert.el
	(auto-revert-size-equal-p): New function.
	(auto-revert-handler): Use `auto-revert-size-equal-p' to
	test file change as well.

=== modified file 'autorevert.el'
--- autorevert.el       2007-03-22 11:05:43 +0000
+++ autorevert.el       2007-03-22 11:24:06 +0000
@@ -302,7 +302,6 @@
     (auto-revert-buffers)
     (setq auto-revert-tail-mode nil)))

-
 ;;;###autoload
 (defun turn-on-auto-revert-mode ()
   "Turn on Auto-Revert Mode.
@@ -396,6 +395,11 @@
        (not (memq major-mode
                  global-auto-revert-ignore-modes)))))

+(defun auto-revert-size-equal-p ()
+  (let ((bsize (buffer-size))
+        (fsize (nth 7 (file-attributes (buffer-file-name)))))
+    (eq bsize fsize)))
+
 (defun auto-revert-handler ()
   "Revert current buffer, if appropriate.
 This is an internal function used by Auto-Revert Mode."
@@ -405,7 +409,9 @@
            (or (and buffer-file-name
                     (not (file-remote-p buffer-file-name))
                     (file-readable-p buffer-file-name)
-                    (not (verify-visited-file-modtime buffer)))
+                     (or
+                      (not (verify-visited-file-modtime buffer))
+                      (not (auto-revert-size-equal-p))))
                (and (or auto-revert-mode
                         global-auto-revert-non-file-buffers)
                     revert-buffer-function

             reply	other threads:[~2007-03-22 11:27 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-22 11:27 Jari Aalto [this message]
2007-03-22 15:00 ` [PATCH] autorevert.el -- revert fix for Windows platform Chong Yidong
2007-03-22 15:56   ` Lennart Borgman (gmail)
2007-03-22 17:49     ` Jason Rumney
2007-03-23 13:26       ` Eli Zaretskii
2007-03-23 17:31         ` Jari Aalto
2007-03-23 20:36           ` Jason Rumney
2007-03-23 23:07             ` Jason Rumney
2007-03-24 10:52               ` martin rudalics
2007-03-24 11:11                 ` Jason Rumney
2007-03-24 11:25                   ` Johan Bockgård
2007-03-24 11:46                     ` Jason Rumney
2007-03-24 11:32                   ` martin rudalics
2007-03-24 18:21             ` Eli Zaretskii
2007-03-24 22:56               ` Kim F. Storm
2007-03-25  4:13                 ` Eli Zaretskii
2007-03-24 14:46           ` Eli Zaretskii
2007-03-23  7:03   ` Jari Aalto
2007-03-23 14:10     ` Eli Zaretskii
2007-03-23 15:47       ` Kim F. Storm
2007-03-23 16:51         ` Jason Rumney
2007-03-23 18:48           ` Luc Teirlinck
2007-03-24 14:59             ` Eli Zaretskii
2007-03-23 22:41           ` Stefan Monnier
2007-03-24 23:50             ` Kim F. Storm
2007-03-25  0:24               ` Luc Teirlinck
2007-03-25  1:09                 ` Kim F. Storm
2007-03-25 19:09                   ` Stefan Monnier
2007-03-23 16:57         ` Stefan Monnier
2007-03-24 14:49         ` Eli Zaretskii
2007-03-23 13:25   ` Eli Zaretskii
2007-03-22 22:50 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7it9frhi.fsf@cante.net \
    --to=jari.aalto@cante.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).