From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: (tramp-handleverify-visited-file-modtime Date: Sun, 11 Jul 2004 11:34:51 -0500 (CDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200407111634.i6BGYpw11715@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1089563878 25226 80.91.224.253 (11 Jul 2004 16:37:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Jul 2004 16:37:58 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Jul 11 18:37:53 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BjhKq-0005LR-00 for ; Sun, 11 Jul 2004 18:37:52 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BjhKq-0005Bk-00 for ; Sun, 11 Jul 2004 18:37:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BjhN7-0008Px-Of for emacs-devel@quimby.gnus.org; Sun, 11 Jul 2004 12:40:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BjhMz-0008Ps-TZ for emacs-devel@gnu.org; Sun, 11 Jul 2004 12:40:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BjhMy-0008Pg-1K for emacs-devel@gnu.org; Sun, 11 Jul 2004 12:40:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BjhMx-0008Pc-At for emacs-devel@gnu.org; Sun, 11 Jul 2004 12:40:03 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BjhKU-0004PS-3S for emacs-devel@gnu.org; Sun, 11 Jul 2004 12:37:30 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i6BGbSuE013871; Sun, 11 Jul 2004 11:37:28 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id i6BGYpw11715; Sun, 11 Jul 2004 11:34:51 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: Kai Grossjohann X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25585 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25585 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. ============================================================