unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50811: 28.0.50; Misleading Docstring for read-string function
@ 2021-09-26  8:28 mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-09-27  4:22 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-09-26  8:28 UTC (permalink / raw)
  To: 50811

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





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

end of thread, other threads:[~2021-09-27 15:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-26  8:28 bug#50811: 28.0.50; Misleading Docstring for read-string function mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-27  4:22 ` 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

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