From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Date: Tue, 25 Aug 2020 08:34:58 -0700 (PDT) Message-ID: References: <871ui48di4.fsf@mail.jurta.org> <878se2aox0.fsf@gnus.org> <87imd669dh.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25155"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dani Moncayo , Stefan Monnier , 12443@debbugs.gnu.org To: Lars Ingebrigtsen , Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 25 17:36:09 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAazY-0006Rh-Rf for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 17:36:08 +0200 Original-Received: from localhost ([::1]:50570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAazX-0001og-MH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 11:36:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAazS-0001oM-0I for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2020 11:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAazR-0008WK-NF for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2020 11:36:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kAazR-00082Y-Js for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2020 11:36:01 -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, 25 Aug 2020 15:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12443 X-GNU-PR-Package: emacs Original-Received: via spool by 12443-submit@debbugs.gnu.org id=B12443.159836971130835 (code B ref 12443); Tue, 25 Aug 2020 15:36:01 +0000 Original-Received: (at 12443) by debbugs.gnu.org; 25 Aug 2020 15:35:11 +0000 Original-Received: from localhost ([127.0.0.1]:35733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAayd-00081H-6q for submit@debbugs.gnu.org; Tue, 25 Aug 2020 11:35:11 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:36828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAaya-00080x-Cl for 12443@debbugs.gnu.org; Tue, 25 Aug 2020 11:35:10 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07PFPJOT028779; Tue, 25 Aug 2020 15:35:02 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-2020-01-29; bh=imQIZLjWMAkmQwZ+b4MRb699UoD6RDBIizwIttWldLE=; b=btmVQy3p/ucZjSIVsPDYlRshalNBmbeCoLY8rEski3hWCTwdvkt8fv+F3XYFfeWnVBPh XN+7FAlOfjFz+wBZLRv8/Fyvj6kuST2Iv117C7PXlPBJPRYkhzbL8BLpBtXRKe4w64Ee psV065WSUzgpsJI5pi31NgBnHMs12dig/aNSpz2Be2MT279W82SLhOAQ8US9vzVOI+EP aKKXtYN1Tb/8AzA3jx7fPJuuSMiRh7f2qgxviOBFFiZyJrimTmkeFoAJK2XeNJEdSM3t dDvX80FIduHBgb5VdUjh1Br1ywgJZdjMql7NfN4Y3ePaCDsiyEVzWoKALLEn0WrNMM8j mw== Original-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 333w6tssju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 25 Aug 2020 15:35:02 +0000 Original-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07PFLJNO037673; Tue, 25 Aug 2020 15:35:02 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 333r9jq2vs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Aug 2020 15:35:02 +0000 Original-Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07PFYxlX007361; Tue, 25 Aug 2020 15:34:59 GMT In-Reply-To: <87imd669dh.fsf@gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5044.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250115 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1011 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250115 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:186310 Archived-At: This is what I do in Icicles. ` icicle-handle-default-for-prompt' is called from `(icicle-)completing-read' and `(icicle-)read-string'. ;; In `(icicle-)completing-read': (setq prompt (icicle-handle-default-for-prompt prompt ;; If `insert-default-directory' then make DEF ;; in prompt relative to `default-directory'. (if (and def1 (eq icicle-default-value t) insert-default-directory) (file-relative-name def1) def1) (and (eq icicle-default-value t) ;; Include in prompt only if ;; `insert-default-directory' does not ;; insert it as input. (or (not insert-default-directory) (not (icicle-file-name-input-p)) (not (equal def1 default-directory)))))) ;; In `(icicle-)read-string': (when default-value (setq prompt (icicle-handle-default-for-prompt prompt default-value (eq icicle-default-value t)))) (defun icicle-handle-default-for-prompt (prompt default include) "Return PROMPT, possibly changed to format or remove the DEFAULT value. Argument INCLUDE: * nil means do not include DEFAULT in prompt. Remove it if there. * non-nil means include DEFAULT, formatted according to `icicle-default-in-prompt-format-function'. In the existing PROMPT before modification, recognizes inclusion of a default value according to these possible patterns: `minibuffer-default-in-prompt-regexps' \"(default ___):\" \"(default is ___):\" \" [___] \"" (when (consp default) (setq default (car default))) (dolist ; Remove the default, if already there. (rgx (if (boundp 'minibuffer-default-in-prompt-regexps) minibuffer-default-in-prompt-regexps '(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'" 1) ("\\( \\[.*\\]\\):? *\\'" 1)))) (setq prompt (replace-regexp-in-string (car rgx) "" prompt nil nil (cadr rgx)))) (if (and default include) ; Add non-nil DEFAULT, if INCLUDE. (replace-regexp-in-string ".*\\(\\): *\\'" (funcall icicle-default-in-prompt-format-function default) prompt nil t 1) prompt)) (defcustom icicle-default-in-prompt-format-function (lambda (default) (format " (%s)" default)) "Function that formats the default value to include in the prompt. The function must accept the default value (a string) as its (first) argument and return a string, which is prepended to the first occurrence of `: ' in the prompt. This option has no effect unless `icicle-default-value' is t." :group 'Icicles-Miscellaneous :type 'function)