[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50811: 28.0.50; Misleading Docstring for read-string function
From: |
Codruț Constantin Gușoi |
Subject: |
bug#50811: 28.0.50; Misleading Docstring for read-string function |
Date: |
Sun, 26 Sep 2021 08:28:05 +0000 |
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