From cac8884d892a8708d74c55e53328ee45f88d82f0 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 18 May 2019 16:04:02 +0200 Subject: [PATCH] Require less packages in Tramp * lisp/net/tramp-compat.el (format-spec): Do not require advice, cl-lib, custom, password-cache, timer and ucs-normalize. * lisp/net/tramp-gvfs.el: Do not require zeroconf. Declare zeroconf-* functions. (tramp-gvfs-enabled): Autoload `zeroconf-init'. * lisp/net/tramp-sh.el: Do not require dired. * lisp/net/tramp.el (tramp-get-debug-buffer): Do not require outline. (tramp-file-name-for-operation): Extend docstring. (tramp-parse-netrc): Do not require netrc. Autoload `netrc-parse'. --- lisp/net/tramp-compat.el | 6 ------ lisp/net/tramp-gvfs.el | 9 +++++++-- lisp/net/tramp-integration.el | 2 +- lisp/net/tramp-sh.el | 4 ---- lisp/net/tramp.el | 14 +++++++++----- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index b515f253c92..21a819f79fd 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -35,15 +35,9 @@ (defun tramp-unload-file-name-handlers ()) (require 'auth-source) -(require 'advice) -(require 'cl-lib) -(require 'custom) (require 'format-spec) (require 'parse-time) -(require 'password-cache) (require 'shell) -(require 'timer) -(require 'ucs-normalize) (declare-function tramp-handle-temporary-file-directory "tramp") diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 52eaf686eaa..03870537c9a 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -99,16 +99,21 @@ (eval-when-compile (require 'cl-lib)) (require 'tramp) - (require 'dbus) (require 'url-parse) (require 'url-util) -(require 'zeroconf) ;; Pacify byte-compiler. (eval-when-compile (require 'custom)) +(declare-function zeroconf-init "zeroconf") +(declare-function zeroconf-list-service-types "zeroconf") +(declare-function zeroconf-list-services "zeroconf") +(declare-function zeroconf-service-host "zeroconf") +(declare-function zeroconf-service-port "zeroconf") +(declare-function zeroconf-service-txt "zeroconf") + ;; We don't call `dbus-ping', because this would load dbus.el. (defconst tramp-gvfs-enabled (ignore-errors diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index da168adce77..35d2eb38e60 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el @@ -31,10 +31,10 @@ ;; Pacify byte-compiler. (require 'cl-lib) +(declare-function recentf-cleanup "recentf") (declare-function tramp-dissect-file-name "tramp") (declare-function tramp-file-name-equal-p "tramp") (declare-function tramp-tramp-file-p "tramp") -(declare-function recentf-cleanup "recentf") (defvar eshell-path-env) (defvar recentf-exclude) (defvar tramp-current-connection) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 95fa61af983..2d27baf454a 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -30,10 +30,6 @@ (eval-when-compile (require 'cl-lib)) (require 'tramp) -;; Pacify byte-compiler. -(eval-when-compile - (require 'dired)) - (declare-function dired-remove-file "dired-aux") (defvar dired-compress-file-suffixes) (defvar vc-handled-backends) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 88389346c33..48152444a61 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1641,8 +1641,6 @@ The outline level is equal to the verbosity of the Tramp message." (get-buffer-create (tramp-debug-buffer-name vec)) (when (bobp) (setq buffer-undo-list t) - ;; So it does not get loaded while `outline-regexp' is let-bound. - (require 'outline) ;; Activate `outline-mode'. This runs `text-mode-hook' and ;; `outline-mode-hook'. We must prevent that local processes ;; die. Yes: I've seen `flyspell-mode', which starts "ispell". @@ -2142,7 +2140,11 @@ pass to the OPERATION." ;; function as well but regexp only. (defun tramp-file-name-for-operation (operation &rest args) "Return file name related to OPERATION file primitive. -ARGS are the arguments OPERATION has been called with." +ARGS are the arguments OPERATION has been called with. + +It does not always return a Tramp file name, for example if the +first argument of `expand-file-name' is absolute and not remote. +Must be handled by the callers." (cond ;; FILE resp DIRECTORY. ((member operation @@ -2954,7 +2956,9 @@ Host is always \"localhost\"." (defun tramp-parse-netrc (filename) "Return a list of (user host) tuples allowed to access. User may be nil." - (require 'netrc) + ;; The declaration is not sufficient at runtime, because netrc.el is + ;; not autoloaded. + (autoload 'netrc-parse "netrc") (mapcar (lambda (item) (and (assoc "machine" item) @@ -3387,6 +3391,7 @@ User is always nil." (access-file filename "Reading directory")) (with-parsed-tramp-file-name (expand-file-name filename) nil (with-tramp-progress-reporter v 0 (format "Opening directory %s" filename) + ;; We must load it in order to get the advice around `insert-directory'. (require 'ls-lisp) (let (ls-lisp-use-insert-directory-program start) (tramp-run-real-handler @@ -4879,7 +4884,6 @@ Only works for Bourne-like shells." ;; - Unload all `tramp-*' packages ;; - Reset `file-name-handler-alist' ;; - Cleanup hooks where Tramp functions are in -;; - Cleanup advised functions ;; - Cleanup autoloads ;;;###autoload (defun tramp-unload-tramp () -- 2.39.2