1

How to ignore emacs backup (*~) files in projectile? My code does not work.

(use-package projectile
  :config
  (progn
    (setq projectile-globally-ignored-files
          (append '(
                "*.pyc"
                "*.class"
                "*~"
                )
              projectile-globally-ignored-files))
    (projectile-global-mode)
    (setq projectile-completion-system 'helm)
    (helm-projectile-on)
    (setq projectile-enable-caching t)
    (defconst projectile-mode-line-lighter " P")
    )
  )

When I call helm-projectile-find-other-file I always see backup files which is quite annoying.

1

The variable projectile-globally-ignored-files should be populated with literal filename suffixes, not glob patterns. Admittedly the variable's documentation does not make this obvious.

So your code could be rewritten as

(use-package projectile
  :config
  (setq projectile-completion-system 'helm
        projectile-enable-caching    t
        projectile-globally-ignored-files
        (append '(".pyc"
                  ".class"
                  "~")
                projectile-globally-ignored-files))
  (projectile-mode)
  (helm-projectile-on)
  (defconst projectile-mode-line-lighter " P"))

My other suggested changes to your code, as seen in my example, are the following:

  • Use projectile-mode instead of obsolete projectile-global-mode.
  • Call setq once.
  • Do not put closing parentheses on lines by themselves, as per the Emacs Coding Conventions.
  • Remove redundant progn from use-package :config clause.

By the way, is the projectile-mode-line-lighter necessary? I don't see projectile making use of it.

0

I had the same experience, finding this very confusing. Eventually, I figure out that I had to run M-x projectile-invalidate-cache for the changes to projectile-globally-ignored-* to be heeded.

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.