From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#34794: 26.1; doc of `read-buffer' Date: Sun, 10 Mar 2019 15:23:05 -0700 (PDT) Message-ID: <48406c96-9f8e-47cf-92f1-525a9ea7077e@default> References: <<<>>> <<<<831s3g7zv1.fsf@gnu.org>>>> <<>> <<<83r2bf7w21.fsf@gnu.org>>> <> <<83o96i615x.fsf@gnu.org>> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="72004"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34794@debbugs.gnu.org To: Eli Zaretskii , Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 10 23:44:25 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h37BA-000IZp-PZ for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Mar 2019 23:44:25 +0100 Original-Received: from localhost ([127.0.0.1]:52066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h37B9-0007B2-Ox for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Mar 2019 18:44:23 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:32946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h378G-0005Bx-ON for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2019 18:41:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h36rT-0002pQ-0H for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2019 18:24:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h36rS-0002pI-RK for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2019 18:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h36rS-0006hR-It for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2019 18:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Mar 2019 22:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34794 X-GNU-PR-Package: emacs Original-Received: via spool by 34794-submit@debbugs.gnu.org id=B34794.155225659925685 (code B ref 34794); Sun, 10 Mar 2019 22:24:02 +0000 Original-Received: (at 34794) by debbugs.gnu.org; 10 Mar 2019 22:23:19 +0000 Original-Received: from localhost ([127.0.0.1]:38481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h36qk-0006gD-Pm for submit@debbugs.gnu.org; Sun, 10 Mar 2019 18:23:19 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:52724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h36qh-0006fv-Og for 34794@debbugs.gnu.org; Sun, 10 Mar 2019 18:23:16 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2AMJZ18022892; Sun, 10 Mar 2019 22:23:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=FlrM6beO7q+sm/J0ssx5ox7d/etW2hZ6DVuS7nyqVFc=; b=qN/RqFT2KDGVZyFinbrk/9prTZVKmulr0yBiwtvfssqZl4dEsqvs7Vk5ewk+S3prnppr MJ3qwaL2Ms6IPk95KXz74ZMb04AhuFktZaPD37YVET2/xY7KIXJcOf2OYvt7ATmybZGP wzx0iSMrCAwgc9xLY6Pn76XdSVIP02qaztMMUuDb8rs3fC47z3ReagN4dlsjE4/KICFu jPkFfsid73YzPZBkH1XH4XSndI+ed6tvKsh9KABjKGeQnUiH4wQeT7nwlO7JVg4HHwXr Jc6avB50CGwV73XQg2wWFdcQppyFd1kOlA8g0RJRJbNhLHxH1zDmZlqv4+46Huo57p3C Iw== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2r464r3brx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 10 Mar 2019 22:23:09 +0000 Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2AMN8ZR001146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 10 Mar 2019 22:23:09 GMT Original-Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2AMN6q2028145; Sun, 10 Mar 2019 22:23:06 GMT In-Reply-To: <<83o96i615x.fsf@gnu.org>> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4810.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9191 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903100172 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156223 Archived-At: > I used some ideas from your suggestion. Thanks. Do you have a URL to the updated doc? > > 4. There appears to be a fairly large bug in the > > behavior, BTW. The function is supposed to return a > > buffer name, which is presumably a string. > > > > But try this, hitting `RET' with empty minibuffer input: > > (read-buffer "b: " (selected-window) t) > > That returns a window! And this returns a number, not > > a numeric string: (read-buffer "b: " 42 t) > > It apparently can return anything at all. >=20 > AFAICT, it just behaves according to documentation of DEF. >=20 > > This is in spite of the fact that the REQUIRE-MATCH > > arg is `t', and according to the doc that should > > mean that you cannot exit the minibuffer unless the > > input corresponds to an existing buffer. >=20 > That's only valid for something the user types, AFAIU. Yes, you're right about that. "`t' means that the user is not allowed to exit unless the input is (or completes to) an element of COLLECTION __or is null__." I forgot about that last part. > > Do you prefer a separate bug report for this bug, or > > can you fix it based on this report? >=20 > I don't really see what is there to fix. I guess not. I would have thought that a DEF that isn't a buffer name - or at least a string - might helpfully raise an error. Let me see what other `read-*' functions do... `read-string', `read-passwd', and `read-regexps' act the same way: the DEFAULT(S) arg can be anything at all, and it is returned as is upon empty input. `read-string' doesn'tt necessarily return a string, and so on. Not great, I'd say. But at least `read-buffer' is not alone in such behavior. And I suppose there is some code somewhere that even takes advantage of such a "feature" somehow... I'm happy, however, to see that at least some `read-*' commands do raise an error if the DEFAULT arg is not a string or nil. `read-command', for example, raises an error if DEF is not a string (it doesn't require a command name, but that test is better than nothing): Hitting RET with no input here: (read-command "Command: " (selected-window)) raises wrong-type-argument stringp # Same thing for `read-number', though at least that tests for the expected type: (read-number "Number: " (selected-window)) wrong-type-argument numberp #) `read-face-name' raises an error even before trying to read! It doesn't wait for input: (read-face-name "Face: " (selected-window)) wrong-type-argument listp # BTW, `read-from-minibuffer' with non-nil READ arg and with DEFAULT-VALUE not a string or nil ends with an `End of file during parsing error': Hitting RET with no input here: (read-from-minibuffer "Input: " nil nil t nil (selected-window)) DEFAULT-VALUE of course "should be a string", but if it's not the error message is not as helpful as it could be. There's nothing to be done about this one, however, I guess. Perhaps it could spit out the thing it was passed as DEFAULT-VALUE, to let you know what `read' choked on. =20 `read-input-method-name' seems a bit problematic when passed a non-string, non-nil DEFAULT-VALUE arg. It tries to insert it into the prompt's "%s", which ends in an error such as=20 wrong-type-argument sequencep #) `read-language-name' raises a similar error: wrong-type-argument sequencep #) There isn't much consistency in these `read-*' functions wrt their handling of the DEFAULT arg. IMO at least some of them might be made better by testing whether that arg is of the proper type and raising a (somewhat relevant) error if not.