This does not speed up the file caching but it saves the manual step of having to invalidate the stale cache (which does not contain the new file).
Projectile automatically invalidates the cache if the /your/projectile/project/root/.projectile
file is newer than the project cache file.
This check is done whenever you try to find any file in the project using projectile; projectile-find-file
or C-c p f
if one of the commands that does this check first.
(defun projectile-maybe-invalidate-cache (force)
"Invalidate if FORCE or project's dirconfig newer than cache."
(when (or force (file-newer-than-file-p (projectile-dirconfig-file)
projectile-cache-file))
(projectile-invalidate-cache nil)))
- From projectile.el
source - lines 575-579
So the solution is to touch
the .projectile
file when you update the project. For example, you can alias
the git commit
, git pull
, etc to do
touch /your/projectile/project/root/.projectile`
after doing whatever you were doing with the git
commands.
So if someone in your team adds a new file to the project and (assuming you are using git to version control) you use your special aliased git pull, the cache will be invalidated automatically when you do projectile-find-file
the next time.
M-x
projectile-cache-current-file
. If you don't want to then Emacs must traverse the whole tree looking for files, so no optimizations can be made. – PythonNut Feb 9 '15 at 2:53filenotify.el
library, which I believe would allow projectile to track directory changes and consequently be informed when a new file (or directory for tracking) was created (or deleted) so that it could automatically add (or remove) the files to/from the cache. Directory notifications are not recursive, so this feature would entail independently tracking every directory in the project. I don't know whether that would incur any noticeable penalties for a large project tree. – phils Apr 12 '15 at 13:54