Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PCRE with GNU Grep and git-grep #178

Closed
wants to merge 2 commits into from
Closed

Conversation

hinrik
Copy link
Contributor

@hinrik hinrik commented Nov 26, 2017

Almost all the patterns used by dumb-jump contain non-POSIX constructs
like [\w], which work in ag and rg but not in grep/git grep unless
the -P option is used.

This was causing parts patterns to be ignored (e.g. the final parts of
most Ruby/Crystal patterns), therefore matching too many candidates
instead of finding only the correct one.

It's a remnant of the alternation which was there before the character
class. I did this by accident in commits c4b3e4b and 2965a40.
@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+0.004%) to 97.319% when pulling 04579c9 on hinrik:use_pcre into c4b3e4b on jacktasia:master.

Almost all the patterns used by dumb-jump contain non-POSIX constructs
like `[\w]`, which work in `ag` and `rg` but not in `grep`/`git grep` unless
the `-P` option is used.

This was causing parts patterns to be ignored (e.g. the final parts of
most Ruby/Crystal patterns), therefore matching too many candidates
instead of finding only the correct one.
@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+0.004%) to 97.319% when pulling 9d51240 on hinrik:use_pcre into c4b3e4b on jacktasia:master.

@jacktasia
Copy link
Owner

Thanks for the PR! As far as GNU grep this has come up before and I am still concerned about backwards compatibility. I think most people are using the more advanced searchers (ag/rg/etc) and for those stuck on grep it's hopefully just a degraded experience instead of potentially not working at all.

That said, part of me feels like supporting GNU grep is important because it's on almost every system and dumb-jump has a "just work" philosophy...and part of me feels like maybe support for grep should be deprecated entirely because of that philosophy since installing a more advanced searcher ensures a better experience. I am interested to hear the thoughts on this from anyone that might be reading this

Anyway, I'd like to keep this open for more discussion for GNU grep. It might make sense to split this into two PRs one for GNU grep and one for git-grep. Thoughts? I personally haven't run into this issue with git-grep. Have you @netromdk? Then my only concern is the tests. I haven't had a chance to look into why exactly they're failing again.

Thanks again for all your PRs!

@netromdk
Copy link
Contributor

netromdk commented Nov 26, 2017

Personally, I would rather we used all POSIX compliant regex if possible. PCRE's fine, too, but it has to be decided what flavor is used in general. The Silver Searcher uses PCRE by default and ripgrep seams to support PCRE. That means all the popular programs support PCRE and it would probably make sense to make PCRE the default.

However, the standard BSD grep on macOS doesn't support "-P". It's compatible with GNU grep but not in this regard. Should BSD grep be supported?

The test failures are, for the most part, about git-grep tests not being updated to match for "-P" instead of "-E".

@netromdk
Copy link
Contributor

@jacktasia what do you want to do with this one?

@netromdk
Copy link
Contributor

netromdk commented Dec 17, 2017

It should be tested if #188 fixed this without the need for using -P.

@jacktasia
Copy link
Owner

@netromdk I definitely think #188 will fix this:

This was causing parts patterns to be ignored (e.g. the final parts of
most Ruby/Crystal patterns), therefore matching too many candidates
instead of finding only the correct one.

since it sounds very similar to #186 but @hinrik If you get a chance to confirm or deny this. It'd be great. It probably won't get picked up by MELPA for a few more hours (from this writing). Thanks!

@jacktasia
Copy link
Owner

My understanding is #188 solves the problem that this PR was addressing so I am going to close it. Please let me know if I am wrong.

@jacktasia jacktasia closed this Jan 9, 2018
@netromdk
Copy link
Contributor

netromdk commented Jan 9, 2018

There were also removals in the ruby and crystal rules. Do they need to go in, @hinrik? Perhaps you could push only those changes then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants