From: Michael Albinus Date: Fri, 28 Apr 2006 04:06:16 +0000 (+0000) Subject: * net/tramp.el (tramp-completion-file-name-handler): Disable X-Git-Tag: emacs-pretest-22.0.90~2923 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ecc6145d808a276cb1ce4bfc9052dc1e9515388;p=emacs.git * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0b384c6d8c3..ac0bbfb9700 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2006-04-28 Michael Albinus + + * 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 * calc-embed.el (calc-embedded-make-info): Use `math-read-expr' to diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 5f3ab41e5cb..ad4eaaa4862 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4324,24 +4324,34 @@ Fall back to normal file name handler if no Tramp handler exists." (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 @@ Falls back to normal file name handler if no tramp file name handler exists." (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 @@ Falls back to normal file name handler if no tramp file name handler exists." (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: