GNU bug report logs - #63399
28.2; Documentation for yes-or-no-p wrong/different between docstring and lispref

Previous Next

Package: emacs;

Reported by: Tim Landscheidt <tim <at> tim-landscheidt.de>

Date: Tue, 9 May 2023 20:36:02 UTC

Severity: minor

Found in version 28.2

Fixed in version 30.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

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 63399 in the body.
You can then email your comments to 63399 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#63399; Package emacs. (Tue, 09 May 2023 20:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tim Landscheidt <tim <at> tim-landscheidt.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 09 May 2023 20:36:02 GMT) Full text and rfc822 format available.

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

From: Tim Landscheidt <tim <at> tim-landscheidt.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; Documentation for yes-or-no-p wrong/different between
 docstring and lispref
Date: Tue, 09 May 2023 20:35:20 +0000
The documentation for yes-or-no-p in Emacs 28.2 reads:

| yes-or-no-p is a built-in function in ‘C source code’.

| (yes-or-no-p PROMPT)

| Ask user a yes-or-no question.
| Return t if answer is yes, and nil if the answer is no.

| PROMPT is the string to display to ask the question; ‘yes-or-no-p’
| adds "(yes or no) " to it.  It does not need to end in space, but if
| it does up to one space will be removed.

| […]

This is wrong: (yes-or-no-p "Prompt? ") gives the prompt
"Prompt? (yes or no) ", but according to the docstring it
should be "Prompt?(yes or no) ".

With the big caveat that I have never looked deeper at
Emacs's C code, the source in src/fns.c does not appear to
change the prompt given as an argument in any way, but just
append yes-or-no-prompt to it.

Also, (elisp) Yes-or-No Queries reads (since 7f53446a10ea;
doc/lispref/minibuf.texi):

| […]

|      Here is an example:

|           (yes-or-no-p "Do you really want to remove everything?")

|           ;; After evaluation of the preceding expression,
|           ;;   the following prompt appears,
|           ;;   with an empty minibuffer:

|           ---------- Buffer: minibuffer ----------
|           Do you really want to remove everything? (yes or no)
|           ---------- Buffer: minibuffer ----------

| […]

