diff options
| author | Michael Albinus | 2019-02-25 11:59:52 +0100 |
|---|---|---|
| committer | Michael Albinus | 2019-02-25 11:59:52 +0100 |
| commit | cedc3410d4feab7b4beeef3eab474fbabad4035c (patch) | |
| tree | 7402bf4ff8d2b6d3f7b3ff897a6bcfa0077c0a07 | |
| parent | 6a3b1aaa066dac28355ca5d09550947250108950 (diff) | |
| download | emacs-cedc3410d4feab7b4beeef3eab474fbabad4035c.tar.gz emacs-cedc3410d4feab7b4beeef3eab474fbabad4035c.zip | |
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'.
| -rw-r--r-- | lisp/net/tramp-archive.el | 18 | ||||
| -rw-r--r-- | lisp/net/tramp-cmds.el | 27 | ||||
| -rw-r--r-- | lisp/net/tramp-ftp.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-integration.el | 21 |
4 files changed, 46 insertions, 23 deletions
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index db9aec05c20..dcddb0ec67d 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el | |||
| @@ -369,13 +369,13 @@ pass to the OPERATION." | |||
| 369 | (when url-handler-mode (tramp-register-file-name-handlers)) | 369 | (when url-handler-mode (tramp-register-file-name-handlers)) |
| 370 | 370 | ||
| 371 | (eval-after-load 'url-handler | 371 | (eval-after-load 'url-handler |
| 372 | (progn | 372 | '(progn |
| 373 | (add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers) | 373 | (add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers) |
| 374 | (add-hook | 374 | (add-hook |
| 375 | 'tramp-archive-unload-hook | 375 | 'tramp-archive-unload-hook |
| 376 | (lambda () | 376 | (lambda () |
| 377 | (remove-hook | 377 | (remove-hook |
| 378 | 'url-handler-mode-hook 'tramp-register-file-name-handlers))))) | 378 | 'url-handler-mode-hook 'tramp-register-file-name-handlers))))) |
| 379 | 379 | ||
| 380 | 380 | ||
| 381 | ;; File name conversions. | 381 | ;; File name conversions. |
| @@ -467,7 +467,6 @@ name is kept in slot `hop'" | |||
| 467 | (setf (tramp-file-name-localname vec) localname) | 467 | (setf (tramp-file-name-localname vec) localname) |
| 468 | vec))) | 468 | vec))) |
| 469 | 469 | ||
| 470 | ;;;###tramp-autoload | ||
| 471 | (defun tramp-archive-cleanup-hash () | 470 | (defun tramp-archive-cleanup-hash () |
| 472 | "Remove local copies of archives, used by GVFS." | 471 | "Remove local copies of archives, used by GVFS." |
| 473 | (maphash | 472 | (maphash |
| @@ -482,9 +481,12 @@ name is kept in slot `hop'" | |||
| 482 | tramp-archive-hash) | 481 | tramp-archive-hash) |
| 483 | (clrhash tramp-archive-hash)) | 482 | (clrhash tramp-archive-hash)) |
| 484 | 483 | ||
| 484 | (add-hook 'tramp-cleanup-all-connections-hook 'tramp-archive-cleanup-hash) | ||
| 485 | (add-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash) | 485 | (add-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash) |
| 486 | (add-hook 'tramp-archive-unload-hook | 486 | (add-hook 'tramp-archive-unload-hook |
| 487 | (lambda () | 487 | (lambda () |
| 488 | (remove-hook 'tramp-cleanup-all-connections-hook | ||
| 489 | 'tramp-archive-cleanup-hash) | ||
| 488 | (remove-hook 'kill-emacs-hook | 490 | (remove-hook 'kill-emacs-hook |
| 489 | 'tramp-archive-cleanup-hash))) | 491 | 'tramp-archive-cleanup-hash))) |
| 490 | 492 | ||
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 38e440e0930..cf4f7417475 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el | |||
| @@ -69,6 +69,11 @@ SYNTAX can be one of the symbols `default' (default), | |||
| 69 | (buffer-list)))) | 69 | (buffer-list)))) |
| 70 | 70 | ||
| 71 | ;;;###tramp-autoload | 71 | ;;;###tramp-autoload |
| 72 | (defvar tramp-cleanup-connection-hook nil | ||
| 73 | "List of functions to be called after Tramp connection is cleaned up. | ||
| 74 | Each function is called with the current vector as argument.") | ||
| 75 | |||
| 76 | ;;;###tramp-autoload | ||
| 72 | (defun tramp-cleanup-connection (vec &optional keep-debug keep-password) | 77 | (defun tramp-cleanup-connection (vec &optional keep-debug keep-password) |
| 73 | "Flush all connection related objects. | 78 | "Flush all connection related objects. |
| 74 | This includes password cache, file cache, connection cache, | 79 | This includes password cache, file cache, connection cache, |
| @@ -99,9 +104,8 @@ When called interactively, a Tramp connection has to be selected." | |||
| 99 | (unless keep-password (tramp-clear-passwd vec)) | 104 | (unless keep-password (tramp-clear-passwd vec)) |
| 100 | 105 | ||
| 101 | ;; Cleanup `tramp-current-connection'. Otherwise, we would be | 106 | ;; Cleanup `tramp-current-connection'. Otherwise, we would be |
| 102 | ;; suppressed in the test suite. We use `keep-password' as | 107 | ;; suppressed. |
| 103 | ;; indicator; it is not worth to add a new argument. | 108 | (setq tramp-current-connection nil) |
| 104 | (when keep-password (setq tramp-current-connection nil)) | ||
| 105 | 109 | ||
| 106 | ;; Flush file cache. | 110 | ;; Flush file cache. |
| 107 | (tramp-flush-directory-properties vec "") | 111 | (tramp-flush-directory-properties vec "") |
| @@ -120,8 +124,8 @@ When called interactively, a Tramp connection has to be selected." | |||
| 120 | (tramp-get-connection-property vec "process-buffer" nil))) | 124 | (tramp-get-connection-property vec "process-buffer" nil))) |
| 121 | (when (bufferp buf) (kill-buffer buf))) | 125 | (when (bufferp buf) (kill-buffer buf))) |
| 122 | 126 | ||
| 123 | ;; Remove recentf files. | 127 | ;; The end. |
| 124 | (tramp-recentf-cleanup vec))) | 128 | (run-hook-with-args 'tramp-cleanup-connection-hook vec))) |
| 125 | 129 | ||
| 126 | ;;;###tramp-autoload | 130 | ;;;###tramp-autoload |
| 127 | (defun tramp-cleanup-this-connection () | 131 | (defun tramp-cleanup-this-connection () |
| @@ -132,6 +136,10 @@ When called interactively, a Tramp connection has to be selected." | |||
| 132 | (tramp-dissect-file-name default-directory 'noexpand)))) | 136 | (tramp-dissect-file-name default-directory 'noexpand)))) |
| 133 | 137 | ||
| 134 | ;;;###tramp-autoload | 138 | ;;;###tramp-autoload |
| 139 | (defvar tramp-cleanup-all-connections-hook nil | ||
| 140 | "List of functions to be called after all Tramp connections are cleaned up.") | ||
| 141 | |||
| 142 | ;;;###tramp-autoload | ||
| 135 | (defun tramp-cleanup-all-connections () | 143 | (defun tramp-cleanup-all-connections () |
| 136 | "Flush all Tramp internal objects. | 144 | "Flush all Tramp internal objects. |
| 137 | This includes password cache, file cache, connection cache, buffers." | 145 | This includes password cache, file cache, connection cache, buffers." |
| @@ -146,10 +154,6 @@ This includes password cache, file cache, connection cache, buffers." | |||
| 146 | ;; Flush file and connection cache. | 154 | ;; Flush file and connection cache. |
| 147 | (clrhash tramp-cache-data) | 155 | (clrhash tramp-cache-data) |
| 148 | 156 | ||
| 149 | ;; Cleanup local copies of archives. | ||
| 150 | (when (bound-and-true-p tramp-archive-enabled) | ||
| 151 | (tramp-archive-cleanup-hash)) | ||
| 152 | |||
| 153 | ;; Remove ad-hoc proxies. | 157 | ;; Remove ad-hoc proxies. |
| 154 | (let ((proxies tramp-default-proxies-alist)) | 158 | (let ((proxies tramp-default-proxies-alist)) |
| 155 | (while proxies | 159 | (while proxies |
| @@ -167,9 +171,8 @@ This includes password cache, file cache, connection cache, buffers." | |||
| 167 | (dolist (name (tramp-list-tramp-buffers)) | 171 | (dolist (name (tramp-list-tramp-buffers)) |
| 168 | (when (bufferp (get-buffer name)) (kill-buffer name))) | 172 | (when (bufferp (get-buffer name)) (kill-buffer name))) |
| 169 | 173 | ||
| 170 | ;; Remove recentf files. | 174 | ;; The end. |
| 171 | (dolist (v (tramp-list-connections)) | 175 | (run-hooks 'tramp-cleanup-all-connections-hook)) |
| 172 | (tramp-recentf-cleanup v))) | ||
| 173 | 176 | ||
| 174 | ;;;###tramp-autoload | 177 | ;;;###tramp-autoload |
| 175 | (defun tramp-cleanup-all-buffers () | 178 | (defun tramp-cleanup-all-buffers () |
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index 4807fe0701c..8735d13f9dd 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el | |||
| @@ -54,8 +54,7 @@ present for backward compatibility." | |||
| 54 | (delete a1 (delete a2 file-name-handler-alist))))) | 54 | (delete a1 (delete a2 file-name-handler-alist))))) |
| 55 | 55 | ||
| 56 | (eval-after-load "ange-ftp" | 56 | (eval-after-load "ange-ftp" |
| 57 | '(when (functionp 'tramp-disable-ange-ftp) | 57 | '(tramp-disable-ange-ftp)) |
| 58 | (tramp-disable-ange-ftp))) | ||
| 59 | 58 | ||
| 60 | ;;;###tramp-autoload | 59 | ;;;###tramp-autoload |
| 61 | (defun tramp-ftp-enable-ange-ftp () | 60 | (defun tramp-ftp-enable-ange-ftp () |
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index f3f95f1b69c..e2a0d6b206f 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el | |||
| @@ -128,7 +128,7 @@ been set up by `rfn-eshadow-setup-minibuffer'." | |||
| 128 | 'tramp-eshell-directory-change) | 128 | 'tramp-eshell-directory-change) |
| 129 | (add-hook 'eshell-directory-change-hook | 129 | (add-hook 'eshell-directory-change-hook |
| 130 | 'tramp-eshell-directory-change) | 130 | 'tramp-eshell-directory-change) |
| 131 | (add-hook 'tramp-unload-hook | 131 | (add-hook 'tramp-integration-unload-hook |
| 132 | (lambda () | 132 | (lambda () |
| 133 | (remove-hook 'eshell-mode-hook | 133 | (remove-hook 'eshell-mode-hook |
| 134 | 'tramp-eshell-directory-change) | 134 | 'tramp-eshell-directory-change) |
| @@ -151,6 +151,25 @@ NAME must be equal to `tramp-current-connection'." | |||
| 151 | (recentf-exclude '(tramp-recentf-exclude-predicate))) | 151 | (recentf-exclude '(tramp-recentf-exclude-predicate))) |
| 152 | (recentf-cleanup)))) | 152 | (recentf-cleanup)))) |
| 153 | 153 | ||
| 154 | (defun tramp-recentf-cleanup-all () | ||
| 155 | "Remove all remote file names from recentf." | ||
| 156 | (when (bound-and-true-p recentf-list) | ||
| 157 | (let ((recentf-exclude '(file-remote-p))) | ||
| 158 | (recentf-cleanup)))) | ||
| 159 | |||
| 160 | (eval-after-load "recentf" | ||
| 161 | '(progn | ||
| 162 | (add-hook 'tramp-cleanup-connection-hook | ||
| 163 | 'tramp-recentf-cleanup) | ||
| 164 | (add-hook 'tramp-cleanup-all-connections-hook | ||
| 165 | 'tramp-recentf-cleanup-all) | ||
| 166 | (add-hook 'tramp-integration-unload-hook | ||
| 167 | (lambda () | ||
| 168 | (remove-hook 'tramp-cleanup-connection-hook | ||
| 169 | 'tramp-recentf-cleanup) | ||
| 170 | (remove-hook 'tramp-cleanup-all-connections-hook | ||
| 171 | 'tramp-recentf-cleanup-all))))) | ||
| 172 | |||
| 154 | (add-hook 'tramp-unload-hook | 173 | (add-hook 'tramp-unload-hook |
| 155 | (lambda () (unload-feature 'tramp-integration 'force))) | 174 | (lambda () (unload-feature 'tramp-integration 'force))) |
| 156 | 175 | ||