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.
This commit is contained in:
parent
8c21f8fab9
commit
ea196ebb93
2 changed files with 49 additions and 2 deletions
|
@ -2075,7 +2075,7 @@ Falls back to normal file name handler if no Tramp file name handler exists."
|
|||
;; are already loaded. This results in
|
||||
;; recursive loading. Therefore, we load the
|
||||
;; Tramp packages locally.
|
||||
(when (and (listp sf) (eq (car sf) 'autoload))
|
||||
(when (autoloadp sf)
|
||||
(let ((default-directory
|
||||
(tramp-compat-temporary-file-directory)))
|
||||
(load (cadr sf) 'noerror 'nomessage)))
|
||||
|
@ -2210,6 +2210,31 @@ Falls back to normal file name handler if no Tramp file name handler exists."
|
|||
;;;###autoload
|
||||
(tramp-register-autoload-file-name-handlers)
|
||||
|
||||
(defun tramp-use-absolute-autoload-file-names ()
|
||||
"Change Tramp autoload objects to use absolute file names.
|
||||
This avoids problems during autoload, when `load-path' contains
|
||||
remote file names."
|
||||
;; We expect all other Tramp files in the same directory as tramp.el.
|
||||
(let* ((dir (expand-file-name (file-name-directory (locate-library "tramp"))))
|
||||
(files-regexp
|
||||
(format
|
||||
"^%s$"
|
||||
(regexp-opt
|
||||
(mapcar
|
||||
'file-name-sans-extension
|
||||
(directory-files dir nil "^tramp.+\\.elc?$"))
|
||||
'paren))))
|
||||
(mapatoms
|
||||
(lambda (atom)
|
||||
(when (and (functionp atom)
|
||||
(autoloadp (symbol-function atom))
|
||||
(string-match files-regexp (cadr (symbol-function atom))))
|
||||
(ignore-errors
|
||||
(setf (cadr (symbol-function atom))
|
||||
(expand-file-name (cadr (symbol-function atom)) dir))))))))
|
||||
|
||||
(eval-after-load 'tramp (tramp-use-absolute-autoload-file-names))
|
||||
|
||||
(defun tramp-register-file-name-handlers ()
|
||||
"Add Tramp file name handlers to `file-name-handler-alist'."
|
||||
;; Remove autoloaded handlers from file name handler alist. Useful,
|
||||
|
|
|
@ -3762,7 +3762,29 @@ process sentinels. They shall not disturb each other."
|
|||
(mapconcat 'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument code)))))))
|
||||
|
||||
(ert-deftest tramp-test38-unload ()
|
||||
(ert-deftest tramp-test38-remote-load-path ()
|
||||
"Check that Tramp autoloads its packages with remote `load-path'."
|
||||
;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el.
|
||||
;; It shall still work, when a remote file name is in the
|
||||
;; `load-path'.
|
||||
(let ((code
|
||||
"(let ((force-load-messages t)\
|
||||
(load-path (cons \"/foo:bar:\" load-path)))\
|
||||
(tramp-cleanup-all-connections))"))
|
||||
(should
|
||||
(string-match
|
||||
(format
|
||||
"Loading %s"
|
||||
(expand-file-name
|
||||
"tramp-cmds" (file-name-directory (locate-library "tramp"))))
|
||||
(shell-command-to-string
|
||||
(format
|
||||
"%s -batch -Q -L %s -l tramp-sh --eval %s"
|
||||
(expand-file-name invocation-name invocation-directory)
|
||||
(mapconcat 'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument code)))))))
|
||||
|
||||
(ert-deftest tramp-test39-unload ()
|
||||
"Check that Tramp and its subpackages unload completely.
|
||||
Since it unloads Tramp, it shall be the last test to run."
|
||||
;; Mark as failed until all symbols are unbound.
|
||||
|
|
Loading…
Add table
Reference in a new issue