Function: tramp-cleanup-connection
tramp-cleanup-connection is an autoloaded, interactive and
byte-compiled function defined in tramp-cmds.el.gz.
Signature
(tramp-cleanup-connection VEC &optional KEEP-DEBUG KEEP-PASSWORD KEEP-PROCESSES)
Documentation
Flush all connection related objects.
This includes password cache, file cache, connection cache, buffers, processes. KEEP-DEBUG non-nil preserves the debug buffer. KEEP-PASSWORD non-nil preserves the password cache. KEEP-PROCESSES non-nil preserves the asynchronous processes. When called interactively, a Tramp connection has to be selected.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-cmds.el.gz
;;;###tramp-autoload
(defun tramp-cleanup-connection
(vec &optional keep-debug keep-password keep-processes)
"Flush all connection related objects.
This includes password cache, file cache, connection cache,
buffers, processes. KEEP-DEBUG non-nil preserves the debug
buffer. KEEP-PASSWORD non-nil preserves the password cache.
KEEP-PROCESSES non-nil preserves the asynchronous processes.
When called interactively, a Tramp connection has to be selected."
(interactive
;; When interactive, select the Tramp remote identification.
;; Return nil when there is no Tramp connection.
(list
(let ((connections
(mapcar #'tramp-make-tramp-file-name (tramp-list-connections)))
name)
(when connections
(setq name
(completing-read
"Enter Tramp connection: " connections nil t
(try-completion "" connections)))
(and (tramp-tramp-file-p name) (tramp-dissect-file-name name))))
nil nil))
(if (not vec)
;; Nothing to do.
(message "No Tramp connection found.")
;; Flush password cache.
(unless keep-password (tramp-clear-passwd vec))
;; Cleanup `tramp-current-connection'. Otherwise, we would be
;; suppressed.
(setq tramp-current-connection nil)
;; Cancel timer.
(dolist (timer timer-list)
(when (and (eq (timer--function timer) 'tramp-timeout-session)
(tramp-file-name-equal-p vec (car (timer--args timer))))
(cancel-timer timer)))
;; Delete processes.
(dolist (key (hash-table-keys tramp-cache-data))
(when (and (processp key)
(tramp-file-name-equal-p (process-get key 'vector) vec)
(or (not keep-processes)
(eq key (tramp-get-process vec))))
(tramp-flush-connection-properties key)
(delete-process key)))
;; Remove buffers.
(dolist
(buf (list (get-buffer (tramp-buffer-name vec))
(unless keep-debug
(get-buffer (tramp-debug-buffer-name vec)))
(unless keep-debug
(get-buffer (tramp-trace-buffer-name vec)))
(tramp-get-connection-property vec "process-buffer" nil)))
(when (bufferp buf) (kill-buffer buf)))
;; Flush file cache.
(tramp-flush-directory-properties vec "")
;; Flush connection cache.
(tramp-flush-connection-properties vec)
;; The end.
(run-hook-with-args 'tramp-cleanup-connection-hook vec)))