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

Grep searches ignored directories on OS X #47

Closed
bosko opened this issue Nov 5, 2012 · 11 comments
Closed

Grep searches ignored directories on OS X #47

bosko opened this issue Nov 5, 2012 · 11 comments

Comments

@bosko
Copy link

bosko commented Nov 5, 2012

Directories listed in the .projectile file are searched when "Find in project" command is executed and they should be ignored.

@mbezjak
Copy link
Contributor

mbezjak commented Nov 5, 2012

I can confirm this on Arch Linux as well.

The problem is because projectile-ignored-directories contain absolute paths when they should be relative to the current working directory. Here is what man find says about it:

Note  that  the  pattern  match test applies to the whole file name, starting from one of the
start points named on the command line.  It would only make sense to  use  an  absolute  path
name here if the relevant start point is also an absolute path.  This means that this command
will never match anything:
         find bar -path /foo/bar/myfile -print

Therefore when setting up grep-find-ignored-directories, projectile-ignored-directories should be relative to root-dir.

@mbezjak
Copy link
Contributor

mbezjak commented Nov 5, 2012

Here is a quick and dirty fix that works for me

...
(let* ((ignored-directories (mapcar (lambda (d) (replace-regexp-in-string "/$" "" (file-relative-name d root-dir))) (projectile-ignored-directories)))
       (grep-find-ignored-directories (append ignored-directories grep-find-ignored-directories)))
...)

@ignacy
Copy link

ignacy commented Nov 28, 2012

Here's a way to fix it without changing projectile. This still needs to be fixed - but untill it is, it's easier (for me) to just add files/directories to global grep ignored list, like that:

(eval-after-load "grep"
  '(progn
     (add-to-list 'grep-find-ignored-directories ".bundle")
     (add-to-list 'grep-find-ignored-directories "log")))

@bbatsov
Copy link
Owner

bbatsov commented Jan 30, 2013

I've recently done some changes that should have taken care of that particular problem. Is it still present?

@mbezjak
Copy link
Contributor

mbezjak commented Jan 30, 2013

I'm using 0.8 and it has indeed been fixed on Linux.

@bbatsov
Copy link
Owner

bbatsov commented Jan 30, 2013

And I'm using OSX and I know it's fixed there. :-)

@bbatsov bbatsov closed this as completed Jan 30, 2013
@bosko
Copy link
Author

bosko commented Jan 30, 2013

Strange. I'm using OSX and directories listed in .projectile file are still not ignored by grep. I just upgraded package thorough package manager to the version 20130129.2335. Is this version the one that has this fix?

@mbezjak
Copy link
Contributor

mbezjak commented Jan 30, 2013

It worked for me when I added leading forward slash (/) to every line. That is documented in readme: https://github.com/bbatsov/projectile#ignoring-files

I haven't tried relative pathnames, though.

@bosko
Copy link
Author

bosko commented Jan 30, 2013

I knew I made an error :) It is working with leading slash. I tried with ending slash which I thought will notify projectile that it is directory that's why it didn't work. However I think using forward slashes (without relative paths) results in a little bit strange syntax since /log associates to top level file system directory rather than subdirectory of current project. Nevertheless it is working now. Excellent!

@bbatsov
Copy link
Owner

bbatsov commented Jan 30, 2013

It's a work in progress. Luckily we're making progress (albeit slowly). :-)

@bosko
Copy link
Author

bosko commented Jan 30, 2013

Excellent work I must say. Just keep going. It would be good if it can accept relative paths because current ignore list looks quite strange if there are hidden directories. For example ./bundle directory in ignore list must be written as /.bundle. Thanks again for this fix ;-)

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

No branches or pull requests

4 participants