@@ -1080,6 +1080,9 @@ A wrapper around `file-exists-p' with additional caching support."
10801080 (run-with-timer 10 nil 'projectile-file-exists-cache-cleanup )))
10811081 (equal value 'found )))))
10821082
1083+ (defsubst projectile-caching-persistent-p ()
1084+ (eq projectile-enable-caching 'persistent ))
1085+
10831086;;;### autoload
10841087(defun projectile-invalidate-cache (prompt )
10851088 " Remove the current project's files from `projectile-projects-cache' .
@@ -1098,7 +1101,7 @@ to invalidate."
10981101 (remhash project-root projectile-projects-cache)
10991102 (remhash project-root projectile-projects-cache-time)
11001103 ; ; reset the project's cache file
1101- (when (eq projectile-enable- caching ' persistent )
1104+ (when (projectile-caching- persistent-p )
11021105 ; ; TODO: Perhaps it's better to delete the cache file in such cases?
11031106 (projectile-serialize nil (projectile-project-cache-file project-root)))
11041107 (when projectile-verbose
@@ -1119,7 +1122,7 @@ to invalidate."
11191122The cache is created both in memory and on the hard drive."
11201123 (puthash project files projectile-projects-cache)
11211124 (puthash project (projectile-time-seconds) projectile-projects-cache-time)
1122- (when (eq projectile-enable- caching ' persistent )
1125+ (when (projectile-caching- persistent-p )
11231126 (projectile-serialize files (projectile-project-cache-file project))))
11241127
11251128(defun projectile-load-project-cache (project-root )
@@ -1140,7 +1143,8 @@ The cache is created both in memory and on the hard drive."
11401143 (if (projectile-file-cached-p file project-root)
11411144 (progn
11421145 (puthash project-root (remove file project-cache) projectile-projects-cache)
1143- (projectile-serialize project-cache (projectile-project-cache-file project-root))
1146+ (when (projectile-caching-persistent-p)
1147+ (projectile-serialize project-cache (projectile-project-cache-file project-root)))
11441148 (when projectile-verbose
11451149 (message " %s removed from cache" file)))
11461150 (error " %s is not in the cache" file))))
@@ -1178,10 +1182,11 @@ The cache is created both in memory and on the hard drive."
11781182 (puthash current-project project-files projectile-projects-cache)
11791183 ; ; we serialize the cache with an idle time to avoid freezing the UI
11801184 ; ; immediately after the new file was created
1181- (run-with-idle-timer
1182- 30
1183- nil
1184- 'projectile-serialize project-files cache-file))
1185+ (when (projectile-caching-persistent-p)
1186+ (run-with-idle-timer
1187+ 30
1188+ nil
1189+ 'projectile-serialize project-files cache-file)))
11851190 (message " File %s added to project %s cache. "
11861191 (propertize current-file 'face 'font-lock-keyword-face )
11871192 (propertize current-project 'face 'font-lock-keyword-face )))))))
0 commit comments