From 569fa594e24e288f3d3ba4d9042bb85f8c4f348f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 11 Sep 2025 12:26:47 +0200 Subject: [PATCH] Rearrange tramp.el in order to avoid bootstrap problems * lisp/net/tramp.el (tramp-compat, tramp-message) (tramp-integration, trampver): Require them later. (top): Use `eval-and-compile' modifying `macro-declarations-alist'. (tramp-register-file-name-handlers): Don't fail during bootstrap before `tramp-loaddefs.el' is built. --- lisp/net/tramp.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9bf1b4ae6c3..ad768f9e038 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -63,11 +63,6 @@ ;;; Code: -(require 'tramp-compat) -(require 'tramp-message) -(require 'tramp-integration) -(require 'trampver) - ;; Pacify byte-compiler. (require 'cl-lib) (declare-function file-notify-rm-watch "filenotify") @@ -106,8 +101,9 @@ ;; TODO: Once (autoload-macro expand) is available in all supported ;; Emacs versions (Emacs 31.1+), this can be eliminated: ;; Backward compatibility for autoload-macro declare form. - (unless (assq 'autoload-macro macro-declarations-alist) - (push '(autoload-macro ignore) macro-declarations-alist)) + (eval-and-compile + (unless (assq 'autoload-macro macro-declarations-alist) + (push '(autoload-macro ignore) macro-declarations-alist))) (defmacro tramp--with-startup (&rest body) "Schedule BODY to be executed at the end of tramp.el." @@ -124,6 +120,11 @@ 'defun-declarations-alist (list 'tramp-suppress-trace #'tramp-byte-run--set-suppress-trace)))) +(require 'tramp-compat) +(require 'tramp-message) +(require 'tramp-integration) +(require 'trampver) + ;;; User Customizable Internal Variables: (defgroup tramp nil @@ -2760,7 +2761,9 @@ remote file names." (cons tramp-file-name-regexp #'tramp-file-name-handler)) (put #'tramp-file-name-handler 'safe-magic t) - (tramp-register-crypt-file-name-handler) + ;; Don't fail during bootstrap before `tramp-loaddefs.el' is built. + (when (fboundp 'tramp-register-crypt-file-name-handler) + (tramp-register-crypt-file-name-handler)) (add-to-list 'file-name-handler-alist (cons tramp-completion-file-name-regexp @@ -2771,7 +2774,9 @@ remote file names." (mapcar #'car tramp-completion-file-name-handler-alist)) ;; After unloading, `tramp-archive-enabled' might not be defined. - (when (bound-and-true-p tramp-archive-enabled) + (when (and (bound-and-true-p tramp-archive-enabled) + ;; Don't burp during boostrap when `tramp-loaddefs.el' isn't built. + (boundp 'tramp-archive-file-name-regexp)) (add-to-list 'file-name-handler-alist (cons tramp-archive-file-name-regexp #'tramp-archive-file-name-handler))