[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master cedc341: Adapt hooks in Tramp
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master cedc341: Adapt hooks in Tramp |
Date: |
Mon, 25 Feb 2019 06:00:16 -0500 (EST) |
branch: master
commit cedc3410d4feab7b4beeef3eab474fbabad4035c
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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'.
---
lisp/net/tramp-archive.el | 18 ++++++++++--------
lisp/net/tramp-cmds.el | 27 +++++++++++++++------------
lisp/net/tramp-ftp.el | 3 +--
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 db9aec0..dcddb0e 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -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)))
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 38e440e..cf4f741 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),
(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.
This includes password cache, file cache, connection cache,
@@ -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 ()
@@ -132,6 +136,10 @@ When called interactively, a Tramp connection has to be
selected."
(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.
This includes password cache, file cache, connection cache, buffers."
@@ -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 ()
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el
index 4807fe0..8735d13 100644
--- a/lisp/net/tramp-ftp.el
+++ b/lisp/net/tramp-ftp.el
@@ -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 ()
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index f3f95f1..e2a0d6b 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'."
'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)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master cedc341: Adapt hooks in Tramp,
Michael Albinus <=