4

After installing ack on Windows 7 64-bit (e.g. using StrawberryPerl), I can run ack from a cmd terminal in Windows.

However, if I try using ack in Emacs in Shell mode (i.e. in a M-x shell buffer), I get not output (all other cmd commands print correctly though).

Interestingly, if I run ack alone - i.e. with no arguments-, I get the ack usage information printed correctly. In other words, ack prints no output in my Emacs shell when I run it with arguments (even though ack should print hits for my queries, as I have checked under cmd).

The lack of output makes me think that ack is waiting for input (although I provide arguments to it). I tried the code snippet suggested here in my .emacs file (which seems to be designed to help ack when it's confused between searching in the file system or STDIN), but the problem still persists.

Any suggestions on how to fix this?

Thanks

Community
  • 1
  • 1
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
  • There are some Windows programs that don't use the console normally. The Windows builtin ftp is one of them. See http://stackoverflow.com/questions/2537180/why-i-cannot-get-the-output-of-ftp-exe-by-code/2564801#2564801 It may be that ack does something similar. – Cheeso Dec 27 '10 at 17:05
  • This may answer your question: http://stackoverflow.com/questions/2322389/ack-does-not-work-when-run-from-grep-find-in-emacs-on-windows – Cheeso Dec 27 '10 at 17:06
  • @Cheeso I am not sure this is the case. As I understood from the linked answer the program might just not flush it's buffers. But what is the reason that the gdb output from MinGW sometimes not printed *only* in the Emacs shell, but works correctly in pure «cmd.exe». More over: I am debugging a program that had no a problem with output under GNU/Linux(and have no on Windows with «cmd.exe» either), but in the emacs shell the output printed only after the program die. I am sure that user815423426's problem is likely to be the same. – Hi-Angel Sep 24 '14 at 10:15

2 Answers2

2

ack is waiting on stdin, incorrectly thinking it is in filter mode. As a workaround, add <NUL to the end of the command, closing its stdin.

FYI - Running "ack" in the perl debugger, inside emacs shell on Windows, shows it stopping here:

main::print_matches_in_resource(c:/Strawberry/perl/site/bin/ack:454):
454:            while ( <$fh> ) {
Yary
  • 325
  • 2
  • 7
  • 1
    Excellent find! To accommodate this with `ack.el` or similar, stuff `--no-filter` into ack's default arguments – mike3996 Jul 11 '16 at 12:10
1

Have you checked ack.el?

That's what I use on Windows 7. It makes using ack easier. By default it suggests searching for the word at point. And you get the output through compile, so you can easily jump to the file and line containing the match.

simon
  • 93
  • 1
  • 9