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

Fix grep #1371

Merged
merged 10 commits into from
Jan 16, 2019
Merged

Fix grep #1371

merged 10 commits into from
Jan 16, 2019

Conversation

jacksonrayhamilton
Copy link
Contributor

This fixes #97 as it related to grep.

find’s “-name” option never matches a path, so binding grep-find-ignored-files would never allow us to ignore such. Therefore, .projectile paths like the following would not ignore anything when grepping (except for directories unusually bearing extensions):

-/foo/bar.txt

It was only possible to ignore all files in a project with a given name, and only by specifying that name with a leading slash:

-/foo.txt

Specifying a file or directory name without a leading slash would not ignore anything:

-foo.txt
-foo/

Also, if an ignore was a path to a directory that existed from the root, then all such paths to directories in a project would be ignored. However, if the path was to a direct descendant of the root which was not a directory (or did not even exist), then all non-directory files in the project with that direct descendant’s name would be ignored, and if the path was to a 2nd-generation or later non-directory or non-existent descendant, then nothing would be ignored.

These strange cases stemmed from probable misuse of grep-find-ignored-directories, which seems to only be intended for ignoring directory names appearing anywhere, and misuse of grep-find-ignored-files, which seems to only be intended for ignoring file names appearing anywhere and without respect to parent directories. Therefore, binding ignores via grep-find-ignored-directories and grep-find-ignored-files greatly limited what could be ignored.

To ignore paths to files and to get more consistent behavior, I thought it was warranted to write a special exclusion expression supporting paths and which only ignored files and directories relative to the root. Also, to fulfill the promise of the documentation and provide support for relative paths (or patterns as I interpreted it), it was warranted to write another special exclusion expression supporting patterns occurring anywhere.

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (make test)
  • The new code is not generating bytecode or M-x checkdoc warnings I documented projectile-rgrep-default-command to the same extent as its source function, rgrep-default-command. Let me know if you’d prefer more documentation.
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Thanks for considering these changes.

This commits an implementation of rgrep-default-command which is identical to
the Emacs 25.1 one.  We will extend it in future commits.
find’s “-name” option never matches a path, so binding grep-find-ignored-files
would never allow us to ignore such.  Therefore, .projectile paths like the
following would not ignore anything (except directories unusually bearing
extensions):

-/foo/bar.txt

Currently, it’s only possible to ignore ALL files in a project with a given
name, and only by specifying that name with a leading slash:

-/foo.txt

Specifying a file or directory name without a leading slash will not ignore
anything:

-foo.txt
-foo/

Also, if an ignore was a path to a directory that existed from the root, then
all such paths to directories in a project would be ignored.  However, if the
path was to a direct descendant of the root which was NOT a directory (or did
not even exist), then all FILES in the project with that direct descendant’s
name would be ignored, and if the path was to a 2nd-generation or later
non-directory or non-existent descendant, then nothing would be ignored.

These strange cases stemmed from probable misuse of
grep-find-ignored-directories and grep-find-ignored-files, and greatly limited
what could be ignored.

To ignore paths to files and to get more consistent behavior, it was warranted
to write a special exclusion expression supporting paths and which only ignored
files and directories relative to the root.

Ignores for paths occurring anywhere (not JUST relative to the root) should
probably use the syntax without a leading slash.  Support for that will be
added in a future commit.
@bbatsov bbatsov merged commit dc02c51 into bbatsov:master Jan 16, 2019
@bbatsov
Copy link
Owner

bbatsov commented Jan 16, 2019

Thanks for working on this! I really appreciate it! 🙇

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.

ack and grep should include .projectile ignores
2 participants