summaryrefslogtreecommitdiff
path: root/lisp/net/tramp-integration.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2019-12-07 13:40:04 +0100
committerMichael Albinus <michael.albinus@gmx.de>2019-12-07 13:40:04 +0100
commit959bbf30032c365c9e6f08dc9211d6bab3123f35 (patch)
tree37cd41db4f1db175fc9fef073b4818ffae056750 /lisp/net/tramp-integration.el
parent3403d7a031030498385ae044765805cd4189056b (diff)
downloademacs-959bbf30032c365c9e6f08dc9211d6bab3123f35.tar.gz
Add unload code to tramp-integration.el
* lisp/net/tramp-integration.el (info-lookup->mode-cache) (info-lookup->topic-cache, info-lookup-alist): Declare. (ido, ivy, info-look): Adapt `tramp-integration-unload-hook'.
Diffstat (limited to 'lisp/net/tramp-integration.el')
-rw-r--r--lisp/net/tramp-integration.el76
1 files changed, 58 insertions, 18 deletions
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index f1d9f390e1b..ad075634ac0 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -32,8 +32,10 @@
;; Pacify byte-compiler.
(require 'cl-lib)
(declare-function info-lookup->cache "info-look")
+(declare-function info-lookup->mode-cache "info-look")
(declare-function info-lookup->mode-value "info-look")
(declare-function info-lookup->other-modes "info-look")
+(declare-function info-lookup->topic-cache "info-look")
(declare-function info-lookup->topic-value "info-look")
(declare-function info-lookup-maybe-add-help "info-look")
(declare-function recentf-cleanup "recentf")
@@ -42,7 +44,7 @@
(declare-function tramp-tramp-file-p "tramp")
(defvar eshell-path-env)
(defvar ido-read-file-name-non-ido)
-(defvar info-lookup-cache)
+(defvar info-lookup-alist)
(defvar ivy-completing-read-handlers-alist)
(defvar recentf-exclude)
(defvar tramp-current-connection)
@@ -182,7 +184,13 @@ NAME must be equal to `tramp-current-connection'."
(with-eval-after-load 'ido
(add-to-list 'ido-read-file-name-non-ido 'tramp-rename-files)
- (add-to-list 'ido-read-file-name-non-ido 'tramp-these-rename-files))
+ (add-to-list 'ido-read-file-name-non-ido 'tramp-these-rename-files)
+ (add-hook 'tramp-integration-unload-hook
+ (lambda ()
+ (setq ido-read-file-name-non-ido
+ (delq 'tramp-these-rename-files ido-read-file-name-non-ido)
+ ido-read-file-name-non-ido
+ (delq 'tramp-rename-files ido-read-file-name-non-ido)))))
;;; Integration of ivy.el:
@@ -190,7 +198,18 @@ NAME must be equal to `tramp-current-connection'."
(add-to-list 'ivy-completing-read-handlers-alist
'(tramp-rename-files . completing-read-default))
(add-to-list 'ivy-completing-read-handlers-alist
- '(tramp-these-rename-files . completing-read-default)))
+ '(tramp-these-rename-files . completing-read-default))
+ (add-hook
+ 'tramp-integration-unload-hook
+ (lambda ()
+ (setq ivy-completing-read-handlers-alist
+ (delete
+ (assq 'tramp-these-rename-files ivy-completing-read-handlers-alist)
+ ivy-completing-read-handlers-alist)
+ ivy-completing-read-handlers-alist
+ (delete
+ (assq 'tramp-rename-files ivy-completing-read-handlers-alist)
+ ivy-completing-read-handlers-alist)))))
;;; Integration of info-look.el:
@@ -202,24 +221,45 @@ NAME must be equal to `tramp-current-connection'."
:doc-spec '(("(tramp)Function Index" nil "^ -+ .*: " "\\( \\|$\\)")
("(tramp)Variable Index" nil "^ -+ .*: " "\\( \\|$\\)")))
- ;; Add it as `other-modes' to `emacs-lisp-mode' itself, and all
- ;; modes which use it as `other-modes'.
+ (add-hook
+ 'tramp-integration-unload-hook
+ (lambda ()
+ (setcdr (assq 'symbol info-lookup-alist)
+ (delete (info-lookup->mode-value 'symbol 'tramp-info-lookup-mode)
+ (info-lookup->topic-value 'symbol)))
+ (setcdr (info-lookup->cache 'symbol)
+ (delete (info-lookup->mode-cache 'symbol 'tramp-info-lookup-mode)
+ (info-lookup->topic-cache 'symbol)))))
+
(dolist (mode (mapcar 'car (info-lookup->topic-value 'symbol)))
+ ;; Add `tramp-info-lookup-mode' to `other-modes' for either
+ ;; `emacs-lisp-mode' itself, or to modes which use
+ ;; `emacs-lisp-mode' as `other-modes'. Reset `info-lookup-cache'.
(when (and (or (equal mode 'emacs-lisp-mode)
- (member
+ (memq
'emacs-lisp-mode (info-lookup->other-modes 'symbol mode)))
- (not (member
- 'tramp-info-lookup-mode
- (info-lookup->other-modes 'symbol mode))))
- (setcdr
- (info-lookup->mode-value 'symbol mode)
- (append
- (butlast (cdr (info-lookup->mode-value 'symbol mode)))
- `(,(cons 'tramp-info-lookup-mode
- (info-lookup->other-modes 'symbol mode)))))))
-
- ;; Reset cache.
- (setq info-lookup-cache nil))
+ (not (memq 'tramp-info-lookup-mode
+ (info-lookup->other-modes 'symbol mode))))
+ (setcdr (info-lookup->mode-value 'symbol mode)
+ (append (butlast (cdr (info-lookup->mode-value 'symbol mode)))
+ `((tramp-info-lookup-mode
+ . ,(info-lookup->other-modes 'symbol mode)))))
+ (setcdr (info-lookup->cache 'symbol)
+ (delete (info-lookup->mode-cache 'symbol mode)
+ (info-lookup->topic-cache 'symbol)))
+
+ (add-hook
+ 'tramp-integration-unload-hook
+ `(lambda ()
+ (setcdr (info-lookup->mode-value 'symbol ',mode)
+ (append (butlast
+ (cdr (info-lookup->mode-value 'symbol ',mode)))
+ (list
+ (delq 'tramp-info-lookup-mode
+ (info-lookup->other-modes 'symbol ',mode)))))
+ (setcdr (info-lookup->cache 'symbol)
+ (delete (info-lookup->mode-cache 'symbol ',mode)
+ (info-lookup->topic-cache 'symbol))))))))
;;; Default connection-local variables for Tramp: