Subject: bug#78995: [PATCH] ;;;autoload-expand for special macros

From: Stefan Monnier <[email-masked]>
Date: Tue, 29 Jul 2025 17:18:33 -0400

>> Damn!  So now I'm the one who needs to figure out how to keep it working
>> in Emacs<31 while trying to make it behave with the new
>> "autoload-expand".
> Maybe it is as simple as requiring a (new?) file that defines the macro
> directly, and whenever you require tramp-loaddefs, using NOERROR=t?

I *think* it's simpler than that: just add the `declare` thingy and the
NOERROR=t.

        Stefan

diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 9787e3a6553..f003bbebf31 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -29,7 +29,7 @@
 
 ;;; Code:
 
-(require 'tramp-loaddefs)
+(require 'tramp-loaddefs nil t) ;; Don't error while building the autoloads.
 (require 'ansi-color)
 (require 'auth-source)
 (require 'format-spec)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 2208ce880d7..485c18fc4a2 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -105,6 +105,7 @@ tramp-completion-file-name-regexp
 
   (defmacro tramp--with-startup (&rest body)
     "Schedule BODY to be executed at the end of tramp.el."
+    (declare (autoload macro-expand))
     `(add-hook 'tramp--startup-hook (lambda () ,@body)))
 
   (eval-and-compile