[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#41692: 26.3; Enhancement request, `query-replace': let user use text
From: |
Drew Adams |
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) |
> > `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.
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Drew Adams, 2020/06/03
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Juri Linkov, 2020/06/03
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Drew Adams, 2020/06/03
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Juri Linkov, 2020/06/04
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Drew Adams, 2020/06/04
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Juri Linkov, 2020/06/11
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default,
Drew Adams <=
- bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default, Drew Adams, 2020/06/11