From 3c586e182c0694896dda670f5fc663b46c9bac63 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 15 Sep 2016 09:24:07 +0200 Subject: [PATCH] Rework fixing Bug#24432 * lisp/net/tramp.el (tramp-get-buffer): Set connection property "process-buffer" in order to mark connection as active. * lisp/net/tramp-cache.el (tramp-get-hash-table) (tramp-set-connection-property) (tramp-dump-connection-properties): Do not use "active" property. (tramp-list-connections): Use "process-buffer" property. * lisp/net/tramp-cmds.el (tramp-cleanup-connection): Flush process properties prior deletion of process. --- lisp/net/tramp-cache.el | 12 ++++-------- lisp/net/tramp-cmds.el | 6 ++++-- lisp/net/tramp.el | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index 43b3ba07708..531044fddfd 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -99,8 +99,7 @@ matching entries of `tramp-connection-properties'." (or (nth 0 elt) "") (tramp-make-tramp-file-name (aref key 0) (aref key 1) (aref key 2) nil)) - (tramp-set-connection-property key (nth 1 elt) (nth 2 elt)))) - (tramp-set-connection-property key "active" 'undef)) + (tramp-set-connection-property key (nth 1 elt) (nth 2 elt))))) hash))) ;;;###tramp-autoload @@ -263,7 +262,6 @@ KEY is a vector." (aset key 3 nil) (aset key 4 nil)) (let ((hash (tramp-get-hash-table key))) - (puthash "active" t hash) (puthash property value hash) (setq tramp-cache-data-changed t) (tramp-message key 7 "%s %s" property value) @@ -333,11 +331,11 @@ properties of the local machine." ;;;###tramp-autoload (defun tramp-list-connections () "Return a list of all known connection vectors according to `tramp-cache'." - (let (result) + (let (result tramp-verbose) (maphash (lambda (key _value) (when (and (vectorp key) (null (aref key 3)) - (tramp-connection-property-p key "active")) + (tramp-connection-property-p key "process-buffer")) (add-to-list 'result key))) tramp-cache-data) result)) @@ -362,7 +360,6 @@ properties of the local machine." (not (tramp-file-name-localname key)) (not (gethash "login-as" value))) (progn - (remhash "active" value) (remhash "process-name" value) (remhash "process-buffer" value) (remhash "first-password-request" value)) @@ -430,8 +427,7 @@ for all methods. Resulting data are derived from connection history." ;; `tramp-connection-properties'. The cache is ;; initialized properly by side effect. (unless (tramp-connection-property-p key (car item)) - (tramp-set-connection-property key (pop item) (car item)))) - (tramp-set-connection-property key "active" 'undef))) + (tramp-set-connection-property key (pop item) (car item)))))) (setq tramp-cache-data-changed nil)) (file-error ;; Most likely because the file doesn't exist yet. No message. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 45f30042ad8..d0c49156500 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -101,8 +101,8 @@ When called interactively, a Tramp connection has to be selected." ;; Flush connection cache. (when (processp (tramp-get-connection-process vec)) - (delete-process (tramp-get-connection-process vec)) - (tramp-flush-connection-property (tramp-get-connection-process vec))) + (tramp-flush-connection-property (tramp-get-connection-process vec)) + (delete-process (tramp-get-connection-process vec))) (tramp-flush-connection-property vec) ;; Remove buffers. @@ -384,10 +384,12 @@ please ensure that the buffers are attached to your email.\n\n")) ;;; TODO: ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) +;; ;; * WIBNI there was an interactive command prompting for Tramp ;; method, hostname, username and filename and translates the user ;; input into the correct filename syntax (depending on the Emacs ;; flavor) (Reiner Steib) +;; ;; * Let the user edit the connection properties interactively. ;; Something like `gnus-server-edit-server' in Gnus' *Server* buffer. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index ad00f31010f..0dade732c46 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1314,6 +1314,7 @@ necessary only. This function will be used in file name completion." "Get the connection buffer to be used for VEC." (or (get-buffer (tramp-buffer-name vec)) (with-current-buffer (get-buffer-create (tramp-buffer-name vec)) + (tramp-set-connection-property vec "process-buffer" nil) (setq buffer-undo-list t) (setq default-directory (tramp-make-tramp-file-name @@ -4306,30 +4307,40 @@ Only works for Bourne-like shells." ;; * In Emacs 21, `insert-directory' shows total number of bytes used ;; by the files in that directory. Add this here. +;; ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) +;; ;; * Better error checking. At least whenever we see something ;; strange when doing zerop, we should kill the process and start ;; again. (Greg Stark) -;; * Username and hostname completion. -;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode-p'. -;; * Make `tramp-default-user' obsolete. +;; ;; * Implement a general server-local-variable mechanism, as there are ;; probably other variables that need different values for different ;; servers too. The user could then configure a variable (such as ;; tramp-server-local-variable-alist) to define any such variables ;; that they need to, which would then be let bound as appropriate ;; in tramp functions. (Jason Rumney) +;; ;; * Make shadowfile.el grok Tramp filenames. (Bug#4526, Bug#4846) +;; ;; * I was wondering if it would be possible to use tramp even if I'm ;; actually using sshfs. But when I launch a command I would like ;; to get it executed on the remote machine where the files really ;; are. (Andrea Crotti) +;; ;; * Run emerge on two remote files. Bug is described here: ;; . ;; (Bug#6850) +;; ;; * Use also port to distinguish connections. This is needed for ;; different hosts sitting behind a single router (distinguished by ;; different port numbers). (Tzvi Edelman) +;; +;; * Refactor code from different handlers. Start with +;; *-process-file. One idea is to generalize `tramp-send-command' +;; and friends, for most of the handlers this is the major +;; difference between the different backends. Other handlers but +;; *-process-file would profit from this as well. ;;; tramp.el ends here -- 2.11.4.GIT