[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ea196eb: Fix load-path issue when it contains remot
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master ea196eb: Fix load-path issue when it contains remote directories |
Date: |
Fri, 16 Jun 2017 08:46:34 -0400 (EDT) |
branch: master
commit ea196ebb93188b0962f478f5dec0ff0645c4da10
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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.
---
lisp/net/tramp.el | 27 ++++++++++++++++++++++++++-
test/lisp/net/tramp-tests.el | 24 +++++++++++++++++++++++-
2 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e329f92..8d81ac6 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."
;; 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,
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 3c1e76e..a90e3ff 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."
(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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ea196eb: Fix load-path issue when it contains remote directories,
Michael Albinus <=