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.
This commit is contained in:
Stefan Monnier 2025-09-11 12:26:47 +02:00 committed by Michael Albinus
parent 2954234f8f
commit 569fa594e2

View file

@ -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))