Function: projectile--process-watch-events
projectile--process-watch-events is a byte-compiled function defined
in projectile.el.
Signature
(projectile--process-watch-events PROJECT)
Documentation
Apply PROJECT's queued file-notify events to its cached file list.
Runs from the debounce timer. If any event can't be applied
incrementally the whole batch falls back to
projectile--invalidate-project-cache - correctness beats cleverness;
the cache rebuilds lazily on the next file listing, re-arming the
watches. After successful mutations the persistent cache flush is
scheduled via projectile--schedule-cache-flush.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--process-watch-events (project)
"Apply PROJECT's queued file-notify events to its cached file list.
Runs from the debounce timer. If any event can't be applied
incrementally the whole batch falls back to
`projectile--invalidate-project-cache' - correctness beats cleverness;
the cache rebuilds lazily on the next file listing, re-arming the
watches. After successful mutations the persistent cache flush is
scheduled via `projectile--schedule-cache-flush'."
(remhash project projectile--watch-debounce-timers)
(let ((events (nreverse (gethash project projectile--watch-pending-events))))
(remhash project projectile--watch-pending-events)
(when (and events (gethash project projectile--project-watches))
;; The cache entry can vanish without an invalidation (e.g. the
;; `projectile-files-cache-expire' TTL drops it directly), leaving the
;; watches orphaned. Mutating an absent cache would fabricate a bogus
;; one-file project, so just drop the watches; they re-arm when the
;; cache is next filled. A present-but-empty file list is different:
;; that project is still watched and its events still apply.
(if (eq (gethash project projectile-projects-cache 'projectile--none)
'projectile--none)
(projectile--unwatch-project project)
(let* ((mutated nil)
(projectile--watch-added-files nil)
(fallback
(catch 'projectile--watch-fallback
(dolist (event events)
(when (projectile--watch-apply-event project event)
(setq mutated t)))
nil)))
;; One question to the VCS for everything the batch added, rather
;; than one per file as the opened-file path can afford.
(when (and (not fallback)
(projectile--watch-drop-vcs-ignored
project projectile--watch-added-files))
(setq mutated t))
(cond
(fallback
(projectile--message "Invalidating the cache of %s (%s)"
project fallback)
;; Also drops the watches (and any events queued meanwhile).
(projectile--invalidate-project-cache project))
((and mutated (projectile-persistent-cache-p))
(projectile--schedule-cache-flush project))))))))