4

After googling and being recommended projectile as project navigation, I ended up trying that. I'm now frustrated by the lack of tutorials and/or explanations on how it works, so I was hoping somebody here knew how to handle it. Here is my current problem:

enter image description here

I can't understand how to use the .projectile file. Now, it works in my other project, but here is just completely fails to ignore files. I've tried C-c p i to clear countless times.

How does projectile work, and why doesn't the file actually ignore those files? And as a sidenote, could anyone recommend anything more reliable than projectile, if this is just how unreliable it is?

  • 2
    As @glucas says in his solution, projectile is very very stable for me too. You just need to have it configured right. I use ag for almost any search function. So I let ag do the file list generation using this config. If you are not familiar with ag, you set the files to ignore in .agignore. The plus is that I maintain just one .agignore file that is used in regular ag searches + projectile. – Kaushal Modi Sep 28 '15 at 21:09
  • I have updated the question title. Feel free to revert it if the edit reflects a misunderstanding. – Kaushal Modi Sep 28 '15 at 21:12
5

To ignore files matching a pattern, such as files with a specific extension, you need to include a wildcard in the pattern.

For example:

-*.swp
-*.meta

There are some examples of this on the project page in Github, in the section on "Ignoring Files".

I've used Projectile daily for a while and in my experience it has always been very stable. Of course, as with any Emacs package you'll need to decide what best fits your work flow; and you may need to tweak configurations to suit your needs.

Update

From the comments, note that file ignore patterns are only working when using native indexing. This may be a bug when using alien indexing.

  • 1
    I'm not the OP, but this doesn't work for me either. The line -*.meta ignores neither the file Test.meta nor the file Test.cs.meta. I've saved the .projectile file, and invalidated the cache, and still projectile tries to find both these files. Interestingly, what does work is ignoring a specific file, as in -/whatever.txt. – zck Sep 28 '15 at 20:03
  • What version of projectile? It's also worth testing with projectile-find-file rather than helm, in case the behavior is different there. You can call projectile-find-file with a prefix arg to invalidate the cache first. – glucas Sep 28 '15 at 20:22
  • Version 20150911.844, and I'm using stock projectile-find-file. I should probably find my way over to the projectile bug tracker and see if there's something about this. – zck Sep 28 '15 at 20:25
  • 2
    Just testing a bit myself (same version). It looks like a file extension pattern ("-*.meta") is working for me with projectile-indexing-method set to 'native, but otherwise not. – glucas Sep 28 '15 at 20:33
  • I just tested it, and it was the same for me as well - it only works when set to native. On the github page they say that it's slower than alien, but I hope it's not super slow in comparison. But hey, it works! – Blobbey Sep 30 '15 at 12:53
2

You should add a "/" before your items, like:

-/.meta
-/.projectile

This is the source code:

(defun projectile-paths-to-ignore ()
  "Return a list of ignored project paths."
  (-non-nil (--map (and (string-prefix-p "/" it)
                        ;; remove the leading /
                        (substring it 1))
                   (cdr (projectile-parse-dirconfig-file)))))

We must put a "/" before the items to make them to be valid.

Also, it uses string-prefix-p to check the file. If you want to ignore the files recursively, you can replace string-prefix-p with string-match-p.

(defun projectile-remove-ignored (files)
  "Remove ignored files and folders from FILES.

Operates on filenames relative to the project root."
  (let ((ignored (append (projectile-ignored-files-rel)
                         (projectile-ignored-directories-rel))))
    (-remove (lambda (file)
               (or (--any-p (string-prefix-p it file) ignored)
                   (--any-p (string-suffix-p it file) projectile-globally-ignored-file-suffixes)))
             files)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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