0

It seems promising to have a built-in function that performs this action: find and replace all matching text recursively, within your project.

The problem is that it doesn't seem consistent. I am working on a python project that I do not have permission to share, but within the project the function is not idempotent. It will go to different depths on different calls, usually exiting early, the depth of which is usually dependent on which file I call it from. Although, in the mini-buffer it shows parsing of files starting at the parent directory, which I'd expect; it shouldn't matter where you call it from and according to the mini-buffer it doesn't seem to. The number of found matches I'm brought to says otherwise.

I have since had to download projectile and even after a good run of M-x project-query-replace-regexp RET, projectile will still find leftover text to replace that I did not skip over intentionally.

Any ideas on why I experience this behavior or how to improve it. I'd rather rely on a built-in than external dependencies. Plus, I only need this feature from projectile, so it's a waste to download an additional package for something I "already have".

I apologize for not having a concrete example to share. If I find this problem in a personal repo, I will fortify the question. I have not had time away from my responsibilites to test further.

Documented here.

Edit:
Oddly, I just ran into the same issue with projectile. Does it matter what file you start from?

5
  • 1
    Did you try M-x fileloop-continue when you find an incomplete replacement? You may have somehow exited the query-replace early? And I don't know how project decides how a file belongs to a project: maybe the "missed" files are not part of the project and need some action to be added?
    – NickD
    Oct 29, 2021 at 19:36
  • 1
    It should not matter which file you start with. Anyway, if you're having problems with this command, try M-x report-emacs-bug. IIUC there are not too many users of this command, so without reports some bugs might indeed be lurking around.
    – Dmitry
    Oct 29, 2021 at 21:23
  • You don't specify the problem; you talk around it ("It will go to different depths on different calls, usually exiting early, the depth of which is usually dependent on which file I call it from."). Don't just link to some external description of the problem. Please consider providing a step-by-step recipe, starting from emacs -Q (no init file), to repro the problem, saying what you do at each step, what you see then, and what you expected/wanted to see instead.
    – Drew
    Oct 31, 2021 at 16:41
  • @NickD I'll give it a shot next time it comes up!
    – mcp
    Oct 31, 2021 at 20:42
  • 1
    @Dmitry will do!
    – mcp
    Oct 31, 2021 at 20:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.