summaryrefslogtreecommitdiff
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2012-09-21 00:21:46 +0300
committerJuri Linkov <juri@jurta.org>2012-09-21 00:21:46 +0300
commit41a97e6fcf1cd4614a9dcd13ee843a922f3890b4 (patch)
tree6a385efb33c7d182d7bd1cf0e18dc1706290f44d /lisp/replace.el
parentc9e452d3a1e611ccd66a0c0030ef8e12d73b27c9 (diff)
downloademacs-41a97e6fcf1cd4614a9dcd13ee843a922f3890b4.tar.gz
emacs-41a97e6fcf1cd4614a9dcd13ee843a922f3890b4.tar.bz2
emacs-41a97e6fcf1cd4614a9dcd13ee843a922f3890b4.zip
* lisp/replace.el (read-regexp): Don't add ": " when PROMPT already
ends with a colon and space. Fixes: debbugs:12321
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el24
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 001f7d1a78d..2f5a9cb6bf6 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -576,10 +576,10 @@ of `history-length', which see.")
(defun read-regexp (prompt &optional default-value)
"Read regexp as a string using the regexp history and some useful defaults.
-Prompt for a regular expression with PROMPT (without a colon and
-space) in the minibuffer. The optional argument DEFAULT-VALUE
-provides the value to display in the minibuffer prompt that is
-returned if the user just types RET.
+When PROMPT doesn't end with a colon and space, it adds a final \": \".
+If DEFAULT-VALUE is non-nil, it displays the first default in the prompt.
+The optional argument DEFAULT-VALUE provides the value to display
+in the minibuffer prompt that is returned if the user just types RET.
Values available via M-n are the string at point, the last isearch
regexp, the last isearch string, and the last replacement regexp."
(let* ((defaults
@@ -595,13 +595,15 @@ regexp, the last isearch string, and the last replacement regexp."
(defaults (delete-dups (delq nil (delete "" defaults))))
;; Don't add automatically the car of defaults for empty input
(history-add-new-input nil)
- (input
- (read-from-minibuffer
- (if default-value
- (format "%s (default %s): " prompt
- (query-replace-descr default-value))
- (format "%s: " prompt))
- nil nil nil 'regexp-history defaults t)))
+ (input (read-from-minibuffer
+ (cond ((string-match-p ":[ \t]*\\'" prompt)
+ prompt)
+ (default-value
+ (format "%s (default %s): " prompt
+ (query-replace-descr default-value)))
+ (t
+ (format "%s: " prompt)))
+ nil nil nil 'regexp-history defaults t)))
(if (equal input "")
(or default-value input)
(prog1 input