GNU bug report logs - #12443
24.2.50; Default values in the minibuffer prompt (fix

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Fri, 14 Sep 2012 14:08:01 UTC

Severity: minor

Found in version 24.2.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Juri Linkov <juri <at> jurta.org>, Dani Moncayo <dmoncayo <at> gmail.com>, Stefan Kangas <stefankangas <at> gmail.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>, 12443 <at> debbugs.gnu.org
Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix
Date: Sun, 17 Jan 2021 19:05:06 +0000
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> OK, the first sweep has now landed on master (I basically grepped for
> " (default %" and then did the changes.  Boy, were there many different
> ways to "optionally add some defaults" in the code...
>
>  78 files changed, 316 insertions(+), 453 deletions(-)
>
> Look at all the lines saved!  :-)
>
> There's also some of the prompting functions that have some support for
> this general idea, but in different ways:
>
> (defun read-regexp (prompt &optional defaults history)
> [...]
> 	 (input (read-from-minibuffer
> 		 (cond ((string-match-p ":[ \t]*\\'" prompt)
> 			prompt)
> 		       ((and default (> (length default) 0))
> 			 (format "%s (default %s): " prompt
> 				 (query-replace-descr default)))
> 		       (t
> 			(format "%s: " prompt)))
> 		 nil nil nil (or history 'regexp-history) suggestions t)))

Any reason this function wasn't changed in the end?

[0001-Use-format-prompt-in-read-regexp.patch (text/x-diff, inline)]
From 3d3423ef6705cf157e279c95e5eb8a35b8ca78fb Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Date: Sun, 17 Jan 2021 18:56:50 +0000
Subject: [PATCH] Use format-prompt in read-regexp.

* lisp/replace.el (read-regexp): Use format-prompt (bug#12443).
---
 lisp/replace.el | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index d41dc98a0d..8f8cbfac54 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -866,13 +866,10 @@ read-regexp
 	 ;; Do not automatically add default to the history for empty input.
 	 (history-add-new-input nil)
 	 (input (read-from-minibuffer
-		 (cond ((string-match-p ":[ \t]*\\'" prompt)
-			prompt)
-		       ((and default (> (length default) 0))
-			 (format "%s (default %s): " prompt
-				 (query-replace-descr default)))
-		       (t
-			(format "%s: " prompt)))
+                 (if (string-match-p ":[ \t]*\\'" prompt)
+                     prompt
+                   (format-prompt prompt (and (length> default 0)
+                                              (query-replace-descr default))))
 		 nil nil nil (or history 'regexp-history) suggestions t)))
     (if (equal input "")
 	;; Return the default value when the user enters empty input.
-- 
2.29.2

[Message part 3 (text/plain, inline)]
-- 
Basil

This bug report was last modified 4 years and 123 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.