# HG changeset patch # User Michael Albinus # Date 1195381491 0 # Node ID 7d7472ea9c0aa71c08758fbe2181e95b91b64ac2 # Parent 9aea71efb681e432fd72a8874bd3986a4014b3c6 * 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. diff -r 9aea71efb681 -r 7d7472ea9c0a lisp/ChangeLog --- a/lisp/ChangeLog Sat Nov 17 18:23:01 2007 +0000 +++ b/lisp/ChangeLog Sun Nov 18 10:24:51 2007 +0000 @@ -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 -r 9aea71efb681 -r 7d7472ea9c0a lisp/net/tramp-ftp.el --- a/lisp/net/tramp-ftp.el Sat Nov 17 18:23:01 2007 +0000 +++ b/lisp/net/tramp-ftp.el Sun Nov 18 10:24:51 2007 +0000 @@ -152,6 +152,7 @@ (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 @@ (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 -r 9aea71efb681 -r 7d7472ea9c0a lisp/net/tramp.el --- a/lisp/net/tramp.el Sat Nov 17 18:23:01 2007 +0000 +++ b/lisp/net/tramp.el Sun Nov 18 10:24:51 2007 +0000 @@ -1425,6 +1425,18 @@ :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 @@ "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 @@ (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 @@ ; 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 @@ 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 @@ (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)