From: Juri Linkov <juri@linkov.net>
To: Drew Adams <drew.adams@oracle.com>
Cc: 41692@debbugs.gnu.org
Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default
Date: Fri, 12 Jun 2020 01:58:36 +0300 [thread overview]
Message-ID: <87a719yztv.fsf@mail.linkov.net> (raw)
In-Reply-To: <39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default> (Drew Adams's message of "Thu, 4 Jun 2020 16:01:21 -0700 (PDT)")
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
>> 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':
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: query-replace-read-from-defaults.patch --]
[-- Type: text/x-diff, Size: 1372 bytes --]
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)
next prev parent reply other threads:[~2020-06-11 22:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 18:35 bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default Drew Adams
2020-06-03 22:54 ` Juri Linkov
2020-06-03 23:22 ` Drew Adams
2020-06-04 22:05 ` Juri Linkov
2020-06-04 23:01 ` Drew Adams
2020-06-11 22:58 ` Juri Linkov [this message]
2020-06-12 0:34 ` Drew Adams
2020-06-12 0:46 ` Drew Adams
2021-01-27 18:33 ` Juri Linkov
2021-01-27 18:55 ` bug#41692: [External] : " Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a719yztv.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=41692@debbugs.gnu.org \
--cc=drew.adams@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).