GNU bug report logs - #67325
shorthands: Incorrect autoloaded register-definition-prefixes

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> ushin.org>

Date: Tue, 21 Nov 2023 14:17:02 UTC

Severity: normal

To reply to this bug, email your comments to 67325 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Tue, 21 Nov 2023 14:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Turner <joseph <at> ushin.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 21 Nov 2023 14:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: Emacs Bugs Mailing List <bug-gnu-emacs <at> gnu.org>
Cc: Protesilaos Stavrou <public <at> protesilaos.com>,
 Jonas Bernoulli <jonas <at> bernoul.li>,
 João Távora <joaotavora <at> gmail.com>
Subject: shorthands: Incorrect autoloaded register-definition-prefixes
Date: Mon, 20 Nov 2023 11:50:50 -0800
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.

Thanks!

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Fri, 24 Nov 2023 08:08:01 GMT) Full text and rfc822 format available.

Message #8 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> ushin.org>, joaotavora <at> gmail.com
Cc: 67325 <at> debbugs.gnu.org, jonas <at> bernoul.li, public <at> protesilaos.com
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Fri, 24 Nov 2023 10:06:41 +0200
> Cc: Protesilaos Stavrou <public <at> protesilaos.com>,
>  Jonas Bernoulli <jonas <at> bernoul.li>,
>  João Távora <joaotavora <at> gmail.com>
> 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" <bug-gnu-emacs <at> gnu.org>
> 
> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Fri, 24 Nov 2023 09:25:02 GMT) Full text and rfc822 format available.

Message #11 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Joseph Turner <joseph <at> ushin.org>, 67325 <at> debbugs.gnu.org, jonas <at> bernoul.li,
 public <at> protesilaos.com
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Fri, 24 Nov 2023 09:24:01 +0000
On Fri, Nov 24, 2023 at 8:06 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > Cc: Protesilaos Stavrou <public <at> protesilaos.com>,
> >  Jonas Bernoulli <jonas <at> bernoul.li>,
> >  João Távora <joaotavora <at> gmail.com>
> > 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" <bug-gnu-emacs <at> gnu.org>
> >
> > 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sat, 25 Nov 2023 04:23:02 GMT) Full text and rfc822 format available.

Message #14 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: João Távora <joaotavora <at> gmail.com>
Cc: 67325 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, public <at> protesilaos.com,
 jonas <at> bernoul.li
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Fri, 24 Nov 2023 20:18:28 -0800
João Távora <joaotavora <at> gmail.com> writes:
>> From:  Joseph Turner
>> > Also see bug#63480.
>
> What about it?  What's the relation to this bug?

bug#63480 is also related to incorrect autoload generation with
shorthands.  I don't know if these two bugs will have related solutions.

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sat, 25 Nov 2023 12:45:02 GMT) Full text and rfc822 format available.

Message #17 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Joseph Turner <joseph <at> ushin.org>
Cc: 67325 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, public <at> protesilaos.com,
 Jonas Bernoulli <jonas <at> bernoul.li>
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Sat, 25 Nov 2023 12:44:00 +0000
[Message part 1 (text/plain, inline)]
On Sat, Nov 25, 2023, 04:21 Joseph Turner <joseph <at> ushin.org> wrote:

> João Távora <joaotavora <at> gmail.com> writes:
> >> From:  Joseph Turner
> >> > Also see bug#63480.
> >
> > What about it?  What's the relation to this bug?
>
> bug#63480 is also related to incorrect autoload generation with
> shorthands.


Hmmm. The two bugs are not related anymore than two Emacs bugs are related.
That bug has a (very decent IMO) workaround. If you want something to be
done there additionally, request it there

> I don't know if these two bugs will have related solutions.

I don't think so.

João
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sun, 26 Nov 2023 14:15:02 GMT) Full text and rfc822 format available.

Message #20 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Joseph Turner <joseph <at> ushin.org>
Cc: 67325 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, public <at> protesilaos.com,
 Jonas Bernoulli <jonas <at> bernoul.li>
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Sun, 26 Nov 2023 14:14:28 +0000
On Sat, Nov 25, 2023 at 12:44 PM João Távora <joaotavora <at> gmail.com> wrote:

