GNU bug report logs - #64138
28.2; C-x ) won't accept the universal argument

Previous Next

Package: emacs;

Reported by: Al Petrofsky <al <at> petrofsky.org>

Date: Sat, 17 Jun 2023 23:49:02 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64138 in the body.
You can then email your comments to 64138 AT debbugs.gnu.org in the normal way.

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#64138; Package emacs. (Sat, 17 Jun 2023 23:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Al Petrofsky <al <at> petrofsky.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 17 Jun 2023 23:49:02 GMT) Full text and rfc822 format available.

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

From: Al Petrofsky <al <at> petrofsky.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; C-x ) won't accept the universal argument
Date: Sat, 17 Jun 2023 19:47:47 -0400
[Message part 1 (text/plain, inline)]
   emacs-28.2 -Q -nw
   C-x ( x C-u C-x )

The C-u C-x ) should complete the macro definition and then execute
the macro three times, making the buffer contents "xxxx".  Instead,
the error "Wrong type argument: fixnump, (4)" occurs.

(Changing "C-u" to "C-u 4" gives the expected result.)

The "P" in the interactive declaration of kmacro-end-macro should be a
"p".

Looking at all eleven "P" in kmacro.el, I think four of them should be
"p": kmacro-call-ring-2nd, kmacro-call-ring-2nd-repeat,
kmacro-end-macro, and kmacro-end-and-call-macro.

Alternatively, if the meaning of a bare C-u argument is being reserved
for some future feature, then it should be explicitly mentioned in the
documentation that C-u and C-u 4 are treated differently.  As the
manual says:

      A few commands treat a plain ‘C-u’ differently from an ordinary
   argument.  A few others may treat an argument of just a minus sign
   differently from an argument of −1.  These unusual cases are described
   when they come up; they exist to make an individual command more
   convenient, and they are documented in that command’s documentation
   string.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64138; Package emacs. (Sun, 18 Jun 2023 06:51:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Al Petrofsky <al <at> petrofsky.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64138 <at> debbugs.gnu.org
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Sun, 18 Jun 2023 09:50:50 +0300
> From: Al Petrofsky <al <at> petrofsky.org>
> Date: Sat, 17 Jun 2023 19:47:47 -0400
> 
>    emacs-28.2 -Q -nw
>    C-x ( x C-u C-x )
> 
> The C-u C-x ) should complete the macro definition and then execute
> the macro three times, making the buffer contents "xxxx".  Instead,
> the error "Wrong type argument: fixnump, (4)" occurs.
> 
> (Changing "C-u" to "C-u 4" gives the expected result.)
> 
> The "P" in the interactive declaration of kmacro-end-macro should be a
> "p".

These commands always required a numeric prefix argument, and that is
how they are documented.  So just "C-u" is invalid, you should use
"C-u 4" instead.

I have no objections to extending those commands to accept just C-u,
though.  Stefan, any reasons why not?




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

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

From: Al Petrofsky <al <at> petrofsky.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64138 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Sun, 18 Jun 2023 07:00:44 -0400
[Message part 1 (text/plain, inline)]
> > The C-u C-x ) should complete the macro definition and then execute
> > the macro three times

> These commands always required a numeric prefix argument

The kmacro-end-macro command has always used the wrong interactive
spec, but C-u C-x ) worked in Emacs 1.9 through 21.4, when C-x ) was
bound to end-kbd-macro, which has always used "p".

> These commands always required a numeric prefix argument, and that
> is how they are documented.  So just "C-u" is invalid, you should
> use "C-u 4" instead.

Hmm, kmacro-end-macro's doc string copied this paragraph verbatim from
end-kbd-macro:

    With numeric arg, repeat macro now that many times,
    counting the definition just completed as the first repetition.
    An argument of zero means repeat until error.

