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#35231: 26.1; Redefine `read-command' behavior for empty input and DEFAULT not a command name Date: Tue, 9 Jul 2019 09:17:55 -0700 (PDT) Message-ID: References: <85ddecd9-7a66-4fbc-8297-b4419e45db05@default> <87ef2ztdx3.fsf@mouse.gnus.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="50015"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 35231@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 09 18:34:49 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hkt4q-000CN0-W5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jul 2019 18:34:49 +0200 Original-Received: from localhost ([::1]:51762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hksps-0003Sy-9Q for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jul 2019 12:19:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32871) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkspb-0003Ol-VS for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 12:19:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkspa-0002fa-Ph for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 12:19:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkspa-0002f8-Hg for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 12:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hkspa-0007zU-Ci for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 12:19: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: Tue, 09 Jul 2019 16:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35231 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 35231-submit@debbugs.gnu.org id=B35231.156268908630640 (code B ref 35231); Tue, 09 Jul 2019 16:19:02 +0000 Original-Received: (at 35231) by debbugs.gnu.org; 9 Jul 2019 16:18:06 +0000 Original-Received: from localhost ([127.0.0.1]:33964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hksof-0007y8-RM for submit@debbugs.gnu.org; Tue, 09 Jul 2019 12:18:06 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:41796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hksoe-0007tJ-KP for 35231@debbugs.gnu.org; Tue, 09 Jul 2019 12:18:05 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x69GE13E140339; Tue, 9 Jul 2019 16:17:58 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=YJqG1Gunzh+Gt2pyHzHdvYXe0YNWWkuffR0eHcvTpAg=; b=Z3DAIluHowaCCdLceHfvyYT/pruhBP8gM3+Wviwxn9SPne54FngTe74E7xgP48wLZ9zC j4liW/IfUG3JOp/3OGRAQzVqTVWyMeZPwTcSN4u4q3itI/44syiEN4xl7X8GfImQjdTG lbPW+ZZAA66oNL1ONiuZwEA0ciZ+R0+PtCfQbZhqFu3LJfvF77YXStFvMEj3aG9JU8nM gjwNiK12MwUBfhE7bAIrhwXEjn6HPyhGM1U9swBD8KuVcEIwSkbxUI3gnnDr/E/fX8Bk tWZ6d3KT4cFwyikGJcZ4Z6f5DBnMXi2MpSUASygsWQjE3NeXGAYeRpPzZjnSWonPuYjk Kw== Original-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2tjkkpnc1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jul 2019 16:17:58 +0000 Original-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x69GHYhV135376; Tue, 9 Jul 2019 16:17:57 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2tmwgx0wg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jul 2019 16:17:57 +0000 Original-Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x69GHu2M007930; Tue, 9 Jul 2019 16:17:56 GMT In-Reply-To: <87ef2ztdx3.fsf@mouse.gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4861.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9313 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090191 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9313 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 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-1907090190 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:162515 Archived-At: > > This is a followup to bug #35222 (and thanks for fixing that doc bug). > > > > As discussed in #35222, the current C-code definition of `read-command' > > seems not so desirable, when it comes to DEFAULT =3D nil or "". > > > > The behavior in that case is to return an uninterned symbol whose name > > is empty, which has the read/print syntax `##'. > > > > This is _not_ a symbol whose function definition is `commandp'. There > > is nothing about this symbol that qualifies for consideration as a > > command. It seems wrong (a bug) for `read-command' to ever return a > > symbol whose function definition is `commandp'. >=20 > That is, indeed, pretty odd. The function isn't used a lot in Emacs: >=20 > ./lisp/subr.el1088: (read-command (format "Set key %s to comman= d: > " > ./lisp/edmacro.el118:=09 (setq cmd (read-command "Name of keyboard > macro to edit: ")) > ./lisp/emulation/edt.el1130:=09(setq edt-function (read-command "Enter > command name: ")) > ./lisp/info.el4526:=09 (read-command "Find documentation for command: > "))) > ./lisp/strokes.el448: (read-command "Command to map stroke to: "))) >=20 > But some of them expect this behaviour: >=20 > =09 (setq cmd (read-command "Name of keyboard macro to edit: ")) > =09 (if (string-equal cmd "") > =09=09 (error "No command name given")) >=20 > =09(setq edt-function (read-command "Enter command name: ")) > =09(if (string-equal "" edt-function) > =09 (message "Key not defined") >=20 > So changing the behaviour is probably not a good idea -- there may be > out-of-tree usages. So I think we'll have to live with it, and I'm > closing this bug report. Just for the record: I don't think this is the best way to handle this. It seems clear from those rare examples you show that they do what they do only to _work around_ the odd (bugged) behavior. It would be easy to fix them. Likewise, any 3rd-party code. And in fact, with a fixed `read-command' no change would really be needed to any such caller. The test for equality with "" would simply never succeed. The test would be superfluous, but if it were not removed there would be no loss. I made good suggestions for how this function can be better defined, and how to handle the (minor) incompatible change (fix) for returning a non command name. The function can be trivially defined in Lisp, in such a way that users can benefit from completion and no caller will need to test for a non-command name (whether odd, such as "", or not). That's the way to improve Emacs, here. Closing the bug because there may be callers that "depend" on the bugged behavior in the way you indicated (i.e., as a bug workaround, for the odd possibility that a non-command name would be read) doesn't make sense to me. This bug is simple to fix properly, and I see no downside to that being done. It's also possible (but it shouldn't be necessary) to define a new function, with a different name, and use that. And declare the old one, with the bug, defined in C, as obsolete. FWIW, I use this (in Dired+): (defun diredp-read-command (&optional prompt default) "Read the name of a command and return a symbol with that name. \(A command is anything that satisfies predicate `commandp'.) Prompt with PROMPT, which defaults to \"Command: \". By default, return the command named DEFAULT (or, with Emacs 23+, its first element if DEFAULT is a list). (If DEFAULT does not name a command then it is ignored.)" (setq prompt (or prompt "Command: ")) (let ((name (completing-read prompt obarray #'commandp t nil 'extended-command-history default))) (while (string=3D "" name) (setq name (completing-read prompt obarray #'commandp t nil 'extended-command-history default))) (intern name))) Any good reason why such a definition (or similar) should not be used as a replacement for the current, bugged, `read-command'?