bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Juri Linkov
Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default
Date: Thu, 04 Jun 2020 01:54:47 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> If you want to default the FROM or TO text for `query-replace' to some
> text at point, you currently need to first isearch for it.  This request
> is essentially to be able to skip doing that.
>
> As an example (only), in my own code, my version of
> `query-replace-read-from' can get the default any of these ways:
>
> * Text of nonempty active region, if option
>   `search/replace-region-as-default-flag' is non-nil.
>
> * Text of secondary selection, if option
>   `search/replace-2nd-sel-as-default-flag' is non-nil.
>
> * What the (function) value of option `search/replace-default-fn'
>   returns, when called.  This defaults to a function that grabs text at
>   point.  (If the function returns a list of strings, then those are the
>   multiple default values.)
>
> (As with vanilla query-replace, you can also use the history lists,
> and you can enter nothing to repeat the previous query replacement
> operation.)
>
> I don't say that vanilla Emacs should do all of that.  But maybe at
> least something like the third one - a function that returns a string or
> list of strings to be used as default values, and with, as its default
> value, a function that grabs some text at point.

query-replace-regexp already does all the above.  It provides text
at point for first M-n, the last search string for the second M-n, etc.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]