There are certain files I never access from Helm, such as those in my global .gitignore file:
# Emacs backup files #
##############################
*~
*#
etc.
Is there any way of telling Helm to ignore these files?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityThis doesn't exactly answer your question directly, but if you are working on something Projectile recognizes as a project, you could try using helm-projectile-find-file
instead of helm-find-files
. The functionality is rather different (it searches all file names and paths in the project simultaneously, rather than letting you navigate to individual directories in the project), but it does have the benefit that it understands and uses .gitignore
files.
I'm not sure when this functionality was introduced, but you can exclude files from helm-find-files
by setting helm-ff-skip-boring-files
to t
and making sure the ignored pattern is on helm-boring-file-regexp-list
. From its documentation:
Non--nil to skip files matching regexps in
helm-boring-file-regexp-list
. This take effect inhelm-find-files
and file completion used byhelm-mode
i.ehelm-read-file-name
.
And the documentation for helm-boring-file-regexp-list
says that by default it is built from completion-ignored-extensions
.
For grepping, there's helm-grep-ignored-files
and helm-grep-ignored-directories
. There's nothing like that for helm-find-files
.
search that respects ignored dirs/files:
install ack
(An alternative to grep. I install via homebrew.)
put --ignore-case
in your ~.ackrc
file (assuming you want to ignore case)
bind helm-projectile-ack
to a key. I do this in my emacs init via:
(use-package helm
...
:bind (...
("C-c p s a" . helm-projectile-ack)
)
...
)
.projectile
file. E.g.,-.dot
-.jcs
-.svg
-.txt
use
C-c p s a ;; search that respects .projectile ignore
or
C-c s p g ;; search everything
Just to add something in relation to using grep type searching and ignoring/including that might be a help. I use this (and it can be used with git-grep and similar if you locate the correct flags):-
(defun helm-projectile-ag-search-all()
(interactive)
(let((helm-ag--extra-options "--skip-vcs-ignores"))
(helm-projectile-ag)))
(defun helm-projectile-rg-search-all()
(interactive)
(let((helm-rg--extra-args "--no-ignore-vcs"))
(helm-projectile-rg)))
ie override the default behaviour and do indeed search vcs ignored files... one key bound to helm-projectile-rg directly and the S-thatkey to helm-projectile-rg-search-all.
M projectile use-package is:-
(use-package
projectile
:demand t
:config
(use-package
helm-projectile
)
(defun helm-projectile-ag-search-all()
(interactive)
(let((helm-ag--extra-options "--skip-vcs-ignores"))
(helm-projectile-ag)))
(defun helm-projectile-rg-search-all()
(interactive)
(let((helm-rg--extra-args "--no-ignore-vcs"))
(helm-projectile-rg)))
(helm-projectile-on)
(projectile-global-mode)
:bind ("<f2>" . 'projectile-dired)
("<f3>" . 'helm-projectile-rg)
("S-<f3>" . helm-projectile-rg-search-all)
("<f4>" . 'helm-projectile-find-file-dwim)
("<f5>" . 'helm-projectile-switch-to-buffer)
(:map projectile-mode-map ("C-c p" . projectile-command-map))
(:map projectile-command-map ("o" . helm-multi-swoop-projectile))
(:map projectile-command-map ("g" . helm-git-grep))
)
helm-grep-ignored-files
andhelm-grep-ignored-directories
. There's nothing like that forhelm-find-files
.