3

I recently updated to emacs 26.1. Since then, grep results are not highlighted and does not contain links to files. 'n' or 'p' gives "Moved past last grep hit" or "Moved back before first grep hit".

Steps followed:
1. Ran emacs 26.1 with -Q option
2. Set the following variables:
(setq explicit-shell-file-name "C:/cygwin/bin/bash.exe")
(setq shell-file-name explicit-shell-file-name)
(add-to-list 'exec-path "C:/cygwin/bin")
(setq null-device "/dev/null")
3. grep -nHri --include=*.m -e "hello" c:/path/to/dir

Couldn't visit the files in the search results.

The same steps work in 25.2 version. In both versions, grep returns search results in windows path format (c:/path/to/dir/...)

8
  • 1
    Welcome to emacs.stackexchange.com. Can you give us a minimal setup recipe to reproduce this issue ourselves using Emacs 26.1 without any user configuration? This is called starting from Emacs -Q.
    – lawlist
    Oct 8, 2018 at 21:58
  • ...which is to say, run emacs -Q at the command line.
    – phils
    Oct 8, 2018 at 23:54
  • Thank you, @lawlist. I am using emacs for windows. Downloaded from here. I open by double clicking on the exe file.
    – Aravind
    Oct 9, 2018 at 4:26
  • @phils, I don't use command line to run emacs. How do I run emacs with -Q from windows?
    – Aravind
    Oct 9, 2018 at 4:48
  • 1
    Can you add output from that grep command to your question? I'm assuming this is related to using cygwin and using a mingw build of Emacs, which use different formats for paths.
    – user12563
    Oct 9, 2018 at 10:01

2 Answers 2

2

This is an emacs bug in emacs 26.1, resolved in 26.2. It has to do with —null being added to the default grep arguments, so the drive letter in Windows paths, with its colon, was not matched by the grep regexp. You can either upgrade to the unreleased version, or customize the grep arguments to remove —null.

1
  • My grep command looks like this: grep -nHir --include=*.m --exclude=*.svn-base "hello" c:/path/to/dir/. I have the following setup: (grep-use-null-device nil) and (grep-use-null-filename-separator nil). The results don't have links to files. Am I missing something?
    – Aravind
    Oct 11, 2018 at 20:41
0

Adding -Z option (-Z, --null: print 0 byte after FILE name) to grep command fixes the issue.

grep -nHirZ --include=*.m --exclude=*.svn-base "hello" c:/path/to/dir

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.

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