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

From: Stefan Monnier <[email-masked]>
Date: Sun, 13 Jul 2025 18:49:30 -0400

>>     (defmacro define-minor-mode ...
>>       (declare (...
>>                 (autoload macroexpand)
>
> Wow, this is even nicer!  Never knew those `delare's were so simple. 

🙂

[ Of course, third-party code would have to use `put` in the short term
  for backward compatibility reasons.  🙁 ]

>>     (defmacro transient-define-prefix ...
>>       (declare (...
>>                 (autoload function)
>
> I mean `defalias' is supported because `defun' expands to it.  Isn't
> that enough?

Yes, I think we could mark `transient-define-prefix` as `expand`.
My understanding is that currently putting it in "list 1" wouldn't work
simply because it's not autoloaded.

> The code in `--make-autoload' seems to think it knows how to handle all
> those "function-like operators".  But list 1 and list 2 seem to be
> disjoint.  E.g. `transient-define-prefix' is on list 2, but _not_ on
> list 1.  So it would like to be treated as a function operator, but not
> expanded.

As mentioned above, I think it's just because of a lack of autoloading.

>    ;; Expand _and_ treat as a special function op (1 & 2):
>    (define-skeleton
>      define-derived-mode
>      define-compilation-mode
>      define-generic-mode
>      easy-mmode-define-global-mode
>      define-global-minor-mode
>      define-globalized-minor-mode
>      easy-mmode-define-minor-mode
>      define-minor-mode cl-defun
>      defun*
>      cl-defmacro
>      defmacro*
>      define-overloadable-function
>      transient-define-prefix
>      transient-define-suffix
>      transient-define-infix
>      transient-define-argument
>      defun defmacro define-inline
>      cl-defgeneric
>      cl-defstruct
>      pcase-defmacro
>      iter-defun
>      cl-iter-defun)

I don't see `cl-defstruct` in list 2 (same for several others), so
I think the above list isn't right.
But yes, some are in both lists and it's mostly "historical accidents".
IIRC `easy-mmode-define-minor-mode` started in list 2 and was later
added to list 1 so as to get a better result (e.g. more complete
docstring) in those cases where the macro happens to be defined.

But I think your trick of evaluating the file (to cause the macros
to be defined) should allow us to focus on list 1 and leave only the
strict minimum in list 2.

        Stefan