emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] Add project.el command to replace symbol at point throughout


From: Dmitry Gutov
Subject: Re: [Patch] Add project.el command to replace symbol at point throughout project
Date: Wed, 12 Jan 2022 05:42:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

Hi!

On 11.01.2022 09:45, Jon Eskin wrote:
Attached is a small patch adding command 'project-query-replace-at-point' to project.el. The command is designed to improve the ergonomics of making a project wide text replacement of a symbol at point.

Currently, if you want to make a project wide replacement of a symbol using project.el, the best options I've found are:

or

- Mark the symbol you wish to replace
- Save symbol to kill ring with 'kill-ring-save'

You don't need these two steps, do you? Just do the rest, and it should work.

- Place cursor on symbol and enter command 'project-find-regexp'
- Hit return at the next prompt to accept the default prompt
- Enter command 'xref-query-replace-in-results'
- Enter the replacement string and hit return

I agree it could use some more optimization still.

'project-query-replace-at-point' regex-quotes the symbol at point and then calls into the fileloop-initialize-replace function used by the existing project-query-replace-regexp command.

Replacing a symbol with 'project-query-replace-at-point' occurs as follows:

- Place cursor on symbol and enter command 'project-query-replace-at-point'
- Enter the replacement string and hit return

Let me know what you guys think. I haven't contributed before so please let me know if I'm doing anything incorrectly.

If we're trying to improve project-query-replace-regexp, why not make it use the symbol at point by default?

You would use the same command, but would be able to press RET to have the default regexp (symbol at point) used as FROM. I don't have a patch yet, but it might be something that all callers of query-replace-read-args might benefit from.

And you can actually do this right now:

- Enter command 'project-query-replace-regexp'
- Press M-n, having the symbol at point picked up as FROM, hit return
- Enter the replacement string and hit return



reply via email to

[Prev in Thread] Current Thread [Next in Thread]