Function: projectile--locate-dominating-file
projectile--locate-dominating-file is a byte-compiled function defined
in projectile.el.
Signature
(projectile--locate-dominating-file FILE NAME FIRST-MATCH-ONLY)
Documentation
Walk up from FILE looking for NAME and return the matching directory.
NAME is either a filename (matched via projectile-file-exists-p in
each candidate directory) or a predicate of one argument (the candidate
directory).
When FIRST-MATCH-ONLY is non-nil, return the bottommost (closest to FILE) match; otherwise keep walking and return the topmost match. Returns nil when no match is found.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--locate-dominating-file (file name first-match-only)
"Walk up from FILE looking for NAME and return the matching directory.
NAME is either a filename (matched via `projectile-file-exists-p' in
each candidate directory) or a predicate of one argument (the candidate
directory).
When FIRST-MATCH-ONLY is non-nil, return the bottommost (closest to
FILE) match; otherwise keep walking and return the topmost match.
Returns nil when no match is found."
;; The walk skeleton was originally copied from files.el; the bottom-up
;; / top-down split was previously two near-identical functions.
(setq file (abbreviate-file-name file))
(let ((root nil)
try)
(while (and file
(not (string-match locate-dominating-stop-dir-regexp file))
(not (and first-match-only root)))
(setq try (if (stringp name)
(projectile-file-exists-p
(projectile-expand-file-name-wildcard name file))
(funcall name file)))
(when try (setq root file))
(let ((parent (file-name-directory (directory-file-name file))))
(setq file (and (not (equal file parent)) parent))))
(and root (expand-file-name (file-name-as-directory root)))))