GNU bug report logs -
#41692
26.3; Enhancement request, `query-replace': let user use text at point as default
Previous Next
Reported by: Drew Adams <drew.adams <at> oracle.com>
Date: Wed, 3 Jun 2020 18:36:01 UTC
Severity: wishlist
Tags: fixed
Found in version 26.3
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
>> Currently `query-replace-read-from' has:
>> (if regexp-flag
>> (read-regexp prompt nil 'minibuffer-history)
>> (read-from-minibuffer
>> prompt nil nil nil nil (car search-ring) t))
>>
>> It's easy to extend `read-regexp' with more options,
>> but what to do for non-regexp case?
>>
>> Maybe to try to use `read-string' and extend it with
>> more M-n options like in `read-regexp'.
>
> I don't understand the question. `read-from-minibuffer'
> accepts a list of default values. Or maybe I don't
> understand what you mean by "more options".
Right, let's add more default values to `read-from-minibuffer':
[query-replace-read-from-defaults.patch (text/x-diff, inline)]
diff --git a/lisp/replace.el b/lisp/replace.el
index 69092c16f9..a5a5200df7 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -227,7 +227,16 @@ query-replace-read-from
(if regexp-flag
(read-regexp prompt nil 'minibuffer-history)
(read-from-minibuffer
- prompt nil nil nil nil (car search-ring) t)))))
+ prompt nil nil nil nil
+ (delq nil
+ (list
+ (when (use-region-p)
+ (buffer-substring-no-properties
+ (region-beginning) (region-end)))
+ (find-tag-default)
+ (car search-ring)
+ (car (symbol-value query-replace-from-history-variable))))
+ t)))))
(to))
(if (and (zerop (length from)) query-replace-defaults)
(cons (caar query-replace-defaults)
@@ -798,6 +807,9 @@ read-regexp-suggestions
appends the list returned by this function to the end of values available
via \\<minibuffer-local-map>\\[next-history-element]."
(list
+ (when (use-region-p)
+ (buffer-substring-no-properties
+ (region-beginning) (region-end)))
(find-tag-default-as-regexp)
(find-tag-default-as-symbol-regexp)
(car regexp-search-ring)
This bug report was last modified 4 years and 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.