changeset 70255:d57fb8c98714

* net/tramp.el (tramp-completion-file-name-handler): Disable Tramp's functionality while loading Tramp itself. (tramp-register-file-name-handlers): That's a defsubst now. Code from `tramp-repair-jka-compr' moved here. Apply it via `after-init-hook'. (tramp-repair-jka-compr): Removed.
author Michael Albinus <michael.albinus@gmx.de>
date Fri, 28 Apr 2006 04:06:16 +0000
parents 3732dd943c16
children 12b22e9828df
files lisp/ChangeLog lisp/net/tramp.el
diffstat 2 files changed, 39 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Apr 27 18:40:41 2006 +0000
+++ b/lisp/ChangeLog	Fri Apr 28 04:06:16 2006 +0000
@@ -1,3 +1,12 @@
+2006-04-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-completion-file-name-handler): Disable
+	Tramp's functionality while loading Tramp itself.
+	(tramp-register-file-name-handlers): That's a defsubst now.  Code
+	from `tramp-repair-jka-compr' moved here.  Apply it via
+	`after-init-hook'.
+	(tramp-repair-jka-compr): Removed.
+
 2006-04-27  Jay Belanger  <belanger@truman.edu>
 
 	* calc-embed.el (calc-embedded-make-info): Use `math-read-expr' to
--- a/lisp/net/tramp.el	Thu Apr 27 18:40:41 2006 +0000
+++ b/lisp/net/tramp.el	Fri Apr 28 04:06:16 2006 +0000
@@ -4324,24 +4324,34 @@
 		  (tramp-run-real-handler operation args))))))
       (setq tramp-locked tl))))
 
+;; Preload this DEFUN with the progn trick.  This avoids cyclic
+;; loading, because the `load-in-progress' check can be performed.
 ;;;###autoload
-(defun tramp-completion-file-name-handler (operation &rest args)
+(progn (defun tramp-completion-file-name-handler (operation &rest args)
   "Invoke tramp file name completion handler.
 Falls back to normal file name handler if no tramp file name handler exists."
 ;;   (setq tramp-debug-buffer t)
 ;;   (tramp-message 1 "%s %s" operation args)
 ;;   (tramp-message 1 "%s %s\n%s"
 ;; 		 operation args (with-output-to-string (backtrace)))
-  (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
-    (if fn
-	(save-match-data (apply (cdr fn) args))
-      (tramp-completion-run-real-handler operation args))))
+  (if load-in-progress
+      ;; We are while loading Tramp.
+      (let (file-name-handler-alist)
+	(apply operation args))
+    ;; If Tramp is not loaded yet, do it now.
+    (require 'tramp)
+    (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
+      (if fn
+	  (save-match-data (apply (cdr fn) args))
+	(tramp-completion-run-real-handler operation args))))))
 
 ;; Register in `file-name-handler-alist'.
 ;; `tramp-completion-file-name-handler' must not be active when temacs
-;; dumps.  And it makes no sense in batch mode anyway.
+;; dumps.  And it makes no sense in batch mode anyway.  This must be
+;; an autoloaded DEFSUBST, because Tramp would be loaded otherwise
+;; applying the `after-init-hook'.
 ;;;###autoload
-(defun tramp-register-file-name-handlers ()
+(defsubst tramp-register-file-name-handlers ()
   "Add tramp file name handlers to `file-name-handler-alist'."
   (unless noninteractive
     (add-to-list 'file-name-handler-alist
@@ -4349,18 +4359,20 @@
     (add-to-list 'file-name-handler-alist
 		 (cons tramp-completion-file-name-regexp
 		       'tramp-completion-file-name-handler))
-    (put 'tramp-completion-file-name-handler 'safe-magic t)))
-
-;; LAMBDA function used temporarily, because older/other versions of
-;; Tramp don't know of `tramp-register-file-name-handlers'.  Can be
-;; replaced once that DEFUN is established.  Relevant for Emacs 22 only.
-;;;###;autoload(add-hook 'emacs-startup-hook 'tramp-register-file-name-handlers)
+    (put 'tramp-completion-file-name-handler 'safe-magic t)
+    ;; If jka-compr is already loaded, move it to the front of
+    ;; `file-name-handler-alist'.
+    (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist)))
+      (when jka
+	(setq file-name-handler-alist
+	      (cons jka (delete jka file-name-handler-alist)))))))
+
+;; `tramp-register-file-name-handlers' cannot be autoloaded as-it-is,
+;; because the `noninteractive' check would prevent functionality to
+;; be dumped in temacs.
 ;;;###autoload(add-hook
-;;;###autoload 'emacs-startup-hook
-;;;###autoload '(lambda ()
-;;;###autoload    (condition-case nil
-;;;###autoload        (funcall 'tramp-register-file-name-handlers)
-;;;###autoload      (error nil))))
+;;;###autoload 'after-init-hook
+;;;###autoload '(lambda () (tramp-register-file-name-handlers)))
 (tramp-register-file-name-handlers)
 
 ;;;###autoload
@@ -4374,16 +4386,6 @@
 
 (add-hook 'tramp-unload-hook 'tramp-unload-file-name-handlers)
 
-(defun tramp-repair-jka-compr ()
-  "If jka-compr is already loaded, move it to the front of
-`file-name-handler-alist'.  On Emacs 22 or so this will not be
-necessary anymore."
-  (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist)))
-    (when jka
-      (setq file-name-handler-alist
-	    (cons jka (delete jka file-name-handler-alist))))))
-(tramp-repair-jka-compr)
-
 
 ;;; Interactions with other packages: