bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12443: 24.2.50; Default values in the minibuffer prompt (fix


From: Basil L. Contovounesios
Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix
Date: Sun, 17 Jan 2021 19:05:06 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lars Ingebrigtsen <larsi@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?

>From 3d3423ef6705cf157e279c95e5eb8a35b8ca78fb Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@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

-- 
Basil

reply via email to

[Prev in Thread] Current Thread [Next in Thread]