Subject: bug#63399: closed (Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different between docstring and lispref)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 12 May 2023 10:50:02 +0000

Your bug report

#63399: 28.2; Documentation for yes-or-no-p wrong/different between docstring and lispref

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
63399: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63399
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#63399: 28.2; Documentation for yes-or-no-p wrong/different between docstring and lispref
From: Michael Albinus <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Fri, 12 May 2023 12:49:13 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 30.1

Eli Zaretskii <[email-masked]> 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.

Subject: 28.2; Documentation for yes-or-no-p wrong/different between docstring and lispref
From: Tim Landscheidt <[email-masked]>
To: [email-masked]
Date: Tue, 09 May 2023 20:35:20 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

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) ".