emacs-devel
[Top][All Lists]
Advanced

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

Re: (tramp-handleverify-visited-file-modtime


From: Luc Teirlinck
Subject: Re: (tramp-handleverify-visited-file-modtime
Date: Sat, 24 Jul 2004 21:11:01 -0500 (CDT)

Michael Albinus wrote:

   Luc Teirlinck <address@hidden> writes:

   > Because `tramp-handle-verify-visited-file-modtime' is supposed to
   > emulate `verify-visited-file-modtime' I believe it should return t,
   > like `visited-visited-file-modtime' does.
   >
   > So what about the following patch?

   I've committed a looks-like-this patch to Tramp CVS.

   Best regards, Michael.

Actually, I recommend the following patch to the present Tramp CVS
version (not the Emacs CVS version) of tramp.el.  The reason is that
we want to return t for a file that does not exist according to
`file-attributes' _and_ for which (visited-file-modtime) returns -1,
but nil if `file-attributes' returns nil and `visited-file-modtime'
returns a "real" modtime (neither 0 nor -1), meaning the file _did_
exist the last time we checked, but has been deleted in the meantime.

To be completely consistent with `verify-visited-file-modtime' we
should also return nil if the file system could not handle the file
name because it was too long (never happens on the GNU system) or
because there were too many symbolic links to follow.  I do not know
whether this case is important enough to worry about.  (The patch
below does not.)  How were we even able to visit the file in the first
place in such a situation?


===File ~/tramp-CVS-diff====================================
*** tramp.el    24 Jul 2004 14:12:22 -0500      2.381
--- tramp.el    24 Jul 2004 19:34:27 -0500      
***************
*** 2342,2360 ****
        (let ((f (buffer-file-name)))
        (with-parsed-tramp-file-name f nil
          (let* ((attr (file-attributes f))
!                (modtime (nth 5 attr)))
            
            (cond ((and attr (not (equal modtime '(0 0))))
!                  (let ((mt (visited-file-modtime)))
!                    (< (abs (tramp-time-diff
!                             modtime
!                             ;; For compatibility, deal with both the old
!                             ;; (HIGH . LOW) and the new (HIGH LOW)
!                             ;; return values of `visited-file-modtime'.
!                             (if (atom (cdr mt))
!                                 (list (car mt) (cdr mt))
!                               mt)))
!                       2)))
                  ;; modtime has the don't know value.
                  (attr
                   (save-excursion
--- 2342,2360 ----
        (let ((f (buffer-file-name)))
        (with-parsed-tramp-file-name f nil
          (let* ((attr (file-attributes f))
!                (modtime (nth 5 attr))
!                (mt (visited-file-modtime)))
            
            (cond ((and attr (not (equal modtime '(0 0))))
!                  (< (abs (tramp-time-diff
!                           modtime
!                           ;; For compatibility, deal with both the old
!                           ;; (HIGH . LOW) and the new (HIGH LOW)
!                           ;; return values of `visited-file-modtime'.
!                           (if (atom (cdr mt))
!                               (list (car mt) (cdr mt))
!                             mt)))
!                     2))
                  ;; modtime has the don't know value.
                  (attr
                   (save-excursion
***************
*** 2368,2375 ****
                     (setq attr (buffer-substring
                                 (point) (progn (end-of-line) (point)))))
                   (equal tramp-buffer-file-attributes attr))
!                 ;; If file does not exist, say it is not modified.
!                 (t t))))))))
  
  (defadvice clear-visited-file-modtime (after tramp activate)
    "Set `tramp-buffer-file-attributes' back to nil.
--- 2368,2376 ----
                     (setq attr (buffer-substring
                                 (point) (progn (end-of-line) (point)))))
                   (equal tramp-buffer-file-attributes attr))
!                 ;; If file does not exist, say it is not modified
!                 ;; if and only if that agrees with the buffer's record.
!                 (t (equal mt '(-1 65535))))))))))
  
  (defadvice clear-visited-file-modtime (after tramp activate)
    "Set `tramp-buffer-file-attributes' back to nil.
============================================================




reply via email to

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