2

Leaving question here for reference. The Lord alone knows why, but whereas once upon a time this didn't work for me, prompting me to ask this question, today it does. Typical bloody emacs. Also typically, it is an utter joy once you've wrestled with it a bit. YMMV.

These two commands:

find ~/myco -type f -print0 | xargs -0 -e grep -nH -e "setjmp"

and

ack --no-heading --no-color "setjmp" ~/myco

Seem to me to produce very similar results at the terminal.

And yet when I try to use the second as the command with M-x find-grep in emacs, it just prints the results, rather than hyperlinking and highlighting them as it would with the first.

Anyone know what is happening? Initial experiments with ack at the command line indicate that it blows find and grep out of the water, so it would be nice to be able to use it from emacs too.

John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110

3 Answers3

3

On windows I call ack from find-grep e.g. like this:

c:/xampp/perl/bin/perl.exe c:/bin/ack-standalone.txt --type-set java=.java --type=java -i information

and it's working perfectly. The results are linked and colored in the grep buffer. I don't know why it doesn't work for you, but I can say it does work here.

emacs version: GNU Emacs 23.2.1

ack version: 1.94

Tom
  • 7,515
  • 7
  • 38
  • 54
1

Emacs tries to show the output of find-grep in a buffer in grep-mode. Apparently grep-mode (surprise, surprise) doesn't understand the output format of ack. Use a dedicated ack-mode.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • Well, I haven't downvoted you, but the two commands seem to produce identical results at the console, so the question is *why* doesn't grep-mode understand. Thanks for the link to ack-mode though, I'll give it a try. – John Lawrence Aspden Oct 19 '11 at 15:26
  • @JohnLawrenceAspden I just found a similar question http://stackoverflow.com/questions/2322389/ack-does-not-work-when-run-from-grep-find-in-emacs-on-windows Others suggest that `grep-mode` should work with ack. I'd rather be on the safe side and go for the easy solution. :) – pmr Oct 19 '11 at 15:48
  • This answer isn't useful. It works perfectly for me too, so much that I'm now switching from "ack-mode" to "find-grep"! Must me some problem with the specific ack and emacs versions. – joao Oct 20 '11 at 13:34
  • Ooops It is not quite so.... sorry for the downvote (can't take it back). On Windows it works almost perfectly, since the match itself isn't highlighted. In Linux it only seems to work if you open the ack output in a buffer and apply grep-mode to it explicitly. – joao Oct 20 '11 at 13:43
  • @JoaoTavora You can take back downvotes. Just click on the downvote button again. Anyway, I tried to point out in the comment that this might be a windows problem. – pmr Oct 20 '11 at 14:16
0

I found this ack-mode to work better, and out of the box. Some more coloring would have been nice, but at least it's readable:

https://github.com/sudish/ack-mode.el

Gauthier
  • 40,309
  • 11
  • 63
  • 97