This is not the actual result: (yes-or-no-p "Do you really
want to remove everything?") gives the prompt "Do you really
want to remove everything?(yes or no) ", i. e., the space
before the parenthesis is missing.

Finally, the behaviour is different when using
use-short-answers:

| (yes-or-no-p "Prompt?")

gives "Prompt?(yes or no) ", while:

| (let ((use-short-answers t)) (yes-or-no-p "Prompt?"))

gives "Prompt? (y or n) ".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 10:09:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Tim Landscheidt <tim <at> tim-landscheidt.de>
Cc: 63399 <at> debbugs.gnu.org
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 12:08:24 +0200
[Message part 1 (text/plain, inline)]
Tim Landscheidt <tim <at> tim-landscheidt.de> writes:

Hi,

> With the big caveat that I have never looked deeper at
> Emacs's C code, the source in src/fns.c does not appear to
> change the prompt given as an argument in any way, but just
> append yes-or-no-prompt to it.
>
> Also, (elisp) Yes-or-No Queries reads (since 7f53446a10ea;
> doc/lispref/minibuf.texi):
>
> | […]
>
> |      Here is an example:
>
> |           (yes-or-no-p "Do you really want to remove everything?")
>
> |           ;; After evaluation of the preceding expression,
> |           ;;   the following prompt appears,
> |           ;;   with an empty minibuffer:
>
> |           ---------- Buffer: minibuffer ----------
> |           Do you really want to remove everything? (yes or no)
> |           ---------- Buffer: minibuffer ----------
>
> | […]
>
> This is not the actual result: (yes-or-no-p "Do you really
> want to remove everything?") gives the prompt "Do you really
> want to remove everything?(yes or no) ", i. e., the space
> before the parenthesis is missing.

I guess we should pad the prompt with a trailing space, if there isn't
any already. As we do in `y-or-no-p'. What about the appended patch?
Documentation must be updated as well, of course.

Best regards, Michael.

[Message part 2 (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 13:48:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tim Landscheidt <tim <at> tim-landscheidt.de>
Cc: 63399 <at> debbugs.gnu.org
Subject: Re: bug#63399: 28.2;
 Documentation for yes-or-no-p wrong/different between docstring and
 lispref
Date: Wed, 10 May 2023 16:48:31 +0300
> From: Tim Landscheidt <tim <at> tim-landscheidt.de>
> Date: Tue, 09 May 2023 20:35:20 +0000
> 
> The documentation for yes-or-no-p in Emacs 28.2 reads:
> 
> | yes-or-no-p is a built-in function in ‘C source code’.
> 
> | (yes-or-no-p PROMPT)
> 
> | Ask user a yes-or-no question.
> | Return t if answer is yes, and nil if the answer is no.
> 
> | PROMPT is the string to display to ask the question; ‘yes-or-no-p’
> | adds "(yes or no) " to it.  It does not need to end in space, but if
> | it does up to one space will be removed.
> 
> | […]
> 
> This is wrong: (yes-or-no-p "Prompt? ") gives the prompt
> "Prompt? (yes or no) ", but according to the docstring it
> should be "Prompt?(yes or no) ".

The doc string in Emacs 29 no longer includes the above confusing and
inaccurate text about removing the space.  So I think this
documentation bug was already fixed.

> Also, (elisp) Yes-or-No Queries reads (since 7f53446a10ea;
> doc/lispref/minibuf.texi):
> 
> | […]
> 
> |      Here is an example:
> 
> |           (yes-or-no-p "Do you really want to remove everything?")
> 
> |           ;; After evaluation of the preceding expression,
> |           ;;   the following prompt appears,
> |           ;;   with an empty minibuffer:
> 
> |           ---------- Buffer: minibuffer ----------
> |           Do you really want to remove everything? (yes or no)
> |           ---------- Buffer: minibuffer ----------
> 
> | […]
> 
> This is not the actual result: (yes-or-no-p "Do you really
> want to remove everything?") gives the prompt "Do you really
> want to remove everything?(yes or no) ", i. e., the space
> before the parenthesis is missing.

I've now fixed the example to be consistent with the result.

> Finally, the behaviour is different when using
> use-short-answers:
> 
> | (yes-or-no-p "Prompt?")
> 
> gives "Prompt?(yes or no) ", while:
> 
> | (let ((use-short-answers t)) (yes-or-no-p "Prompt?"))
> 
> gives "Prompt? (y or n) ".

You are supposed to include the trailing blank if you want to ensure
there's a blank between the prompt and the "(y or n)" part.

I think we should close this bug now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 14:05:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2;
 Documentation for yes-or-no-p wrong/different between docstring and
 lispref
Date: Wed, 10 May 2023 17:05:20 +0300
> Cc: 63399 <at> debbugs.gnu.org
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Date: Wed, 10 May 2023 12:08:24 +0200
> 
> I guess we should pad the prompt with a trailing space, if there isn't
> any already.

No, I don't think we should.  The caller should take care of any
padding, if that is desired.  The function shouldn't second-guess
whether a space is needed or not.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 14:07:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399 <at> debbugs.gnu.org, Tim Landscheidt <tim <at> tim-landscheidt.de>
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 16:05:54 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi Eli,

> You are supposed to include the trailing blank if you want to ensure
> there's a blank between the prompt and the "(y or n)" part.

In y-or-n-p, we add a trailing space if it doesn't exist. So I assume we
could do it in yes-or-no-p as well. See my other message, where I have
proposed a patch.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 14:09:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 16:07:45 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> I guess we should pad the prompt with a trailing space, if there isn't
>> any already.
>
> No, I don't think we should.  The caller should take care of any
> padding, if that is desired.  The function shouldn't second-guess
> whether a space is needed or not.

Why the difference to y-or-no-p?

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 14:42:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 17:42:12 +0300
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Cc: tim <at> tim-landscheidt.de,  63399 <at> debbugs.gnu.org
> Date: Wed, 10 May 2023 16:07:45 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> I guess we should pad the prompt with a trailing space, if there isn't
> >> any already.
> >
> > No, I don't think we should.  The caller should take care of any
> > padding, if that is desired.  The function shouldn't second-guess
> > whether a space is needed or not.
> 
> Why the difference to y-or-no-p?

I don't know.

But there's no difference if the prompt ends in a space.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 14:58:01 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 16:57:17 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> >> I guess we should pad the prompt with a trailing space, if there isn't
>> >> any already.
>> >
>> > No, I don't think we should.  The caller should take care of any
>> > padding, if that is desired.  The function shouldn't second-guess
>> > whether a space is needed or not.
>>
>> Why the difference to y-or-no-p?
>
> I don't know.
>
> But there's no difference if the prompt ends in a space.

Yes. It is just a convenience change, and there's code in the wild which
doesn't use a trailing space in the propmpt, when calling
yes-or-no-p. What would be wrong with my patch? I don't see that it
hurts.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 15:44:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 18:44:38 +0300
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Cc: tim <at> tim-landscheidt.de,  63399 <at> debbugs.gnu.org
> Date: Wed, 10 May 2023 16:57:17 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > But there's no difference if the prompt ends in a space.
> 
> Yes. It is just a convenience change, and there's code in the wild which
> doesn't use a trailing space in the propmpt, when calling
> yes-or-no-p. What would be wrong with my patch? I don't see that it
> hurts.

I'm sure something will come up.  It isn't an accident that we have
danced around this more than once in the past.

But if you insist, please install on master, and let's see whose gray
hair is more right...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 16:05:01 GMT) Full text and rfc822 format available.

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

From: Tim Landscheidt <tim <at> tim-landscheidt.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Michael Albinus <michael.albinus <at> gmx.de>, 63399 <at> debbugs.gnu.org
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 16:04:47 +0000
Eli Zaretskii <eliz <at> gnu.org> wrote:

>> > But there's no difference if the prompt ends in a space.

>> Yes. It is just a convenience change, and there's code in the wild which
>> doesn't use a trailing space in the propmpt, when calling
>> yes-or-no-p. What would be wrong with my patch? I don't see that it
>> hurts.

> I'm sure something will come up.  It isn't an accident that we have
> danced around this more than once in the past.

> But if you insist, please install on master, and let's see whose gray
> hair is more right...

I support Michael's idea here.  I do not remember any case
where a prompt "Prompt?(yes or no) " was an intentional
choice by the author.  It looks "wrong".  (The GNU Coding
Standards recommend spaces before open-parentheses in C
code, but strictly speaking this does not relate to the UI.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 16:44:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tim Landscheidt <tim <at> tim-landscheidt.de>
Cc: michael.albinus <at> gmx.de, 63399 <at> debbugs.gnu.org
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 19:44:24 +0300
> From: Tim Landscheidt <tim <at> tim-landscheidt.de>
> Cc: Michael Albinus <michael.albinus <at> gmx.de>,  63399 <at> debbugs.gnu.org
> Date: Wed, 10 May 2023 16:04:47 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> >> > But there's no difference if the prompt ends in a space.
> 
> >> Yes. It is just a convenience change, and there's code in the wild which
> >> doesn't use a trailing space in the propmpt, when calling
> >> yes-or-no-p. What would be wrong with my patch? I don't see that it
> >> hurts.
> 
> > I'm sure something will come up.  It isn't an accident that we have
> > danced around this more than once in the past.
> 
> > But if you insist, please install on master, and let's see whose gray
> > hair is more right...
> 
> I support Michael's idea here.

Of course you do.  And I won't argue, I will just say that you don't
have enough gray hair in Emacs development.  Time and again I see us
willing to fix some minuscule issue, and as result introduce subtle
problems and regressions which are frequently worse than the original
issue.  I suspect this is one of those cases.  But I'm willing to
consider the possibility that perhaps this time I will be wrong (yeah,
right).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 16:56:01 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399 <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 18:55:23 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi Eli,

>> Yes. It is just a convenience change, and there's code in the wild which
>> doesn't use a trailing space in the propmpt, when calling
>> yes-or-no-p. What would be wrong with my patch? I don't see that it
>> hurts.
>
> I'm sure something will come up.  It isn't an accident that we have
> danced around this more than once in the past.
>
> But if you insist, please install on master,

Will do. It might take one day or two. Tomorrow, I have a
Grand-daughter-care day. Perhaps also on Friday. Obviously, with changed
preferences :-)

> and let's see whose gray hair is more right...

Usually your hair, I know. Let's see.

OTOH, don't trust my Gravatar image. It is 15+ years old. If you want to
check my gray hair in reality, you might join the next Berlin Emacs
meetup :-)

<https://emacs-berlin.org/>

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63399; Package emacs. (Wed, 10 May 2023 16:58:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399 <at> debbugs.gnu.org, Tim Landscheidt <tim <at> tim-landscheidt.de>
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Wed, 10 May 2023 18:57:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi Eli,

> Of course you do.  And I won't argue, I will just say that you don't
> have enough gray hair in Emacs development.  Time and again I see us
> willing to fix some minuscule issue, and as result introduce subtle
> problems and regressions which are frequently worse than the original
> issue.  I suspect this is one of those cases.  But I'm willing to
> consider the possibility that perhaps this time I will be wrong (yeah,
> right).

Obviously, you should forward all reports about this change to me. I'm
prepared ...

Best regards, Michael.




Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Fri, 12 May 2023 10:50:02 GMT) Full text and rfc822 format available.

Notification sent to Tim Landscheidt <tim <at> tim-landscheidt.de>:
bug acknowledged by developer. (Fri, 12 May 2023 10:50:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63399-done <at> debbugs.gnu.org, tim <at> tim-landscheidt.de
Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different
 between docstring and lispref
Date: Fri, 12 May 2023 12:49:13 +0200
Version: 30.1

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

Hi Eli,

>> > But there's no difference if the prompt ends in a space.
>>
>> Yes. It is just a convenience change, and there's code in the wild which
>> doesn't use a trailing space in the propmpt, when calling
>> yes-or-no-p. What would be wrong with my patch? I don't see that it
>> hurts.
>
> I'm sure something will come up.  It isn't an accident that we have
> danced around this more than once in the past.
>
> But if you insist, please install on master, and let's see whose gray
> hair is more right...

I've pushed this to master. In NEWS.28, we have

--8<---------------cut here---------------start------------->8---
** 'yes-or-no-p' and 'y-or-n-p' PROMPT parameter no longer needs trailing space.
In other words, the prompt can now end with "?" instead of "? ".  This
has been the case since Emacs 24.4 but was not announced or documented
until now.  (Checkdoc has also been updated to accept this convention.)
--8<---------------cut here---------------end--------------->8---

So this is the intended bahavior, and the patch is just a bug fix.

Closing this report.

Best regards, Michael.




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

This bug report was last modified 314 days ago.

Previous Next


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