Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,9 @@ A wrapper around `file-exists-p' with additional caching support."
(run-with-timer 10 nil 'projectile-file-exists-cache-cleanup)))
(equal value 'found)))))

(defsubst projectile-caching-persistent-p ()
(eq projectile-enable-caching 'persistent))

;;;###autoload
(defun projectile-invalidate-cache (prompt)
"Remove the current project's files from `projectile-projects-cache'.
Expand All @@ -1098,7 +1101,7 @@ to invalidate."
(remhash project-root projectile-projects-cache)
(remhash project-root projectile-projects-cache-time)
;; reset the project's cache file
(when (eq projectile-enable-caching 'persistent)
(when (projectile-caching-persistent-p)
;; TODO: Perhaps it's better to delete the cache file in such cases?
(projectile-serialize nil (projectile-project-cache-file project-root)))
(when projectile-verbose
Expand All @@ -1119,7 +1122,7 @@ to invalidate."
The cache is created both in memory and on the hard drive."
(puthash project files projectile-projects-cache)
(puthash project (projectile-time-seconds) projectile-projects-cache-time)
(when (eq projectile-enable-caching 'persistent)
(when (projectile-caching-persistent-p)
(projectile-serialize files (projectile-project-cache-file project))))

(defun projectile-load-project-cache (project-root)
Expand All @@ -1140,7 +1143,8 @@ The cache is created both in memory and on the hard drive."
(if (projectile-file-cached-p file project-root)
(progn
(puthash project-root (remove file project-cache) projectile-projects-cache)
(projectile-serialize project-cache (projectile-project-cache-file project-root))
(when (projectile-caching-persistent-p)
(projectile-serialize project-cache (projectile-project-cache-file project-root)))
(when projectile-verbose
(message "%s removed from cache" file)))
(error "%s is not in the cache" file))))
Expand Down Expand Up @@ -1178,10 +1182,11 @@ The cache is created both in memory and on the hard drive."
(puthash current-project project-files projectile-projects-cache)
;; we serialize the cache with an idle time to avoid freezing the UI
;; immediately after the new file was created
(run-with-idle-timer
30
nil
'projectile-serialize project-files cache-file))
(when (projectile-caching-persistent-p)
(run-with-idle-timer
30
nil
'projectile-serialize project-files cache-file)))
(message "File %s added to project %s cache."
(propertize current-file 'face 'font-lock-keyword-face)
(propertize current-project 'face 'font-lock-keyword-face)))))))
Expand Down