Adapt hooks in Tramp
* lisp/net/tramp-archive.el (tramp-archive-cleanup-hash): Remove autoload cookie. (tramp-cleanup-all-connections-hook): Add `tramp-archive-cleanup-hash'. * lisp/net/tramp-cmds.el (tramp-cleanup-connection-hook) (tramp-cleanup-all-connections-hook): New hook variables. (tramp-cleanup-connection): Set `tramp-current-connection' always to nil. (tramp-cleanup-connection): Do not call `tramp-recentf-cleanup'. Run ´tramp-cleanup-connection-hook`. (tramp-cleanup-all-connections): Do not call `tramp-archive-cleanup-hash' and ´tramp-recentf-cleanup'. Run `tramp-cleanup-all-connections-hook'. * lisp/net/tramp-ftp.el (top): Simply call `tramp-disable-ange-ftp'. * lisp/net/tramp-integration.el (tramp-recentf-cleanup-all): New defun. (top): Adapt `tramp-integration-unload-hook', `tramp-cleanup-connection-hook' and `tramp-cleanup-all-connections-hook'.
This commit is contained in:
parent
6a3b1aaa06
commit
cedc3410d4
4 changed files with 46 additions and 23 deletions
|
@ -369,13 +369,13 @@ pass to the OPERATION."
|
|||
(when url-handler-mode (tramp-register-file-name-handlers))
|
||||
|
||||
(eval-after-load 'url-handler
|
||||
(progn
|
||||
(add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers)
|
||||
(add-hook
|
||||
'tramp-archive-unload-hook
|
||||
(lambda ()
|
||||
(remove-hook
|
||||
'url-handler-mode-hook 'tramp-register-file-name-handlers)))))
|
||||
'(progn
|
||||
(add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers)
|
||||
(add-hook
|
||||
'tramp-archive-unload-hook
|
||||
(lambda ()
|
||||
(remove-hook
|
||||
'url-handler-mode-hook 'tramp-register-file-name-handlers)))))
|
||||
|
||||
|
||||
;; File name conversions.
|
||||
|
@ -467,7 +467,6 @@ name is kept in slot `hop'"
|
|||
(setf (tramp-file-name-localname vec) localname)
|
||||
vec)))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-archive-cleanup-hash ()
|
||||
"Remove local copies of archives, used by GVFS."
|
||||
(maphash
|
||||
|
@ -482,9 +481,12 @@ name is kept in slot `hop'"
|
|||
tramp-archive-hash)
|
||||
(clrhash tramp-archive-hash))
|
||||
|
||||
(add-hook 'tramp-cleanup-all-connections-hook 'tramp-archive-cleanup-hash)
|
||||
(add-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash)
|
||||
(add-hook 'tramp-archive-unload-hook
|
||||
(lambda ()
|
||||
(remove-hook 'tramp-cleanup-all-connections-hook
|
||||
'tramp-archive-cleanup-hash)
|
||||
(remove-hook 'kill-emacs-hook
|
||||
'tramp-archive-cleanup-hash)))
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ SYNTAX can be one of the symbols `default' (default),
|
|||
(with-current-buffer x (when (tramp-tramp-file-p default-directory) x)))
|
||||
(buffer-list))))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defvar tramp-cleanup-connection-hook nil
|
||||
"List of functions to be called after Tramp connection is cleaned up.
|
||||
Each function is called with the current vector as argument.")
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-cleanup-connection (vec &optional keep-debug keep-password)
|
||||
"Flush all connection related objects.
|
||||
|
@ -99,9 +104,8 @@ When called interactively, a Tramp connection has to be selected."
|
|||
(unless keep-password (tramp-clear-passwd vec))
|
||||
|
||||
;; Cleanup `tramp-current-connection'. Otherwise, we would be
|
||||
;; suppressed in the test suite. We use `keep-password' as
|
||||
;; indicator; it is not worth to add a new argument.
|
||||
(when keep-password (setq tramp-current-connection nil))
|
||||
;; suppressed.
|
||||
(setq tramp-current-connection nil)
|
||||
|
||||
;; Flush file cache.
|
||||
(tramp-flush-directory-properties vec "")
|
||||
|
@ -120,8 +124,8 @@ When called interactively, a Tramp connection has to be selected."
|
|||
(tramp-get-connection-property vec "process-buffer" nil)))
|
||||
(when (bufferp buf) (kill-buffer buf)))
|
||||
|
||||
;; Remove recentf files.
|
||||
(tramp-recentf-cleanup vec)))
|
||||
;; The end.
|
||||
(run-hook-with-args 'tramp-cleanup-connection-hook vec)))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-cleanup-this-connection ()
|
||||
|
@ -131,6 +135,10 @@ When called interactively, a Tramp connection has to be selected."
|
|||
(tramp-cleanup-connection
|
||||
(tramp-dissect-file-name default-directory 'noexpand))))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defvar tramp-cleanup-all-connections-hook nil
|
||||
"List of functions to be called after all Tramp connections are cleaned up.")
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-cleanup-all-connections ()
|
||||
"Flush all Tramp internal objects.
|
||||
|
@ -146,10 +154,6 @@ This includes password cache, file cache, connection cache, buffers."
|
|||
;; Flush file and connection cache.
|
||||
(clrhash tramp-cache-data)
|
||||
|
||||
;; Cleanup local copies of archives.
|
||||
(when (bound-and-true-p tramp-archive-enabled)
|
||||
(tramp-archive-cleanup-hash))
|
||||
|
||||
;; Remove ad-hoc proxies.
|
||||
(let ((proxies tramp-default-proxies-alist))
|
||||
(while proxies
|
||||
|
@ -167,9 +171,8 @@ This includes password cache, file cache, connection cache, buffers."
|
|||
(dolist (name (tramp-list-tramp-buffers))
|
||||
(when (bufferp (get-buffer name)) (kill-buffer name)))
|
||||
|
||||
;; Remove recentf files.
|
||||
(dolist (v (tramp-list-connections))
|
||||
(tramp-recentf-cleanup v)))
|
||||
;; The end.
|
||||
(run-hooks 'tramp-cleanup-all-connections-hook))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-cleanup-all-buffers ()
|
||||
|
|
|
@ -54,8 +54,7 @@ present for backward compatibility."
|
|||
(delete a1 (delete a2 file-name-handler-alist)))))
|
||||
|
||||
(eval-after-load "ange-ftp"
|
||||
'(when (functionp 'tramp-disable-ange-ftp)
|
||||
(tramp-disable-ange-ftp)))
|
||||
'(tramp-disable-ange-ftp))
|
||||
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-ftp-enable-ange-ftp ()
|
||||
|
|
|
@ -128,7 +128,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
|
|||
'tramp-eshell-directory-change)
|
||||
(add-hook 'eshell-directory-change-hook
|
||||
'tramp-eshell-directory-change)
|
||||
(add-hook 'tramp-unload-hook
|
||||
(add-hook 'tramp-integration-unload-hook
|
||||
(lambda ()
|
||||
(remove-hook 'eshell-mode-hook
|
||||
'tramp-eshell-directory-change)
|
||||
|
@ -151,6 +151,25 @@ NAME must be equal to `tramp-current-connection'."
|
|||
(recentf-exclude '(tramp-recentf-exclude-predicate)))
|
||||
(recentf-cleanup))))
|
||||
|
||||
(defun tramp-recentf-cleanup-all ()
|
||||
"Remove all remote file names from recentf."
|
||||
(when (bound-and-true-p recentf-list)
|
||||
(let ((recentf-exclude '(file-remote-p)))
|
||||
(recentf-cleanup))))
|
||||
|
||||
(eval-after-load "recentf"
|
||||
'(progn
|
||||
(add-hook 'tramp-cleanup-connection-hook
|
||||
'tramp-recentf-cleanup)
|
||||
(add-hook 'tramp-cleanup-all-connections-hook
|
||||
'tramp-recentf-cleanup-all)
|
||||
(add-hook 'tramp-integration-unload-hook
|
||||
(lambda ()
|
||||
(remove-hook 'tramp-cleanup-connection-hook
|
||||
'tramp-recentf-cleanup)
|
||||
(remove-hook 'tramp-cleanup-all-connections-hook
|
||||
'tramp-recentf-cleanup-all)))))
|
||||
|
||||
(add-hook 'tramp-unload-hook
|
||||
(lambda () (unload-feature 'tramp-integration 'force)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue