emacs-devel
[Top][All Lists]
Advanced

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

(tramp-handleverify-visited-file-modtime


From: Luc Teirlinck
Subject: (tramp-handleverify-visited-file-modtime
Date: Sun, 11 Jul 2004 11:34:51 -0500 (CDT)

There is is another apparent problem with
`tramp-handleverify-visited-file-modtime' that has nothing to do with
the proposed change in `visited-file-modtime':

             ;; If file does not exist, say it is not modified.
                (t nil)))))))

If the file is not modified,
`tramp-handle-verify-visited-file-modtime' should return t, not nil.
Moreover, replacing (t nil) with (t t) is not sufficient, because an
error is going to be thrown earlier if the buffer is not visiting a
file;

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (verify-visited-file-modtime (get-buffer "*scratch*"))
t
ELISP> (load "tramp")
t
ELISP> (tramp-handle-verify-visited-file-modtime (get-buffer "*scratch*"))
*** Eval error ***  Wrong type argument: stringp, nil
ELISP> 

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?

===File ~/tramp-diff-4======================================
*** tramp.el    26 Jun 2004 16:46:18 -0500      1.46
--- tramp.el    11 Jul 2004 11:22:58 -0500      
***************
*** 2334,2363 ****
    "Like `verify-visited-file-modtime' for tramp files."
    (with-current-buffer buf
      (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))))
!                ;; Why does `file-attributes' return a list (HIGH
!                ;; LOW), but `visited-file-modtime' returns a cons
!                ;; (HIGH . LOW)?
!                (let ((mt (visited-file-modtime)))
!                  (< (abs (tramp-time-diff
!                           modtime (list (car mt) (cdr mt)))) 2)))
!               (attr
!                (save-excursion
!                  (tramp-send-command
!                   multi-method method user host
!                   (format "%s -ild %s"
!                           (tramp-get-ls-command multi-method method
!                                                 user host)
!                           (tramp-shell-quote-argument localname)))
!                  (tramp-wait-for-output)
!                  (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 nil)))))))
  
  (defadvice clear-visited-file-modtime (after tramp activate)
    "Set `tramp-buffer-file-attributes' back to nil.
--- 2334,2370 ----
    "Like `verify-visited-file-modtime' for tramp files."
    (with-current-buffer buf
      (let ((f (buffer-file-name)))
!       (if (not f)
!         t
!       (with-parsed-tramp-file-name f nil
!         (let* ((attr (file-attributes f))
!                (modtime (nth 5 attr)))
!           (cond ((eq (visited-file-modtime) 0))
!                 ((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 (and (consp mt) (atom (cdr mt)))
!                                 (list (car mt) (cdr mt))
!                               mt)))
!                       2)))
!                 (attr
!                  (save-excursion
!                    (tramp-send-command
!                     multi-method method user host
!                     (format "%s -ild %s"
!                             (tramp-get-ls-command multi-method method
!                                                   user host)
!                             (tramp-shell-quote-argument localname)))
!                    (tramp-wait-for-output)
!                    (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.
============================================================




reply via email to

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