aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-06-16 14:46:25 +0200
committerMichael Albinus2017-06-16 14:46:25 +0200
commitea196ebb93188b0962f478f5dec0ff0645c4da10 (patch)
treeb246e18195e13df653d77f6c2defb2dcce3ac7d5
parent8c21f8fab915a5dabd7c3d10aae07ff36a3830e4 (diff)
downloademacs-ea196ebb93188b0962f478f5dec0ff0645c4da10.tar.gz
emacs-ea196ebb93188b0962f478f5dec0ff0645c4da10.zip
Fix load-path issue when it contains remote directories
* lisp/net/tramp.el (tramp-file-name-handler): Use `autoloadp'. (tramp-use-absolute-autoload-file-names): New defun. Call it after loading tramp.el. * test/lisp/net/tramp-tests.el (tramp-test38-remote-load-path): New test. (tramp-test39-unload): Rename.
-rw-r--r--lisp/net/tramp.el27
-rw-r--r--test/lisp/net/tramp-tests.el24
2 files changed, 49 insertions, 2 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e329f921e03..8d81ac64aa2 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2075,7 +2075,7 @@ Falls back to normal file name handler if no Tramp file name handler exists."
2075 ;; are already loaded. This results in 2075 ;; are already loaded. This results in
2076 ;; recursive loading. Therefore, we load the 2076 ;; recursive loading. Therefore, we load the
2077 ;; Tramp packages locally. 2077 ;; Tramp packages locally.
2078 (when (and (listp sf) (eq (car sf) 'autoload)) 2078 (when (autoloadp sf)
2079 (let ((default-directory 2079 (let ((default-directory
2080 (tramp-compat-temporary-file-directory))) 2080 (tramp-compat-temporary-file-directory)))
2081 (load (cadr sf) 'noerror 'nomessage))) 2081 (load (cadr sf) 'noerror 'nomessage)))
@@ -2210,6 +2210,31 @@ Falls back to normal file name handler if no Tramp file name handler exists."
2210;;;###autoload 2210;;;###autoload
2211(tramp-register-autoload-file-name-handlers) 2211(tramp-register-autoload-file-name-handlers)
2212 2212
2213(defun tramp-use-absolute-autoload-file-names ()
2214 "Change Tramp autoload objects to use absolute file names.
2215This avoids problems during autoload, when `load-path' contains
2216remote file names."
2217 ;; We expect all other Tramp files in the same directory as tramp.el.
2218 (let* ((dir (expand-file-name (file-name-directory (locate-library "tramp"))))
2219 (files-regexp
2220 (format
2221 "^%s$"
2222 (regexp-opt
2223 (mapcar
2224 'file-name-sans-extension
2225 (directory-files dir nil "^tramp.+\\.elc?$"))
2226 'paren))))
2227 (mapatoms
2228 (lambda (atom)
2229 (when (and (functionp atom)
2230 (autoloadp (symbol-function atom))
2231 (string-match files-regexp (cadr (symbol-function atom))))
2232 (ignore-errors
2233 (setf (cadr (symbol-function atom))
2234 (expand-file-name (cadr (symbol-function atom)) dir))))))))
2235
2236(eval-after-load 'tramp (tramp-use-absolute-autoload-file-names))
2237
2213(defun tramp-register-file-name-handlers () 2238(defun tramp-register-file-name-handlers ()
2214 "Add Tramp file name handlers to `file-name-handler-alist'." 2239 "Add Tramp file name handlers to `file-name-handler-alist'."
2215 ;; Remove autoloaded handlers from file name handler alist. Useful, 2240 ;; Remove autoloaded handlers from file name handler alist. Useful,
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 3c1e76e8772..a90e3fff355 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3762,7 +3762,29 @@ process sentinels. They shall not disturb each other."
3762 (mapconcat 'shell-quote-argument load-path " -L ") 3762 (mapconcat 'shell-quote-argument load-path " -L ")
3763 (shell-quote-argument code))))))) 3763 (shell-quote-argument code)))))))
3764 3764
3765(ert-deftest tramp-test38-unload () 3765(ert-deftest tramp-test38-remote-load-path ()
3766 "Check that Tramp autoloads its packages with remote `load-path'."
3767 ;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el.
3768 ;; It shall still work, when a remote file name is in the
3769 ;; `load-path'.
3770 (let ((code
3771 "(let ((force-load-messages t)\
3772 (load-path (cons \"/foo:bar:\" load-path)))\
3773 (tramp-cleanup-all-connections))"))
3774 (should
3775 (string-match
3776 (format
3777 "Loading %s"
3778 (expand-file-name
3779 "tramp-cmds" (file-name-directory (locate-library "tramp"))))
3780 (shell-command-to-string
3781 (format
3782 "%s -batch -Q -L %s -l tramp-sh --eval %s"
3783 (expand-file-name invocation-name invocation-directory)
3784 (mapconcat 'shell-quote-argument load-path " -L ")
3785 (shell-quote-argument code)))))))
3786
3787(ert-deftest tramp-test39-unload ()
3766 "Check that Tramp and its subpackages unload completely. 3788 "Check that Tramp and its subpackages unload completely.
3767Since it unloads Tramp, it shall be the last test to run." 3789Since it unloads Tramp, it shall be the last test to run."
3768 ;; Mark as failed until all symbols are unbound. 3790 ;; Mark as failed until all symbols are unbound.