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

From: Michael Albinus <[email-masked]>
Date: Fri, 01 Aug 2025 16:39:37 +0200

"J.D. Smith" <[email-masked]> writes:

Hi,

>>>> Tramp uses an own declare form `tramp-suppress-trace'. In order to make
>>>> it happen, there's the code
>>>
>>> We are already adding the new declare form to
>>> `macro-declarations-alist', but the problem is, this code will not
>>> exist in Emacs <31.
>>
>> I meant to do this in tramp.el or tramp-compat.el
>
> Aha.  One idea would be for tramp-compat to including something like:
>
>     ;; Remove when Emacs >=31 is required
>     (require 'loaddefs-gen)
>     (cl-symbol-macrolet
>         ((amac (alist-get 'autoload-macro macro-declarations-alist)))
>       (unless amac (setq amac #'ignore)))   
>
> to silence the warning, yet remain harmless once Emacs 31 is in the
> wild.

That doesn't work with Emacs 28:

--8<---------------cut here---------------start------------->8---
# make -C lisp EMACS=/home/albinus/src/emacs-28/src/emacs
make: Entering directory '/home/albinus/src/tramp/lisp'
/home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lisp -l autoload						    \
  --eval "(setq generate-autoload-cookie \";;;###tramp-autoload\")" \
  --eval "(setq generated-autoload-file				    \
	    (expand-file-name \"tramp-loaddefs.el\"))"		    \
  --eval "(setq make-backup-files nil)"				    \
  -f batch-update-autoloads .
  SCRAPE   .
  INFO     Scraping files for tramp-loaddefs.el... 
  INFO     Scraping files for tramp-loaddefs.el...done
/home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lisp -l bytecomp -f batch-byte-compile tramp-loaddefs.el
/home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lisp -l bytecomp -f batch-byte-compile trampver.el
/home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lisp -l bytecomp -f batch-byte-compile tramp-compat.el

In toplevel form:
tramp-compat.el:33:1: Error: Cannot open load file: No such file or directory, loaddefs-gen
make: *** [Makefile:77: tramp-compat.elc] Error 1
make: Leaving directory '/home/albinus/src/tramp/lisp'
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.