emacs-devel
[Top][All Lists]
Advanced

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

Re: autorevert.el


From: Luc Teirlinck
Subject: Re: autorevert.el
Date: Thu, 25 Mar 2004 00:20:20 -0600 (CST)

Eli Zaretskii wrote:

   > When renaming a file to a name with the same length (common when one
   > made a typo, when updating a version number, changing a suffix and
   > so on), dired would not get notified.

   So who is talking about almost-zero probability cases now? ;-)

It is definitely not almost-zero probability in my usage.
But more importantly (from `(libc.info.gz)Attribute Meanings'):

    `off_t st_size'
          This specifies the size of a regular file in bytes.  For
          files that are really devices this field isn't usually
          meaningful.  For symbolic links this specifies the length of
          the file name the link refers to.

Note that apparently, stat is only supposed to return a well defined
value for st_size for regular files and for symbolic links, not for
directories.  You told me it returns a meaningful value on ms-dos.
Why would that lead us to assume that it returns a meaningful value on
all operating systems?  It definitely does not return something
terribly useful on GNU/Linux.  Maybe on other operating systems it
returns garbage that changes on every call regardless of whether there
was any change in the directory.

   (In general, I'm opposed to planting into Emacs user-level features
   implicit assumptions about Posix-specific behavior, in this case, that
   a directory is just another file.  Yes, I know: Emacs is being
   developed primarily for Posix-compliant platforms, bla, bla...)

And I'm opposed to planting into Emacs user-level features implicit
assumptions about MS-DOS-port-specific behavior, in this case, that
st_size is useful to reliably determine the directory size.  If you
want to do this for ms-dos, then that is your prerogative as a
maintainer (the patch below would do that), but I do not believe that
one can just blindly do this for any operating system without knowing
what stat is going to do on that system.

   I don't see how adding a call to file-attributes is a big deal that
   needs a call for volunteers,

It is not.  See the patch below.  I already explained in a previous
message what I really meant.

I do not have access to a machine with an MS operating system and
Emacs CVS installed.  Hence I can not test the patch below.  It
compiles without warnings.  To test the patch below, set
global-auto-revert-non-file-buffers to t.  I just noticed that there
are bad bugs in the vc-part of the original autorevert patch (not my
patch, the prior one).  These are not yet taken care of.  If you do
not want to be confronted with these bugs while testing the patch,
just do not visit any CVS buffer with uncommitted changes while testing.

===File ~/dired-diff========================================
diff -c /home/teirllm/dired.old.el /home/teirllm/emacscvsdir/emacs/lisp/dired.el
*** /home/teirllm/dired.old.el  Wed Mar 24 22:07:09 2004
--- /home/teirllm/emacscvsdir/emacs/lisp/dired.el       Wed Mar 24 23:46:37 2004
***************
*** 525,530 ****
--- 525,538 ----
        (setq dir-or-list dirname))
      (dired-internal-noselect dir-or-list switches)))
  
+ (defvar dired-directory-size nil
+   "Internal variable used by dired on certain operating systems.
+ On ms-dos, the value is the sum of all file lenghts in the directory.
+ On other operating systems, the value may have a different meaning
+ or be meaningless.")
+ 
+ (put 'dired-directory-size 'permanent-local t)
+ 
  ;; The following is an internal dired function.  It returns non-nil if
  ;; the directory visited by the current dired buffer has changed on
  ;; disk.  DIRNAME should be the directory name of that directory.
***************
*** 534,540 ****
         (or (eq modtime 0)
             (not (eq (car attributes) t))
             (and (= (car (nth 5 attributes)) (car modtime))
!                 (= (nth 1 (nth 5 attributes)) (cdr modtime)))))))
  
  (defun dired-buffer-stale-p (&optional noconfirm)
    "Return non-nil if current dired buffer needs updating.
--- 542,552 ----
         (or (eq modtime 0)
             (not (eq (car attributes) t))
             (and (= (car (nth 5 attributes)) (car modtime))
!                 (= (nth 1 (nth 5 attributes)) (cdr modtime))
!                 (if (eq system-type 'ms-dos)
!                     ;; This does not work perfectly.
!                     (= dired-directory-size (nth 7 attributes))
!                   t))))))
  
  (defun dired-buffer-stale-p (&optional noconfirm)
    "Return non-nil if current dired buffer needs updating.
***************
*** 677,682 ****
--- 689,696 ----
        ;; dired-build-subdir-alist will call dired-clear-alist first
        (set (make-local-variable 'dired-subdir-alist) nil)
        (dired-build-subdir-alist)
+       (set (make-local-variable 'dired-directory-size)
+          (nth 7 (file-attributes dirname)))
        (let ((attributes (file-attributes dirname)))
        (if (eq (car attributes) t)
            (set-visited-file-modtime (nth 5 attributes))))

Diff finished.  Wed Mar 24 23:49:01 2004
============================================================




reply via email to

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