> Hmmm. The two bugs are not related anymore than two Emacs bugs are related. That bug has a (very decent IMO) workaround. If you want something to be done there additionally, request it there
>
> > I don't know if these two bugs will have related solutions.
>
> I don't think so.


Earlier I said that 'autoload-compute-prefixes' was completely
undocumented.  I was wrong, it is documented in loading.texi
and perfectly defined in loaddefs-gen.el.  No idea why
I didn't notice.

It even has a sane local safety specification, but that safety
specification is not pre-loaded, so opening files
with 'autoload-compute-prefixes' local variables has
the unfortunate effect of prompting the user sometimes.

I think this should be fixed maybe somewhere in the
prompting logic.  Even describing the variable will cause
loaddefs-gen.el to be loaded the file and thus the safety
specification.

Another option is to store just safety specification
for this variable somewhere else, so that it is preloaded.

Eli, any comments about the above ideas?

João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sun, 26 Nov 2023 18:08:02 GMT) Full text and rfc822 format available.

Message #23 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: João Távora <joaotavora <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: joseph <at> ushin.org, 67325 <at> debbugs.gnu.org, jonas <at> bernoul.li,
 public <at> protesilaos.com
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Sun, 26 Nov 2023 20:07:15 +0200
> From: João Távora <joaotavora <at> gmail.com>
> Date: Sun, 26 Nov 2023 14:14:28 +0000
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 67325 <at> debbugs.gnu.org, public <at> protesilaos.com, 
> 	Jonas Bernoulli <jonas <at> bernoul.li>
> 
> On Sat, Nov 25, 2023 at 12:44 PM João Távora <joaotavora <at> gmail.com> wrote:
> 
> Earlier I said that 'autoload-compute-prefixes' was completely
> undocumented.  I was wrong, it is documented in loading.texi
> and perfectly defined in loaddefs-gen.el.  No idea why
> I didn't notice.
> 
> It even has a sane local safety specification, but that safety
> specification is not pre-loaded, so opening files
> with 'autoload-compute-prefixes' local variables has
> the unfortunate effect of prompting the user sometimes.
> 
> I think this should be fixed maybe somewhere in the
> prompting logic.  Even describing the variable will cause
> loaddefs-gen.el to be loaded the file and thus the safety
> specification.
> 
> Another option is to store just safety specification
> for this variable somewhere else, so that it is preloaded.
> 
> Eli, any comments about the above ideas?

I agree that we should not prompt when the safety predicate is
satisfied, but I don't have any idea how to do that.  Maybe Stefan
does?  E.g., can the (put 'autoload-compute-prefixes 'safe-local-variable
form be put in 'autoload'?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sun, 26 Nov 2023 18:45:02 GMT) Full text and rfc822 format available.

Message #26 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: joseph <at> ushin.org, 67325 <at> debbugs.gnu.org, jonas <at> bernoul.li,
 public <at> protesilaos.com,
 João Távora <joaotavora <at> gmail.com>
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Sun, 26 Nov 2023 13:44:09 -0500
> I agree that we should not prompt when the safety predicate is
> satisfied, but I don't have any idea how to do that.  Maybe Stefan
> does?  E.g., can the (put 'autoload-compute-prefixes 'safe-local-variable
> form be put in 'autoload'?

Yes, a standard autoload cookie should do the trick.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67325; Package emacs. (Sun, 26 Nov 2023 21:40:02 GMT) Full text and rfc822 format available.

Message #29 received at 67325 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: joseph <at> ushin.org, 67325 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 public <at> protesilaos.com, jonas <at> bernoul.li
Subject: Re: bug#67325: shorthands: Incorrect autoloaded
 register-definition-prefixes
Date: Sun, 26 Nov 2023 21:39:04 +0000
On Sun, Nov 26, 2023 at 6:44 PM Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>
> > I agree that we should not prompt when the safety predicate is
> > satisfied, but I don't have any idea how to do that.  Maybe Stefan
> > does?  E.g., can the (put 'autoload-compute-prefixes 'safe-local-variable
> > form be put in 'autoload'?
>
> Yes, a standard autoload cookie should do the trick.

Thanks for confirming.  I tested and indeed it does, so I pushed
this change.

So now breadcrumb.el can just specify this local variable to nil,
at least until those autoload heuristics aren't taught about
the shorthand exceptions.

If in fact they should... What do you think?

João




This bug report was last modified 159 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.