From a80b19dd49bc588cffd9df3adc4b7581713c5cf0 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 15 Feb 2026 18:22:55 +0200 Subject: Add projectile-invalidate-all-caches command Closes #1694 Add a command that clears the file cache for all known projects at once. This is useful when using projectile-find-file-in-known-projects, where stale files from other projects could appear since projectile-invalidate-cache only clears the current project. --- projectile.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/projectile.el b/projectile.el index 6c5306b..4b40143 100644 --- a/projectile.el +++ b/projectile.el @@ -1130,6 +1130,23 @@ argument)." (when (fboundp 'recentf-cleanup) (recentf-cleanup))) +;;;###autoload +(defun projectile-invalidate-all-caches () + "Remove the cache files for all known projects." + (interactive) + (setq projectile-project-root-cache (make-hash-table :test 'equal)) + (clrhash projectile-project-type-cache) + (let ((projects (hash-table-keys projectile-projects-cache))) + (clrhash projectile-projects-cache) + (clrhash projectile-projects-cache-time) + (when (projectile-persistent-cache-p) + (dolist (project-root projects) + (projectile-serialize nil (projectile-project-cache-file project-root))))) + (when projectile-verbose + (message "Invalidated Projectile cache for all projects.")) + (when (fboundp 'recentf-cleanup) + (recentf-cleanup))) + (defun projectile-time-seconds () "Return the number of seconds since the unix epoch." (time-convert nil 'integer)) -- cgit v1.0