Function: projectile--maybe-watch-project

projectile--maybe-watch-project is a byte-compiled function defined in projectile.el.

Signature

(projectile--maybe-watch-project PROJECT FILES)

Documentation

Arm file-notify watches for PROJECT, whose cached file list is FILES.

No-op unless both projectile-auto-update-cache-with-watches and projectile-enable-caching are non-nil. Remote (TRAMP) projects are never watched: registering one watch per directory would mean a remote round-trip each, and most remote handlers don't support file notifications anyway.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;; Automatic cache updates via file-notify watches
;;
;; Opt-in machinery (see `projectile-auto-update-cache-with-watches') that
;; keeps `projectile-projects-cache' in sync with the filesystem.  Emacs
;; file notifications are not recursive, so a watched project gets one
;; watch per directory, derived from the cached file list and bounded by
;; `projectile-watch-directory-limit'.  Events are debounced per project
;; and applied incrementally; anything that can't be applied safely falls
;; back to invalidating the project's cache, which rebuilds lazily and
;; re-arms the watches on the next cache fill.

(defun projectile--maybe-watch-project (project files)
  "Arm file-notify watches for PROJECT, whose cached file list is FILES.
No-op unless both `projectile-auto-update-cache-with-watches' and
`projectile-enable-caching' are non-nil.  Remote (TRAMP) projects are
never watched: registering one watch per directory would mean a remote
round-trip each, and most remote handlers don't support file
notifications anyway."
  (when (and projectile-auto-update-cache-with-watches
             projectile-enable-caching
             (not (file-remote-p project)))
    (projectile--watch-project project files)))