Closed kek closed 9 years ago
Try using the current master
, since 0.9.1 is quite outdated, and let me know if you have the same problem.
I have following contents in my .projectile
-/res
-*.png
-*.jpg
Ignore -res
works, but .png
and .jpg
file still keep show up.
projectile version: f5cccda4d3160b1f82d157baa048b8092ea1ba77
I'm seeing the same. I removed projectile, and installed from MELPA, projectile-20131120.1056
I can't get projectile to ignore relative directories, either using .projectile or projectile-globally-ignored-directories. With projectile-globally-ignored-directories, it only ignores those directories if they are in the root of the project.
I should note that this applies only when using external indexing. With native indexing, files/directories are ignored, but then I have to suffer the slowness of native indexing :-(
I'm seeing this issue also, on the latest commit 4f4ed3c1e7.
I'm on Projectile version: 0.10.0 (package: 20140330.404) and am also seeing this issue. I have -*.dat
in my .projectile, but it's still showing my data files. I've cleared the cache with projectile-invalidate-cache
and restarted Emacs but to no avail.
Same here.
Using 20140416.1040
projectile-invalidate-cache
called, still files not being ignored (f.e ace's bootstrap-theme directory is so heavy it renders find files in project unusable)
my .projectile
file:
-bootstrap-theme
-*.pyc
-__pycache__
You know what does work? Adding the files to .gitignore. Projectile won't list those. Not quite a fix, but it is a workaround.
@starenka If you're only have one bootstrap-theme dir then you could add /
in front
-/bootstrap-theme
unfortunately i can't use vcs ingore (need to be comited) neither /
trick as the dir is being collected to static dir too
I have *.png
files in my project and Projectile does not ignore them when I've set them to be ignored in the .projectile
file. I'm using the native indexing method. This is happening with the master branch with the latest commit being 2f89c17 on Nov 13, 2014.
I'm using M-x helm-projectile-grep
and results in the PNG files are showing up which is undesirable.
I'm using Emacs 24.4.1 on Ubuntu 14.10.
Thanks
@nloyola To ignore files for grepping with helm-projectile-grep/ack
, you must customize either one of these four variables:
grep-find-ignored-files
: List of file names which rgrep and lgrep shall exclude. helm-projectile-grep also uses this variable.grep-find-ignored-directories
: List of names of sub-directories which rgrep shall not recurse into. helm-projectile-grep also uses this variable.projectile-globally-ignored-files
: A list of files globally ignored by Projectile.projectile-globally-ignored-directories
: A list of directories globally ignored by Projectile.You can add to this to your init.el
:
(add-to-list 'projectile-globally-ignored-files "*.png")
Add more if you want.
Alternatively, C-h v
then type projectile-globally-ignored-files
. In the customization window, press INS
button and add "*.png", then press State
button and choose Save for future session
.
You can read the guide for helm-projectile-grep/ack/ag
EDIT: Don't put it in .projectile
files or your files won't be ignored when grepping.
Thanks for that @tuhdo. I will update my configuration.
However, PNG files are still showing up when I use M-x projectile-find-file or M-x helm-projectile-find-file.
To ignore files in those two commands you'll have to do it in .projectile file.
@tuhdo, the problem is that I've already added a wildcard for PNG files in my .projectile
file and the files are not being ignored. Maybe that was not clear in my original post.
Ah yes I remember it now. I tried to ignores files a few days ago and it did not work. Only directory ignoring works. It probably has problem with Projectile's file ignoring function.
As suggested by @tuhdo, I've added *.png
to both grep-find-ignored-files
and projectile-globally-ignored-files
, and PNG files are still showing up in my results when i use M-x helm-projectile-grep.
However, they are not showing up when I use M-x projectile-grep or M-x helm-projectile-ag.
Is this a Helm problem?
Thanks
Hmm it works for me both on Windows and Linux. I will give you a screenshot for that, but I will take a look soon.
Here are my settings:
ELISP> (message "%s" grep-find-ignored-files)
"(.#* *.o *~ *.bin *.lbin *.so *.a *.ln *.blg *.bbl *.elc *.lof *.glo *.idx *.lot *.fmt *.tfm *.class *.fas *.lib *.mem *.x86f *.sparcf *.dfsl *.pfsl *.d64fsl *.p64fsl *.lx64fsl *.lx32fsl *.dx64fsl *.dx32fsl *.fx64fsl *.fx32fsl *.sx64fsl *.sx32fsl *.wx64fsl *.wx32fsl *.fasl *.ufsl *.fsl *.dxl *.lo *.la *.gmo *.mo *.toc *.aux *.cp *.fn *.ky *.pg *.tp *.vr *.cps *.fns *.kys *.pgs *.tps *.vrs *.pyc *.pyo *.png *.odg)"
ELISP> (message "%s" projectile-globally-ignored-files)
"(TAGS GRTAGS GTAGS GPATH *.png)"
@nloyola It works on my machine. Here is a demo with just necessary packages installed, you can see the difference before and after I added *.pngt
("t" stands for "test") in projectile-globally-ignored-files
:
Could you try it again on a fresh installation similar to above?
I updated my Emacs packages today, and the problem with M-x helm-projectile-grep and PNG files no longer happens. Thanks for your help @tuhdo.
I realised this is closed, but are there any plans for helm-projectile-grep to honour .projectile? If not (which is a shame), is there a way I can specify values for vars on a per-projectile-project basis (i.e. ignore XYZ in this project but ABC in that project)?
Thanks!
I have almost the same problem as OP.
My .projectile file is:
+/Assets
-*.cs.meta
-*.unity
and with M-x projectile-find-file
I can see that +/Assets
filter works -- there is a list from that dir. But excluding doesn't work. All files are in the list.
I have the latest melpa version installed:
projectile 20151111.2318 installed Manage and navigate projects in Emacs easily
Okay, it looks like it basically works... but excluding is not nested. My previous .projectile should be written as
+/Assets
-/Assets/*.cs.meta
-/Assets/*.unity
I had the same issue with projectile
+ helm-projectile
+ persp-projectile
. It seems, that projectile's indexing method is changed implicitly by one of the extensions. I've added
(setq projectile-indexing-method 'native)
into .emacs.d/init.el
after all require
s and configurations of the projectile
and extensions. It fixes the issue for me.
Switching to the "native" indexer worked, but opening files becomes slower. If I understand correctly, projectile uses Git for it's indexing if it's not using the native method, which is why .projectile ignores are, ignored? No way to combine the two? I have files that need to be in my Git repo, but I really don't like sifting through them when searching for project files, such as dependencies.
Any help would be appreciated, thanks.
According to the documentation of projectile-indexing-method
:
The alien indexing method optimizes to the limit the speed
of the hybrid indexing method. This means that Projectile will
not do any processing of the files returned by the external
commands and you're going to get the maximum performance
possible. This behaviour makes a lot of sense for most people,
as they'd typically be putting ignores in their VCS config and
won't care about any additional ignores/unignores/sorting that
Projectile might also provide.
Is this the desired behavior or just the current behavior? It seems to me like regardless of indexing method, commands should respect the .projectile
file.
If that's the case, it shouldn't be too difficult to filter the list of files returned by the 'alien
index by the .projectile
ignore file.
Also, the documentation at https://projectile.readthedocs.io/en/latest/projects/#ignoring-files claims that
The contents of .projectile are ignored when using the alien project indexing method.
But in fact, hybrid
method also doesn't work.
hybrid mode doesn't respect .projectile neither, also i think projectile should respect .ignore file, as it became standard across search tools
@nickenchev @wpcarro Try using projectile-ripgrep
together with a .ignore
or .rgignore
file. I had this issue as well and finally set some time aside to figure out a solution and wrote it up in a blog post along with some learnings. Hope it helps 👍
I have following contents in my
.projectile
-/res -*.png -*.jpg
Ignore
-res
works, but.png
and.jpg
file still keep show up. projectile version: f5cccda
Omitting the dot worked for me inside .projectile
. Tried it with native search:
-*toc
-*jpg
-*aux
Hi @eayin2 ! I notice you downvoted my earlier comment. That's all good, but just curious, did you try my suggestion? If you ran into any issues with it, I'd love to know, since I really think ripgrep
is the best option here. I'm happy to help if you ran into any issues in getting it working - just post the details of the problem you ran into.
@countvajhula Yes, I tried it and it didn't work for me., but maybe I used it wrongly. I think with ripgrep you search through the contents of the files and not just for the file names? I usually just do C-c-p-f
and select the file I want to open, not doing something like grep -R
.
Ah you're quite right @eayin2 , I didn't realize that some of the discussion here is about the find-file
feature you're talking about rather than grep search. ripgrep
ignores would not be recognized by projectile when using the find-file feature -- the only way to get ignores working with find-file seems to be to use native indexing.
Ideally, with alien indexing, projectile should still recognize projectile-globally-ignored-files
(which @tuhdo mentioned), but it doesn't seem like it does. Until that point, a stopgap option if you're using alien indexing could be to advise the find-file feature to filter the returned list of files:
(defun my-projectile-filter-ignores (orig-fn &rest args)
(let* ((files (apply orig-fn args))
(ignores (list "/res" "\\.png"))) ; whatever regex you want to exclude
(seq-filter (lambda (f)
(let ((matches (seq-map (lambda (pat)
(string-match-p pat f))
ignores)))
(not (seq-reduce (lambda (a b)
(or a b))
matches
nil))))
files)))
Add the advice so that find-file will return the filtered results:
(advice-add 'projectile-project-files :around #'my-projectile-filter-ignores)
The advice can always be removed:
(advice-remove 'projectile-project-files #'my-projectile-filter-ignores)
Note that these are global excludes, not per-project. But of course, a proper fix here would be for projectile to recognize .projectile
excludes (or defer to a standard like .ignore
as @amfern suggested) even when using alien indexing.
I rewrote the solution given by @countvajhula to use patterns and paths defined in .projectile
files.
The function my-projectile-filter-ignores
filters the files list with patterns from projectile-patterns-to-ignore
and paths from projectile-paths-to-ignore
(theses two variables are defined by projectile from the .projectile
file):
(defun my-projectile-filter-ignores (files)
"Remove from FILES patterns defined in
`projectile-patterns-to-ignore' and paths defined in
`projectile-paths-to-ignore'.
Setting this function as advice for `projectile-remove-ignored'
permits to use rules defined in .projectile ignoring files, with
the 'hybrid' indexation method."
(let ((ignored-patterns (projectile-patterns-to-ignore))
(ignored-paths (projectile-paths-to-ignore)))
(cl-remove-if
(lambda (file)
(or (cl-some
(lambda (pattern)
(string-match-p pattern file))
ignored-patterns)
(cl-some
(lambda (dir)
(string-match-p (concat "^\\(\\./\\)+" dir "/") file))
ignored-paths)))
files)))
The function can be used as advice for projectile-remove-ignored
:
(advice-add 'projectile-remove-ignored :filter-return #'my-projectile-filter-ignores)
With this, I can use .projectile
files with the hybrid
indexation method. Without, patterns and paths ignored are not taken into account (with emacs 27.1, doom emacs 6cb2c6e96 and projectile 4d6da87).
Ignoring files doesn't seem to work. I have created a
.projectile
file in the project with the following contents:Still, when I do
projectile-find-file
, all kinds of crap from.settings
,lib_managed
andtarget
show up.I'm using version 0.9.1 on Emacs 24.3.50.1.