all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org
Subject: (tramp-handleverify-visited-file-modtime
Date: Sun, 11 Jul 2004 11:34:51 -0500 (CDT)	[thread overview]
Message-ID: <200407111634.i6BGYpw11715@raven.dms.auburn.edu> (raw)

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	other threads:[~2004-07-11 16:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-11 16:34 Luc Teirlinck [this message]
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

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

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

  git send-email \
    --in-reply-to=200407111634.i6BGYpw11715@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --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 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.