Subject: 26.3; Enhancement request, `query-replace': let user use text at point as default

From: Drew Adams <[email-masked]>
Date: Wed, 3 Jun 2020 11:35:41 -0700 (PDT)

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.

In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.18362
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''