This is needed to handle `read-regexp` in `occur-read-primary-args`
that uses the symbol `regexp-history-last` by default.
occur?
read-regexp is called from query-replace-read-from.
Binding read-regexp-defaults-function doesn't seem to work because its use
is for some reason predicated on (and defaults (symbolp defaults))
evaluating to non-nil.
And 'read-regexp' is called with nil second argument.
The customizable user option 'read-regexp-defaults-function' was created
for the following problem: by default, 'occur' uses the last history item
as the default value, so 'read-regexp-defaults-function' could be
customized to get a tag at point as the default value of 'occur'.
Exactly the same situation is with 'query-replace-read-from':
by default, it uses the last history item, so changing the value of
'read-regexp-defaults-function' should also affect the query-replace
like in the patch that I sent to Jon.
Before finishing this implementation, please answer one question.
`query-replace-read-from` uses two minibuffer-reading functions:
(if regexp-flag
(read-regexp prompt sym-at-point 'minibuffer-history)
(read-from-minibuffer
prompt nil nil nil nil
(query-replace-read-from-suggestions) t))
Do you think the same default with the symbol at point
should be used for the non-regexp case with read-from-minibuffer as well?
If yes, then we need a different solution that works for both cases.
It doesn't have to be the same. project-query-replace-regexp could bind
read-regexp-defaults-function, and xref-find-references-and-replace could
bind something else. But that variable still needs to be created.
xref-find-references-and-replace calls query-replace-read-args
with a non-regexp flag, so I have no idea what new variable
could be created for read-from-minibuffer.