So you're saying that end-kbd-macro was always documented wrong, and
should have pointed out that C-u works?  I take the manual to be
saying that C-u meaning C-u 4 is the norm, and it is the functions
that are exceptions to that norm that need to clearly document that
exception:

   A few commands treat a plain ‘C-u’ differently from an ordinary
   argument.  A few others may treat an argument of just a minus sign
   differently from an argument of −1.  These unusual cases are described
   when they come up; they exist to make an individual command more
   convenient, and they are documented in that command’s documentation
   string.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64138; Package emacs. (Sun, 18 Jun 2023 11:06:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Al Petrofsky <al <at> petrofsky.org>
Cc: 64138 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Sun, 18 Jun 2023 14:05:11 +0300
> From: Al Petrofsky <al <at> petrofsky.org>
> Date: Sun, 18 Jun 2023 07:00:44 -0400
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 64138 <at> debbugs.gnu.org
> 
> > These commands always required a numeric prefix argument, and that
> > is how they are documented.  So just "C-u" is invalid, you should
> > use "C-u 4" instead.
> 
> Hmm, kmacro-end-macro's doc string copied this paragraph verbatim from
> end-kbd-macro:
> 
>     With numeric arg, repeat macro now that many times,
>     counting the definition just completed as the first repetition.
>     An argument of zero means repeat until error.
> 
> So you're saying that end-kbd-macro was always documented wrong, and
> should have pointed out that C-u works?

No, I'm saying that just "C-u" is not a "numeric argument".

> I take the manual to be
> saying that C-u meaning C-u 4 is the norm, and it is the functions
> that are exceptions to that norm that need to clearly document that
> exception:
> 
>    A few commands treat a plain ‘C-u’ differently from an ordinary
>    argument.  A few others may treat an argument of just a minus sign
>    differently from an argument of −1.  These unusual cases are described
>    when they come up; they exist to make an individual command more
>    convenient, and they are documented in that command’s documentation
>    string.

Yes, which is why it would be good to make these commands behave
closer to the general principle that the manual describes.  I'm just
saying that they never did until now.  Which is completely legitimate,
since what these commands do is not easily and obviously categorized
as repeatable operations: the argument makes them repeat some part of
what the command does.

Anyway, I think we agree that it would be a good extension, so no need
to argue any longer.  I'd just want to hear from Stefan whether we are
missing some subtlety here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64138; Package emacs. (Sun, 18 Jun 2023 13:06:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Al Petrofsky <al <at> petrofsky.org>, Stefan
 Monnier <monnier <at> iro.umontreal.ca>
Cc: "64138 <at> debbugs.gnu.org" <64138 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#64138: 28.2; C-x ) won't accept the universal
 argument
Date: Sun, 18 Jun 2023 13:05:24 +0000
> > (Changing "C-u" to "C-u 4" gives the expected result.)
> > The "P" in the interactive declaration of kmacro-end-macro
> > should be a "p".
> 
> These commands always required a numeric prefix argument, and that is
> how they are documented.  So just "C-u" is invalid, you should use
> "C-u 4" instead.

I thought it was the case that unless specified
otherwise (i.e., unless C-u has another behavior),
when a numeric prefix arg has some behavior then
a plain C-u should act the same as C-u 4 (etc.).

I thought that when doc says _only_ "with numeric
prefix arg..." or "a numeric prefix arg means..."
that's short for an equivalent statement about
plain C-u (and its multiples), plain M--, etc.

I thought that any departure from this general
rule would be mentioned in the doc, including if
plain C-u were ignored or raised an error or...

Hasn't this been the (unwritten) convention?
(Just asking a question - not arguing.)

In this case, if plain C-u were indeed "invalid"
then I'd expect that to be documented.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64138; Package emacs. (Sun, 18 Jun 2023 13:37:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Al Petrofsky <al <at> petrofsky.org>, 64138 <at> debbugs.gnu.org
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Sun, 18 Jun 2023 09:36:09 -0400
> I have no objections to extending those commands to accept just C-u,
> though.  Stefan, any reasons why not?

Offhand, I can't think of any reason why not.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64138; Package emacs. (Sun, 18 Jun 2023 14:09:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Al Petrofsky <al <at> petrofsky.org>, 64138 <at> debbugs.gnu.org
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Sun, 18 Jun 2023 10:08:04 -0400
>> I have no objections to extending those commands to accept just C-u,
>> though.  Stefan, any reasons why not?
> Offhand, I can't think of any reason why not.

BTW: the main question here is whether a C-1 prefix should be treated
the same as the absence of a prefix.  AFAICT, the `arg` argument
of `kmacro-end-macro` is only used once, to pass it to `end-kbd-macro`,
and that function starts with:

      if (NILP (repeat))
        XSETFASTINT (repeat, 1);
      else
        CHECK_FIXNUM (repeat);

so, the absence of a prefix arg currently should indeed always behave
exactly as with a `C-1` arg.
IOW, I'm pretty sure now that there is not reason why not.


        Stefan





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 21 Jun 2023 14:03:01 GMT) Full text and rfc822 format available.

Notification sent to Al Petrofsky <al <at> petrofsky.org>:
bug acknowledged by developer. (Wed, 21 Jun 2023 14:03:01 GMT) Full text and rfc822 format available.

Message #28 received at 64138-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: al <at> petrofsky.org, 64138-done <at> debbugs.gnu.org
Subject: Re: bug#64138: 28.2; C-x ) won't accept the universal argument
Date: Wed, 21 Jun 2023 17:02:06 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Al Petrofsky <al <at> petrofsky.org>,  64138 <at> debbugs.gnu.org
> Date: Sun, 18 Jun 2023 10:08:04 -0400
> 
> >> I have no objections to extending those commands to accept just C-u,
> >> though.  Stefan, any reasons why not?
> > Offhand, I can't think of any reason why not.
> 
> BTW: the main question here is whether a C-1 prefix should be treated
> the same as the absence of a prefix.  AFAICT, the `arg` argument
> of `kmacro-end-macro` is only used once, to pass it to `end-kbd-macro`,
> and that function starts with:
> 
>       if (NILP (repeat))
>         XSETFASTINT (repeat, 1);
>       else
>         CHECK_FIXNUM (repeat);
> 
> so, the absence of a prefix arg currently should indeed always behave
> exactly as with a `C-1` arg.
> IOW, I'm pretty sure now that there is not reason why not.

OK, thanks.  I've now installed this on the master branch, and I'm
closing this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 20 Jul 2023 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 336 days ago.

Previous Next


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