Emacs find-grep grep

I am trying to make grep from the result of emacs find-grep, so I use the following command:

find ... | xargs ... | grep -v enable

The result shows I have a grep buffer, but when I press enter on every entry trying to go to this file, emacs says that the file does not exist. On the minibuffer, the [[K] character is in front of the full file path. This basically makes the file name invalid. I looked through the grep manual, but I don’t know what I can do about it.

I probably don't need to do this, but I'm just not sure how to pass two patterns, one for grep and the other for inverting grep. (Could be a regular expression?)

Anyone have any suggestions on this?

Decision:

I did this on a Cento 5.5 machine. Turns out this is a problem due to the old version of grep. I installed the latest version of grep in my home directory, and now everything is fine.

+4
source share
2 answers

After debugging a problem using comments, this is a solution that should work for you. Add it to your .emacs and configure it so that the regular expression matches the special characters you want to remove from the file name: ^[[K

 (defadvice compilation-find-file (before compilation-find-file-strip-odd-chars activate) "Strip the ^[[K in the input string" (let ((filename (ad-get-arg 1))) (save-match-data (when (string-match "^\\[\\[K" filename) (ad-set-arg 1 (replace-match "" nil nil filename)))))) 
+2
source

I had the same problem, but I could not change my version of grep, so I used a workaround. The problem seemed to be ending the greps line so I just run the grep results through awk and print them as is.

 ... | grep -v blaa | awk '{print $0}' 

This fixes the problem for me, although I don't know why.

0
source

Source: https://habr.com/ru/post/1346292/


All Articles