Function: projectile--watch-project
projectile--watch-project is a byte-compiled function defined in
projectile.el.
Signature
(projectile--watch-project PROJECT FILES)
Documentation
Register file-notify watches for PROJECT, whose cached files are FILES.
One watch per directory, into projectile--project-watches. Any
watches already registered for PROJECT are replaced. Does nothing
beyond a one-time message when the project spans more directories than
projectile-watch-directory-limit or when the platform provides no
usable file notification backend.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--watch-project (project files)
"Register file-notify watches for PROJECT, whose cached files are FILES.
One watch per directory, into `projectile--project-watches'. Any
watches already registered for PROJECT are replaced. Does nothing
beyond a one-time message when the project spans more directories than
`projectile-watch-directory-limit' or when the platform provides no
usable file notification backend."
(projectile--unwatch-project project)
(let ((dirs (projectile--watch-directories project files)))
(if (> (length dirs) projectile-watch-directory-limit)
(projectile--watch-skipped-once
project
"Not watching %s: %d directories exceed `projectile-watch-directory-limit' (%d)"
project (length dirs) projectile-watch-directory-limit)
(let ((callback (projectile--watch-make-callback project))
(failed nil)
watches)
(dolist (dir dirs)
(unless failed
(condition-case nil
(when (file-directory-p dir)
(push (cons (file-notify-add-watch dir '(change) callback)
dir)
watches))
(error (setq failed t)))))
(if (not failed)
(puthash project watches projectile--project-watches)
;; No usable backend, or the OS ran out of watches: roll back the
;; partial registration and don't retry noisily on every cache fill.
(dolist (entry watches)
(ignore-errors (file-notify-rm-watch (car entry))))
(projectile--watch-skipped-once
project
"Cannot watch %s (no file notification backend, or watch registration failed)"
project))))))