unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Juri Linkov <juri@linkov.net>
Cc: Jon Eskin <eskinjp@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: [Patch] Add project.el command to replace symbol at point throughout project
Date: Mon, 17 Jan 2022 02:19:50 +0200	[thread overview]
Message-ID: <921c0b69-7bac-b78a-54d8-987165331661@yandex.ru> (raw)
In-Reply-To: <86czkr36ll.fsf@mail.linkov.net>

On 16.01.2022 19:58, Juri Linkov wrote:
>>> 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.

The patch works for project-query-replace-regexp but not for 
xref-find-references-and-replace, which still doesn't suggest the symbol 
at point as FROM (BTW, in the final version this function should 
probably use #'find-tag-default rather than 'find-tag-default-as-regexp).

>>> 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.

I don't really have a preference as to how the implementation is 
organized, as long as it all works.

As far as I'm concerned, it might as well use 
read-regexp-defaults-function. But the implementation is made more 
complicated by the fact that read-regexp and read-from-minibuffer treat 
their PROMPT and DEFAULTS arguments differently.

E.g. the latter won't return DEFAULT-VALUE on empty input and won't 
format the prompt. If I use read-string instead, it uses the default 
value instead of empty input, but does not format the prompt still.

> It already uses
> 'query-replace-read-from-suggestions' where the top value
> could be the default.

That would affect all callers of query-replace-read-from, wouldn't it? 
I'm not sure, but a conservative approach (which we often take here) 
would be to try to avoid that.



  reply	other threads:[~2022-01-17  0:19 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11  7:45 [Patch] Add project.el command to replace symbol at point throughout project Jon Eskin
2022-01-11  7:51 ` Manuel Uberti
2022-01-11  9:50   ` Jon Eskin
2022-01-12  3:43     ` Dmitry Gutov
2022-01-12  9:42       ` Jon Eskin
2022-01-13  1:03         ` Dmitry Gutov
2022-01-13  9:57           ` Jon Eskin
2022-01-14  2:39             ` Dmitry Gutov
2022-01-11 13:10 ` Eli Zaretskii
2022-01-11 15:15   ` Daniel Martín
2022-01-11 17:17     ` Eli Zaretskii
2022-01-12  3:46   ` Dmitry Gutov
2022-01-12 12:45     ` Eli Zaretskii
2022-01-13  1:19       ` Dmitry Gutov
2022-01-13  8:25         ` Eli Zaretskii
2022-01-14  2:43           ` Dmitry Gutov
2022-01-14  7:46             ` Eli Zaretskii
2022-01-14 10:26             ` Jon Eskin
2022-01-14 20:28               ` Dmitry Gutov
2022-01-15  9:55                 ` Jon Eskin
2022-01-15 18:30                   ` Juri Linkov
2022-01-16  3:02                     ` Dmitry Gutov
2022-01-16 17:58                       ` Juri Linkov
2022-01-17  0:19                         ` Dmitry Gutov [this message]
2022-01-17  1:15                           ` Dmitry Gutov
2022-01-17  8:17                             ` Juri Linkov
2022-01-21  3:06                               ` Dmitry Gutov
2022-01-31 18:25                                 ` Juri Linkov
2022-02-01  2:10                                   ` Dmitry Gutov
2022-02-01 20:09                                     ` Juri Linkov
2022-02-01 22:07                                       ` Dmitry Gutov
2022-02-02 19:51                                         ` Juri Linkov
2022-02-02 21:09                                           ` Dmitry Gutov
2022-01-15 18:41                   ` Jon Eskin
2022-01-16 17:55                     ` Juri Linkov
2022-01-17  1:41                   ` Dmitry Gutov
2022-01-17  6:36                     ` Jon Eskin
2022-01-12  3:42 ` Dmitry Gutov
2022-01-12  8:03   ` Jon Eskin
2022-01-12 19:43     ` Dmitry Gutov
2022-01-12 19:56       ` Juri Linkov
2022-01-12 22:12         ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=921c0b69-7bac-b78a-54d8-987165331661@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=eskinjp@gmail.com \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).