unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
@ 2023-11-20 19:50 Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-24  8:06 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-20 19:50 UTC (permalink / raw)
  To: 67325; +Cc: Protesilaos Stavrou, Jonas Bernoulli, João Távora

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-20 19:50 bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-24  8:06 ` Eli Zaretskii
  2023-11-24  9:24   ` João Távora
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-11-24  8:06 UTC (permalink / raw)
  To: Joseph Turner, joaotavora; +Cc: 67325, jonas, public

> Cc: Protesilaos Stavrou <public@protesilaos.com>,
>  Jonas Bernoulli <jonas@bernoul.li>,
>  João Távora <joaotavora@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@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?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-24  8:06 ` Eli Zaretskii
@ 2023-11-24  9:24   ` João Távora
  2023-11-25  4:18     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: João Távora @ 2023-11-24  9:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Joseph Turner, 67325, jonas, public

On Fri, Nov 24, 2023 at 8:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Cc: Protesilaos Stavrou <public@protesilaos.com>,
> >  Jonas Bernoulli <jonas@bernoul.li>,
> >  João Távora <joaotavora@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@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-24  9:24   ` João Távora
@ 2023-11-25  4:18     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-25 12:44       ` João Távora
  0 siblings, 1 reply; 9+ messages in thread
From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-25  4:18 UTC (permalink / raw)
  To: João Távora; +Cc: 67325, Eli Zaretskii, public, jonas

João Távora <joaotavora@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-25  4:18     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-25 12:44       ` João Távora
  2023-11-26 14:14         ` João Távora
  0 siblings, 1 reply; 9+ messages in thread
From: João Távora @ 2023-11-25 12:44 UTC (permalink / raw)
  To: Joseph Turner; +Cc: 67325, Eli Zaretskii, public, Jonas Bernoulli

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

On Sat, Nov 25, 2023, 04:21 Joseph Turner <joseph@ushin.org> wrote:

> João Távora <joaotavora@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

[-- Attachment #2: Type: text/html, Size: 1182 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-25 12:44       ` João Távora
@ 2023-11-26 14:14         ` João Távora
  2023-11-26 18:07           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: João Távora @ 2023-11-26 14:14 UTC (permalink / raw)
  To: Joseph Turner; +Cc: 67325, Eli Zaretskii, public, Jonas Bernoulli

On Sat, Nov 25, 2023 at 12:44 PM João Távora <joaotavora@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-26 14:14         ` João Távora
@ 2023-11-26 18:07           ` Eli Zaretskii
  2023-11-26 18:44             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-11-26 18:07 UTC (permalink / raw)
  To: João Távora, Stefan Monnier; +Cc: joseph, 67325, jonas, public

> From: João Távora <joaotavora@gmail.com>
> Date: Sun, 26 Nov 2023 14:14:28 +0000
> Cc: Eli Zaretskii <eliz@gnu.org>, 67325@debbugs.gnu.org, public@protesilaos.com, 
> 	Jonas Bernoulli <jonas@bernoul.li>
> 
> On Sat, Nov 25, 2023 at 12:44 PM João Távora <joaotavora@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'?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-26 18:07           ` Eli Zaretskii
@ 2023-11-26 18:44             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-26 21:39               ` João Távora
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-26 18:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: joseph, 67325, jonas, public, João Távora

> 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes
  2023-11-26 18:44             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-26 21:39               ` João Távora
  0 siblings, 0 replies; 9+ messages in thread
From: João Távora @ 2023-11-26 21:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joseph, 67325, Eli Zaretskii, public, jonas

On Sun, Nov 26, 2023 at 6:44 PM Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-26 21:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-20 19:50 bug#67325: shorthands: Incorrect autoloaded register-definition-prefixes Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-24  8:06 ` Eli Zaretskii
2023-11-24  9:24   ` João Távora
2023-11-25  4:18     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-25 12:44       ` João Távora
2023-11-26 14:14         ` João Távora
2023-11-26 18:07           ` Eli Zaretskii
2023-11-26 18:44             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-26 21:39               ` João Távora

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).