From: Drew Adams <drew.adams@oracle.com>
To: Juri Linkov <juri@linkov.net>
Cc: 41692@debbugs.gnu.org
Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default
Date: Thu, 11 Jun 2020 17:34:21 -0700 (PDT) [thread overview]
Message-ID: <355c8fb7-2113-44c4-acdd-cbbf02d3828b@default> (raw)
In-Reply-To: <87a719yztv.fsf@mail.linkov.net>
> > `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'
Yes, but not in a hard-coded way. What I'd suggest
instead:
Provide a user option, to let users choose the list
of default sources (and thus also their order).
The option value could be a `repeat' of a `choice'
among: (1) nonempty active region, (2) secondary
selection, (3) result of calling the function that's
the value of a predefined option, (4) the most recent
entry in the query-replace history variable - and
whatever else you want to include.
#1-4 are what I use in my code.
Both my code and your code provide a hard-coded list.
But letting a user choose the list is better.
Your list includes `(find-tag-default)' and the first
entry of `search-ring'. And your list doesn't include
the secondary selection or the result of funcalling
a function-valued variable (option).
I don't have a problem with your adding more choices
to the default value of the list option.
I do mind that you've removed those two (second sel
and function) from your list. It's especially
important to include a funcallable option value.
So the two changes I'd like to see to your code are:
(1) add an option that lets users specify a list of
sexps to evaluate to provide the list of default
values, and (2) include secondary selection and
(especially) a function-valued user option among the
list-element `choice's.
But another consideration: `query-replace-read-from'
is used for several kinds of query-replacing,
including for `query-replace-regexp'. For that
command, `regexp-search-ring', is more appropriate
than `search-ring'.
The option value `choice' could thus include, not a
hard-coded `search-ring', but a variable value, so
`query-replace-regexp' could bind that variable to
`regexp-search-ring', and `query-replace' could bind
it to `search-ring'.
IOW:
* One option for a user-chosen list of sources of
default values. Easy for a user to order the
list, make it smaller, and change any of the
choices that use a variable.
* One function-valued option, for a user-chosen
function, to be funcalled with no args to produce
a default value.
* One defvar whose value is used as a default value.
I'd actually prefer a user option for the last one
(the defvar), but I know that vanilla Emacs doesn't
like to let a command bind a user option.
next prev parent reply other threads:[~2020-06-12 0:34 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
2020-06-12 0:34 ` Drew Adams [this message]
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=355c8fb7-2113-44c4-acdd-cbbf02d3828b@default \
--to=drew.adams@oracle.com \
--cc=41692@debbugs.gnu.org \
--cc=juri@linkov.net \
/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).