diff options
| author | Michael Albinus | 2019-12-07 13:40:04 +0100 |
|---|---|---|
| committer | Michael Albinus | 2019-12-07 13:40:04 +0100 |
| commit | 959bbf30032c365c9e6f08dc9211d6bab3123f35 (patch) | |
| tree | 37cd41db4f1db175fc9fef073b4818ffae056750 | |
| parent | 3403d7a031030498385ae044765805cd4189056b (diff) | |
| download | emacs-959bbf30032c365c9e6f08dc9211d6bab3123f35.tar.gz emacs-959bbf30032c365c9e6f08dc9211d6bab3123f35.zip | |
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'.
| -rw-r--r-- | lisp/net/tramp-integration.el | 76 |
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 @@ | |||
| 32 | ;; Pacify byte-compiler. | 32 | ;; Pacify byte-compiler. |
| 33 | (require 'cl-lib) | 33 | (require 'cl-lib) |
| 34 | (declare-function info-lookup->cache "info-look") | 34 | (declare-function info-lookup->cache "info-look") |
| 35 | (declare-function info-lookup->mode-cache "info-look") | ||
| 35 | (declare-function info-lookup->mode-value "info-look") | 36 | (declare-function info-lookup->mode-value "info-look") |
| 36 | (declare-function info-lookup->other-modes "info-look") | 37 | (declare-function info-lookup->other-modes "info-look") |
| 38 | (declare-function info-lookup->topic-cache "info-look") | ||
| 37 | (declare-function info-lookup->topic-value "info-look") | 39 | (declare-function info-lookup->topic-value "info-look") |
| 38 | (declare-function info-lookup-maybe-add-help "info-look") | 40 | (declare-function info-lookup-maybe-add-help "info-look") |
| 39 | (declare-function recentf-cleanup "recentf") | 41 | (declare-function recentf-cleanup "recentf") |
| @@ -42,7 +44,7 @@ | |||
| 42 | (declare-function tramp-tramp-file-p "tramp") | 44 | (declare-function tramp-tramp-file-p "tramp") |
| 43 | (defvar eshell-path-env) | 45 | (defvar eshell-path-env) |
| 44 | (defvar ido-read-file-name-non-ido) | 46 | (defvar ido-read-file-name-non-ido) |
| 45 | (defvar info-lookup-cache) | 47 | (defvar info-lookup-alist) |
| 46 | (defvar ivy-completing-read-handlers-alist) | 48 | (defvar ivy-completing-read-handlers-alist) |
| 47 | (defvar recentf-exclude) | 49 | (defvar recentf-exclude) |
| 48 | (defvar tramp-current-connection) | 50 | (defvar tramp-current-connection) |
| @@ -182,7 +184,13 @@ NAME must be equal to `tramp-current-connection'." | |||
| 182 | 184 | ||
| 183 | (with-eval-after-load 'ido | 185 | (with-eval-after-load 'ido |
| 184 | (add-to-list 'ido-read-file-name-non-ido 'tramp-rename-files) | 186 | (add-to-list 'ido-read-file-name-non-ido 'tramp-rename-files) |
| 185 | (add-to-list 'ido-read-file-name-non-ido 'tramp-these-rename-files)) | 187 | (add-to-list 'ido-read-file-name-non-ido 'tramp-these-rename-files) |
| 188 | (add-hook 'tramp-integration-unload-hook | ||
| 189 | (lambda () | ||
| 190 | (setq ido-read-file-name-non-ido | ||
| 191 | (delq 'tramp-these-rename-files ido-read-file-name-non-ido) | ||
| 192 | ido-read-file-name-non-ido | ||
| 193 | (delq 'tramp-rename-files ido-read-file-name-non-ido))))) | ||
| 186 | 194 | ||
| 187 | ;;; Integration of ivy.el: | 195 | ;;; Integration of ivy.el: |
| 188 | 196 | ||
| @@ -190,7 +198,18 @@ NAME must be equal to `tramp-current-connection'." | |||
| 190 | (add-to-list 'ivy-completing-read-handlers-alist | 198 | (add-to-list 'ivy-completing-read-handlers-alist |
| 191 | '(tramp-rename-files . completing-read-default)) | 199 | '(tramp-rename-files . completing-read-default)) |
| 192 | (add-to-list 'ivy-completing-read-handlers-alist | 200 | (add-to-list 'ivy-completing-read-handlers-alist |
| 193 | '(tramp-these-rename-files . completing-read-default))) | 201 | '(tramp-these-rename-files . completing-read-default)) |
| 202 | (add-hook | ||
| 203 | 'tramp-integration-unload-hook | ||
| 204 | (lambda () | ||
| 205 | (setq ivy-completing-read-handlers-alist | ||
| 206 | (delete | ||
| 207 | (assq 'tramp-these-rename-files ivy-completing-read-handlers-alist) | ||
| 208 | ivy-completing-read-handlers-alist) | ||
| 209 | ivy-completing-read-handlers-alist | ||
| 210 | (delete | ||
| 211 | (assq 'tramp-rename-files ivy-completing-read-handlers-alist) | ||
| 212 | ivy-completing-read-handlers-alist))))) | ||
| 194 | 213 | ||
| 195 | ;;; Integration of info-look.el: | 214 | ;;; Integration of info-look.el: |
| 196 | 215 | ||
| @@ -202,24 +221,45 @@ NAME must be equal to `tramp-current-connection'." | |||
| 202 | :doc-spec '(("(tramp)Function Index" nil "^ -+ .*: " "\\( \\|$\\)") | 221 | :doc-spec '(("(tramp)Function Index" nil "^ -+ .*: " "\\( \\|$\\)") |
| 203 | ("(tramp)Variable Index" nil "^ -+ .*: " "\\( \\|$\\)"))) | 222 | ("(tramp)Variable Index" nil "^ -+ .*: " "\\( \\|$\\)"))) |
| 204 | 223 | ||
| 205 | ;; Add it as `other-modes' to `emacs-lisp-mode' itself, and all | 224 | (add-hook |
| 206 | ;; modes which use it as `other-modes'. | 225 | 'tramp-integration-unload-hook |
| 226 | (lambda () | ||
| 227 | (setcdr (assq 'symbol info-lookup-alist) | ||
| 228 | (delete (info-lookup->mode-value 'symbol 'tramp-info-lookup-mode) | ||
| 229 | (info-lookup->topic-value 'symbol))) | ||
| 230 | (setcdr (info-lookup->cache 'symbol) | ||
| 231 | (delete (info-lookup->mode-cache 'symbol 'tramp-info-lookup-mode) | ||
| 232 | (info-lookup->topic-cache 'symbol))))) | ||
| 233 | |||
| 207 | (dolist (mode (mapcar 'car (info-lookup->topic-value 'symbol))) | 234 | (dolist (mode (mapcar 'car (info-lookup->topic-value 'symbol))) |
| 235 | ;; Add `tramp-info-lookup-mode' to `other-modes' for either | ||
| 236 | ;; `emacs-lisp-mode' itself, or to modes which use | ||
| 237 | ;; `emacs-lisp-mode' as `other-modes'. Reset `info-lookup-cache'. | ||
| 208 | (when (and (or (equal mode 'emacs-lisp-mode) | 238 | (when (and (or (equal mode 'emacs-lisp-mode) |
| 209 | (member | 239 | (memq |
| 210 | 'emacs-lisp-mode (info-lookup->other-modes 'symbol mode))) | 240 | 'emacs-lisp-mode (info-lookup->other-modes 'symbol mode))) |
| 211 | (not (member | 241 | (not (memq 'tramp-info-lookup-mode |
| 212 | 'tramp-info-lookup-mode | 242 | (info-lookup->other-modes 'symbol mode)))) |
| 213 | (info-lookup->other-modes 'symbol mode)))) | 243 | (setcdr (info-lookup->mode-value 'symbol mode) |
| 214 | (setcdr | 244 | (append (butlast (cdr (info-lookup->mode-value 'symbol mode))) |
| 215 | (info-lookup->mode-value 'symbol mode) | 245 | `((tramp-info-lookup-mode |
| 216 | (append | 246 | . ,(info-lookup->other-modes 'symbol mode))))) |
| 217 | (butlast (cdr (info-lookup->mode-value 'symbol mode))) | 247 | (setcdr (info-lookup->cache 'symbol) |
| 218 | `(,(cons 'tramp-info-lookup-mode | 248 | (delete (info-lookup->mode-cache 'symbol mode) |
| 219 | (info-lookup->other-modes 'symbol mode))))))) | 249 | (info-lookup->topic-cache 'symbol))) |
| 220 | 250 | ||
| 221 | ;; Reset cache. | 251 | (add-hook |
| 222 | (setq info-lookup-cache nil)) | 252 | 'tramp-integration-unload-hook |
| 253 | `(lambda () | ||
| 254 | (setcdr (info-lookup->mode-value 'symbol ',mode) | ||
| 255 | (append (butlast | ||
| 256 | (cdr (info-lookup->mode-value 'symbol ',mode))) | ||
| 257 | (list | ||
| 258 | (delq 'tramp-info-lookup-mode | ||
| 259 | (info-lookup->other-modes 'symbol ',mode))))) | ||
| 260 | (setcdr (info-lookup->cache 'symbol) | ||
| 261 | (delete (info-lookup->mode-cache 'symbol ',mode) | ||
| 262 | (info-lookup->topic-cache 'symbol)))))))) | ||
| 223 | 263 | ||
| 224 | ;;; Default connection-local variables for Tramp: | 264 | ;;; Default connection-local variables for Tramp: |
| 225 | 265 | ||