unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: mail--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 50811@debbugs.gnu.org
Subject: bug#50811: 28.0.50; Misleading Docstring for read-string function
Date: Sun, 26 Sep 2021 08:28:05 +0000	[thread overview]
Message-ID: <_54OEp0LYzdxgXLLnOGpPKIfp0dH3AVBE0pzUGBTFZW_r1v5IQw7Vf4Ij-ugCTXUw-UVAneeffL-Kt1PV2XuwrSeFXFllKCypAD2pZ1cQZs=@codrut.pro> (raw)

While trying to solve and issue in an emacs pacage: https://github.com/Alexander-Miller/cfrs/pull/6 I encountered the following docstring entry for the read-string function:


```

If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
  This argument has been superseded by DEFAULT-VALUE and should normally be nil
  in new code.  It behaves as INITIAL-CONTENTS in `read-from-minibuffer' (which
  see).
```


This is misleading since INITIAL-INPUT behaves differently from DEFAULT-VALUE:


```

;; No pre-completed value, returns "" when empty.
(read-string "PROMPT ")

;; Pre-completed with "A", returns "" when empty.
(read-string "PROMPT " "A")

;; Pre-completed with "A", returns "B" when empty.
(read-string "PROMPT " "A" nil "B")

;; No pre-completed value, returns "B" when empty.
(read-string "PROMPT " nil nil "B")

```


Not sure what should be done here, either remove that note, since both arguments do a different job, or change the code to pass around DEFAULT-VALUE instead of INITIAL-INPUT internally when INITIAL-INPUT is nil, as the docstring suggests. But the latter feels weird to me as getting rid of INITIAL-INPUT would be a breaking change so it's probably never going to be removed from the arguments list. Also I am not sure what the initial intention of superseding INITIAL-INPUT was.


Let me know what you think works best and I can submit patches.

Cheers,
Codruț

www.codrut.pro





             reply	other threads:[~2021-09-26  8:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26  8:28 mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-09-27  4:22 ` bug#50811: 28.0.50; Misleading Docstring for read-string function Lars Ingebrigtsen
2021-09-27  4:35   ` mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-27  4:40     ` Lars Ingebrigtsen
2021-09-27  4:56       ` mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-27  5:02         ` Lars Ingebrigtsen
2021-09-27 15:22       ` bug#50811: [External] : " Drew Adams
2021-09-27 15:17   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='_54OEp0LYzdxgXLLnOGpPKIfp0dH3AVBE0pzUGBTFZW_r1v5IQw7Vf4Ij-ugCTXUw-UVAneeffL-Kt1PV2XuwrSeFXFllKCypAD2pZ1cQZs=@codrut.pro' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=50811@debbugs.gnu.org \
    --cc=mail@codrut.pro \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).