I understand that you are most interested in "something very nearly exactly functionally equivalent to query-replace". I don't have such an answer. I think I recall seeing something about that at some point in the last few years, so hopefully someone will give you an exact answer to your question.
Anyway, here is an answer that presents an alternative that might help.
Instead of query-replace, you can use Icicles search in a *grep*
or compilation buffer. The key C-c `
in these buffers is bound to icicle-compilation-search
, which is a specialized version of icicle-search
.
Each grep/compilation buffer hit defines a search context in the buffer it points to. You then search for text within these contexts. For grep
, for example, each context is a matching line of source code.
While you search, you can replace search hits on demand. This is unlike the case for query-replace, where you are queried for each search hit and you must answer for each one (or for all that remain, together).
This is quite different from the searching and replacing you are used to, so be aware that it takes a bit of learning.
See alsoYou should first become somewhat familiar with using Icicles in general, in particular using C-down
etc. to act on completion candidates (which for search means navigating to search hits). You should next experiment with Icicles search, including its different possibilities (see the user options that affect it). Only when you are comfortable with these things should you try on-demand replacement during search.
Read about the various user options that affect Icicles search and replace, in particular icicle-search-replace-whole-candidate-flag
, icicle-expand-input-to-common-match
, and icicle-search-replace-common-match-flag
, and icicle-search-highlight-all-current-flag
.