Function: projectile-cache-current-file
projectile-cache-current-file is an autoloaded, interactive and
byte-compiled function defined in projectile.el.
Signature
(projectile-cache-current-file)
Documentation
Add the currently visited file to the cache.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
;;;###autoload
(defun projectile-cache-current-file ()
"Add the currently visited file to the cache."
(interactive)
(let ((current-project (projectile-project-root)))
(when (and (buffer-file-name)
(file-exists-p (buffer-file-name))
(gethash current-project projectile-projects-cache))
(let* ((abs-current-file (file-truename (buffer-file-name)))
(current-file (file-relative-name abs-current-file current-project)))
(unless (or (projectile-file-cached-p current-file current-project)
(projectile-ignored-directory-p (file-name-directory abs-current-file))
(projectile-ignored-file-p abs-current-file))
(let ((project-files (cons current-file (gethash current-project projectile-projects-cache)))
(cache-file (projectile-project-cache-file current-project)))
(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
(when (projectile-persistent-cache-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)))))))