Subject: bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes

From: João Távora <[email-masked]>
Date: Fri, 24 Nov 2023 09:24:01 +0000

On Fri, Nov 24, 2023 at 8:06 AM Eli Zaretskii <[email-masked]> wrote:
>
> > Cc: Protesilaos Stavrou <[email-masked]>,
> >  Jonas Bernoulli <[email-masked]>,
> >  João Távora <[email-masked]>
> > Date: Mon, 20 Nov 2023 11:50:50 -0800
> > From:  Joseph Turner via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <[email-masked]>
> >
> > When using shorthands.el, autoload generation inserts a call to
> > register-definition-prefixes with the shorthand prefix, instead of the
> > translated print name prefix.  For example, breadcrumb-autoloads.el
> > contains the line:
> >
> > (register-definition-prefixes "breadcrumb" '("bc-"))
> >
> > instead of
> >
> > (register-definition-prefixes "breadcrumb" '("breadcrumb-"))
> >
> > This PR attempts to resolve this issue in breadcrumb.el by adding the
> > correct autoload line at the bottom of the file:
> >
> > https://github.com/joaotavora/breadcrumb/pull/24
> >
> > What needs to be done in core Emacs to fix autoload generation with
> > shorthands.el?
> >
> > Also see bug#63480.
>
> João, any comments?

Yes.  Well first, we are talking about an imperfect heuristic here
which lives in lisp/emacs-lisp/loaddefs-gen.el.  That's where
the definition prefixes for a given file are collected and the
common prefix is guessed, leading to the generation of the
register-definition-prefixes form.

The logic seems to have a number of exceptions and corner cases
baked into it already, and there seems to be even a specific
kill-switch for this particular register-definition-prefixes form:

;; Local Variables:
;; autoload-compute-prefixes: nil
;; End:

This form should probably be added to breadcrumb.el so that
the autoload mechanism would stop trying to guess the prefix
using its current flawed methods.  I've already asked the
submitters of the pull request to do so at the Breadcrumb
upstream.

BTW.  Grepping for autoload-compute-prefixes seems to indicate
it is totally undocumented. It's not even a defvar,
just an autoload-specific cookies.  This is fine, but I guess
it should still be documented somewhere.

OK so that solves the problem for breadcrumb.el and other
such shorthand-using packages such as beardbolt.el and others
I see popping up.

But maybe this issue can still be kept open.  It shouldn't be
terribly hard to add a fix to loaddefs-generate--compute-prefixes
or loaddefs-generate--make-prefixes that takes shorthands in
consideration.  In fact, the presence of a shorthand might
be a more reliable indicator of the package's intended "external"
prefix than any of the current heuristics.

> > Also see bug#63480.

What about it?  What's the relation to this bug?

João