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.devel Subject: RE: read-from-minibuffer INITIAL-CONTENTS/DEFAULT-VALUE Date: Fri, 12 Jul 2019 23:40:15 -0700 (PDT) Message-ID: <08db103a-ffb8-4465-a0e4-f90fb834fc43@default> References: 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="248669"; mail-complaints-to="usenet@blaine.gmane.org" To: Lars Ingebrigtsen , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 13 08:40:40 2019 Return-path: Envelope-to: ged-emacs-devel@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 1hmBi2-0012Ia-S6 for ged-emacs-devel@m.gmane.org; Sat, 13 Jul 2019 08:40:39 +0200 Original-Received: from localhost ([::1]:53856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmBhp-0002Fa-Az for ged-emacs-devel@m.gmane.org; Sat, 13 Jul 2019 02:40:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39818) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmBhm-0002FT-OX for emacs-devel@gnu.org; Sat, 13 Jul 2019 02:40:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmBhl-0004bi-8g for emacs-devel@gnu.org; Sat, 13 Jul 2019 02:40:22 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:34508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hmBhk-0004a4-TO for emacs-devel@gnu.org; Sat, 13 Jul 2019 02:40:21 -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 x6D6eIi0002886; Sat, 13 Jul 2019 06:40:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=fvGBuAaVvqHJDgjr4dxG8KVUD7aN5wjJ/ss5UpziFQk=; b=r22OOcji7zAeZV3BAGc006jrIFCc3AyecQFTnMlwD5mU5hKQhbE8BBcwYZ4OyJ+rHsL2 BLFW/oVyepnbVQlgfqfw5XBl+cjBiBRcScfIcWZQkqxn9NIY5weGJgu9hevZhBhMpik3 WOzyP1X80tu8wUHPM4j2jDj3IMmb0eKYusSXFLhFTdiYtKsCr0F0sQPDkfFTGIFRbnrI lFRF5/Rgu4JOM6Zy0A9Dykou0D4sU4eP7LM1upcp8AVeJHg2bewLzkYMa3UungNa902n X1tNgCOt9TqICJHyZb6xQPuOhqFrWNlG3Ze4OTU9ODuImyUe9Dl2FORE8qOQEf9ne3Hd Nw== Original-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2tq7xqg7b6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Jul 2019 06:40:18 +0000 Original-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6D6bUOw110562; Sat, 13 Jul 2019 06:40:17 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2tq741t3ha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Jul 2019 06:40:17 +0000 Original-Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x6D6eGYa023221; Sat, 13 Jul 2019 06:40:16 GMT In-Reply-To: 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=9316 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-1907130078 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9316 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=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-1907130078 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238541 Archived-At: > Historically, Emacs has used to put text in INITIAL-CONTENTS for a bunch > of commands, but has, over the years, moved to putting the defaults in > DEFAULT-VALUE so that the user has to type `M-n' to get at them. >=20 > Overall, I think this is a good change... but for a bunch of commands, > I really would like to have what's in DEFAULT-VALUE to be in > INITIAL-CONTENTS instead. It's a lot more ergonomic (for me) for a > number of commands, and reading a bunch of bug reports over the years, > apparently for a number of users as well. >=20 > So it would be nice if there was a way to tweak this. >=20 > An obvious way would be to offer an option that would just put > DEFAULT-VALUE in INITIAL-CONTENTS always. It'd be trivial to implement, > and I'm sure somebody would want this for all commands. >=20 > An if somebody wants this action for some commands only, they could add > :around advice to the commands in question. >=20 > Or we could allow tweaking this in the symbol plists. >=20 > Any opinions? I argued for this long ago, and since 2005 Icicles has had such an option. It controls the treatment of the default value (or the first default value, if the default value is a list): whether it is shown in the prompt, substituted for an empty INITIAL-INPUT, and so on. The default value of the option is `t', which gives behavior like that of vanilla Emacs. ------- icicle-default-value is a variable defined in `icicles-opt.el'. Its value is insert-end Original value was t Documentation: How to treat the default value when reading minibuffer input. These are the possible option values: nil - Do not insert default value or add it to prompt. t - Add default value to `completing-read' prompt. Do not insert it. `insert-start' - Insert default value and leave cursor at start. `insert-end' - Insert default value and leave cursor at end. `preselect-start' - Insert and preselect default value; leave cursor at beginning. `preselect-end' - Insert and preselect default value; leave cursor at end. This option controls how a non-nil default-value argument to functions such as `completing-read', `read-file-name', `read-from-minibuffer', and `read-string' is handled. When it is non-nil and the initial-input argument is nil or "", the default value can be inserted into the minibuffer as the initial input. For `completing-read' and `read-file-name', if the option value is `t' then the default value is normally added to the prompt as a hint. However, for `read-file-name', if `insert-default-directory' is non-nil, then to avoid duplication: * If the default value is the same as `default-directory' it is not added to the prompt. * If the default value is added to the prompt it is first made relative to `default-directory'. Adding the default value to the prompt corresponds to the more or less conventional behavior of vanilla Emacs. But vanilla Emacs does not do this systematically for `completing-read' (or for any of the input-reading functions). Instead, it hard-codes default values into prompts in the commands that call these functions. By design, Icicles commands never add the default value to the prompt themselves. This includes Icicles versions of standard commands that might do so. Icicles instead tries to give you the choice, using option `icicle-default-value'. Function `completing-read' is the only input-reading function for which Icicles adds the default value to the prompt (for option value `t'). Other such functions, like `(icicle-)read-from-minibuffer' and `(icicle-)read-file-name', treat empty input (just `RET') specially - see their doc for details. Inserting the default value in the minibuffer as the initial input has the advantage of not requiring you to use `M-n' to retrieve it. It has the disadvantage of making you use `M-p' (or do something else) to get rid of the default value in the minibuffer if you do not want to use or edit it. If you often want to use or edit the default value, then set `icicle-default-value' to non-nil and non-t. If you rarely do so, then set it to nil or t. If the default value is inserted in the minibuffer, the value of this option also determines whether or not the inserted text is preselected, and where the cursor is left: at the beginning or end of the text. Preselection can be useful in Delete Selection mode or PC Selection mode. It makes it easy to replace the value by typing characters, or delete it by hitting `C-d' or `DEL' (backspace). However, all of the initial input is lost if you type or hit `C-d' or `DEL'. That is inconvenient if you want to keep most of it and edit it only slightly. My own preference for the option value is `insert-end', but the default value is `t', which is closest to what vanilla Emacs does. You can customize this variable. ------- If you use `t' as the value of `icicle-default-value' then you can use option `icicle-default-in-prompt-format-function' to format the text that shows the (first) default value in the prompt. The option value is a function that accepts the default value (a string) and returns a string that is prepended to the first occurrence of ": " in the prompt. This option has no effect unless `icicle-default-value' is `t'. The default value is (lambda (default) (format " (%s)" default)). ------- https://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00462.html