From b50dd0d2b6316e1278a40238a1ac9ae55b98a148 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 18 Nov 2007 10:24:51 +0000 Subject: [PATCH] * net/tramp.el (tramp-completion-reread-directory-timeout): New defcustom. (tramp-handle-file-name-all-completions): Flush directory contents from cache regularly. (tramp-set-auto-save-file-modes): Check also for `buffer-modified-p'. (tramp-open-connection-setup-interactive-shell): Call `tramp-cleanup-connection' via funcall. * net/tramp-ftp.el (tramp-ftp-file-name-handler): Temp file is already created when copying. --- lisp/ChangeLog | 14 ++++++++++++++ lisp/net/tramp-ftp.el | 13 +++++++++++-- lisp/net/tramp.el | 29 +++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 466e1d7349e..94bc86ce1a1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2007-11-18 Michael Albinus + + * net/tramp.el (tramp-completion-reread-directory-timeout): New + defcustom. + (tramp-handle-file-name-all-completions): Flush directory contents + from cache regularly. + (tramp-set-auto-save-file-modes): Check also for + `buffer-modified-p'. + (tramp-open-connection-setup-interactive-shell): Call + `tramp-cleanup-connection' via funcall. + + * net/tramp-ftp.el (tramp-ftp-file-name-handler): Temp file is already + created when copying. + 2007-11-17 Dan Nicolaescu * eshell/esh-util.el (eshell-under-xemacs-p): Remove. diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index a8b6bca44f2..c4edd2f3fa4 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el @@ -152,6 +152,7 @@ pass to the OPERATION." (aset v 0 tramp-ftp-method) (tramp-set-connection-property v "started" t)) nil)) + ;; If the second argument of `copy-file' or `rename-file' is a ;; remote file name but via FTP, ange-ftp doesn't check this. ;; We must copy it locally first, because there is no place in @@ -163,8 +164,16 @@ pass to the OPERATION." (newname (cadr args)) (tmpfile (tramp-compat-make-temp-file filename)) (args (cddr args))) - (apply operation filename tmpfile args) - (rename-file tmpfile newname (car args)))) + ;; We must set `ok-if-already-exists' to t in the first + ;; step, because the temp file has been created already. + (if (eq operation 'copy-file) + (apply operation filename tmpfile t (cdr args)) + (apply operation filename tmpfile t)) + (unwind-protect + (rename-file tmpfile newname (car args)) + ;; Cleanup. + (ignore-errors (delete-file tmpfile))))) + ;; Normally, the handlers must be discarded. (t (let* ((inhibit-file-name-handlers (list 'tramp-file-name-handler diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a1b4bec1f5f..1ccf02d4353 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1425,6 +1425,18 @@ opening a connection to a remote host." :group 'tramp :type '(choice (const nil) (const t) (const pty))) +(defcustom tramp-completion-reread-directory-timeout 10 + "Defines seconds since last remote command before rereading a directory. +A remote directory might have changed its contents. In order to +make it visible during file name completion in the minibuffer, +Tramp flushes its cache and rereads the directory contents when +more than `tramp-completion-reread-directory-timeout' seconds +have been gone since last remote command execution. A value of 0 +would require an immediate reread during filename completion, nil +means to use always cached values for the directory contents." + :group 'tramp + :type '(choice (const nil) integer)) + ;;; Internal Variables: (defvar tramp-end-of-output @@ -2807,6 +2819,16 @@ and gid of the corresponding user is taken. Both parameters must be integers." "Like `file-name-all-completions' for Tramp files." (unless (save-match-data (string-match "/" filename)) (with-parsed-tramp-file-name (expand-file-name directory) nil + ;; Flush the directory cache. There could be changed directory + ;; contents. + (when (and (integerp tramp-completion-reread-directory-timeout) + (> (tramp-time-diff + (current-time) + (tramp-get-file-property + v localname "last-completion" '(0 0 0))) + tramp-completion-reread-directory-timeout)) + (tramp-flush-file-property v localname)) + (all-completions filename (mapcar @@ -2838,6 +2860,8 @@ and gid of the corresponding user is taken. Both parameters must be integers." (point) (tramp-compat-line-end-position)) result))) + (tramp-set-file-property + v localname "last-completion" (current-time)) result))))))) ;; The following isn't needed for Emacs 20 but for 19.34? @@ -4323,7 +4347,7 @@ ARGS are the arguments OPERATION has been called with." ; BUF ((member operation (list 'set-visited-file-modtime 'verify-visited-file-modtime - ; Emacs 22 only + ; since Emacs 22 only 'make-auto-save-file-name ; XEmacs only 'backup-buffer)) @@ -5699,7 +5723,7 @@ process to set up. VEC specifies the connection." vec "uname" (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\"")))) (when (and (stringp old-uname) (not (string-equal old-uname new-uname))) - (tramp-cleanup-connection vec) + (funcall (symbol-function 'tramp-cleanup-connection) vec) (signal 'quit (list (format @@ -6982,6 +7006,7 @@ If the `tramp-methods' entry does not exist, return NIL." (let ((bfn (buffer-file-name))) (when (and (stringp bfn) (tramp-tramp-file-p bfn) + (buffer-modified-p) (stringp buffer-auto-save-file-name) (not (equal bfn buffer-auto-save-file-name))) (unless (file-exists-p buffer-auto-save-file-name) -- 2.39.2