5

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?

  • 1
    For grepping, there's helm-grep-ignored-files and helm-grep-ignored-directories. There's nothing like that for helm-find-files. – Tianxiang Xiong Jan 25 '17 at 23:08
  • Thanks for letting me know--if you post that as an answer I'll mark the question as resolved. – tcelferact Jan 25 '17 at 23:48
3

This 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.

| improve this answer | |
6

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 in helm-find-files and file completion used by helm-mode i.e helm-read-file-name.

And the documentation for helm-boring-file-regexp-list says that by default it is built from completion-ignored-extensions.

| improve this answer | |
  • This is just what I needed. I suspect if one really wanted there would be a way to append or replace those entries from your .gitignore. However, this for me more than suffices. – cammil Mar 19 at 11:27
1

For grepping, there's helm-grep-ignored-files and helm-grep-ignored-directories. There's nothing like that for helm-find-files.

| improve this answer | |
1

search that respects ignored dirs/files:

  1. install ack (An alternative to grep. I install via homebrew.)

  2. put --ignore-case in your ~.ackrc file (assuming you want to ignore case)

  3. 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)
        )
  ...
)
  1. create a .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
| improve this answer | |
0

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))
  )
| improve this answer | |

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.