2

I am trying to quickly search and replace in multiple files using dired. The steps I follow are from this question (Chris Conway's and Frank Henard's answers), I am pretty sure the instructions are correct since it seems like I am the only person having this problem.

To simplify the problem, the steps I am doing are as follows:

  • Open a folder in dired
  • Mark a file with m
  • Q to search and replace in the marked file, this command will ask for two arguments, in the search query argument I type div, and in the replacement query argument I type foo (to replace div with foo).

After I do these simple steps, the search throws no results, the buffer says:

No matches for: div

I know plenty divs are spreaded all over the file. Perhaps I am not entering the arguments in the correct format, I tryed many things, like enclosing the string in quotes or double quotes, and running emacs with the -q argument in the shell to disable my dotfile. The instructions looked pretty simple, I don't know what I am doing wrong.

Emacs version: 25.1.1

  • What OS are you on? I believe this uses grep, so it may be an issue with what grep executable it is finding or what args are being passed. Also, try to reproduce this after starting with emacs with -Q (ie with the default settings, no local config.) – glucas Feb 3 '17 at 23:11
  • Fedora 25. Yes, I ran emacs with -q and -Q, the problem persists. M-x rgrep works fine, but dired's Q option doesn't. – mikl Feb 3 '17 at 23:17
  • Are your values for grep-find-ignored-files and grep-find-ignored-directories a factor? (Although they also affect rgrep.) FYI the implementation for the Q binding is completely new in Emacs 25. 24.5 runs tags-query-replace whereas 25.1 uses the new xref-collect-matches and xref-query-replace-in-results. – phils Feb 3 '17 at 23:50
  • @Drew I think you should add this as an answer instead of a comment so it can be marked as the proper answer. – Fabman Aug 9 '17 at 10:54
  • @Fabman: OK, I added it as an answer. – Drew Aug 9 '17 at 14:04
5

As @phils said in a comment, Emacs 25.1 no longer uses dired-do-query-replace-regexp for Q. It uses dired-do-find-regexp-and-replace for Q.

(It shouldn't, IMHO, but it does.)

Try M-x dired-do-query-replace-regexp. If that works, you can just bind it to Q to have Q act the same as it used to.

  • Do you know why dired-do-find-regexp-and-replace fails to find matches for regexps that work just fine with dired-do-query-replace-regexp? More than that, I'm just replacing string literals, e.g. TEST_STRING -> teststring, and it's failing to find matches. – Andy Aug 14 '17 at 17:05
  • 1
    @Andy: No, sorry; I don't know. I haven't investigated d-d-f-r-a-r. (I don't even use it, myself.) But if you have a concrete query that you think should succeed but which fails, then consider filing a bug: M-x report-emacs-bug. (For the example you mention, are you taking care of case-sensitivity? Could that be the problem?) – Drew Aug 14 '17 at 18:17
  • Finally I can search and replace using regexps that contain newlines again. Thank you! – taranaki Sep 23 at 21:27
  • @taranaki: Consider filing a bug report / enhancement request for the xref stuff, if it doesn't let you do that: M-x report-emacs-bug. – Drew Sep 23 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.