|
From: | Dmitry Gutov |
Subject: | Re: [Patch] Add project.el command to replace symbol at point throughout project |
Date: | Sun, 16 Jan 2022 05:02:35 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
On 15.01.2022 20:30, Juri Linkov wrote:
When I first let-bound `read-regexp-defaults-function` around the call to `query-replace-read-args`, it didn't work- it looks like `read-regexp` needs to be passed a symbol for its `DEFAULTS` parameter or it ignores `read-regexp-default-function`. I passed in the symbol at point to `DEFAULTS` which works- if I understand correctly the value of any I pass in doesn't end up making a difference as long as it's a symbol. I wasn't sure what the reason was for that behavior, but I didn't want to mess with stuff I didn't understand.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.
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.
[Prev in Thread] | Current Thread | [Next in Thread] |