all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (tramp-handleverify-visited-file-modtime
@ 2004-07-11 16:34 Luc Teirlinck
  2004-07-11 16:42 ` (tramp-handleverify-visited-file-modtime Luc Teirlinck
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Luc Teirlinck @ 2004-07-11 16:34 UTC (permalink / raw)
  Cc: emacs-devel

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.
============================================================

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-07-25 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-11 16:34 (tramp-handleverify-visited-file-modtime Luc Teirlinck
2004-07-11 16:42 ` (tramp-handleverify-visited-file-modtime Luc Teirlinck
2004-07-11 17:06 ` (tramp-handleverify-visited-file-modtime Luc Teirlinck
2004-07-11 17:35   ` (tramp-handleverify-visited-file-modtime Luc Teirlinck
2004-07-24 18:46 ` (tramp-handleverify-visited-file-modtime Michael Albinus
2004-07-25  2:11   ` (tramp-handleverify-visited-file-modtime Luc Teirlinck
2004-07-25 11:00     ` (tramp-handleverify-visited-file-modtime Michael Albinus

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.