Subject: Re: bug#48694: 28.0.50; Suboptimal autoload cookie for `transient-define-prefix'

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 15 Jul 2022 13:08:45 +0200

Philipp Stephani <[email-masked]> writes:

> 2. Moreover, this is needlessly heavyweight in that it requires
>    `transient' to be loaded just for the autoload.  This should rather
>    be
>
>    (autoload 'f () "test" "test" t)
>
>    or so.  It's possible to add such an autoload cookie manually, but it
>    would be better if Emacs did the right thing automatically.
>
> I think this can be rectified by adding `transient-define-prefix' to the
> big list of special/complex cases in `make-autoload'.

I've now done this in Emacs 29.

> However, that in turn wouldn't be the best solution, because it
> prevents libraries not shipped with Emacs from the autoload
> optimization for defun-like macros like this.  It would be better to
> create a macro declaration specifier that would allow arbitrary
> defun-like macros to optimize their autoload behavior.

We could have the packages put a symbol on the macro to trigger this,
but then the question is -- how do we tell the Emacs that'd doing the
loaddefs generation about that?  That Emacs usually doesn't load
anything in particular, so it'd have to be told in some other way.

We could introduce some new syntax here, for instance

;;;###autoload-expand-macro

to signal that the macro should be expanded, but then we have the same
problem -- that Emacs has to load the file to get the definition of the
macro.  And in that case, we could just use the symbol property
anyway.

So I'm not sure anything can be done here practically, because
package.el doesn't do "emacs ... -l package -f loaddefs-gen", after all.

Anybody have any opinions here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no