Function: projectile-subproject-root
projectile-subproject-root is a byte-compiled function defined in
projectile.el.
Signature
(projectile-subproject-root &optional DIR)
Documentation
Find the root of the nearest subproject containing DIR.
Walk up from DIR (the current file's directory by default) looking for
one of projectile-subproject-markers, stopping at the project root.
Returns the directory containing the nearest marker, or signals an error
if no subproject is found between DIR and the project root.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-subproject-root (&optional dir)
"Find the root of the nearest subproject containing DIR.
Walk up from DIR (the current file's directory by default) looking for
one of `projectile-subproject-markers', stopping at the project root.
Returns the directory containing the nearest marker, or signals an error
if no subproject is found between DIR and the project root."
(let* ((project-root (projectile-acquire-root))
(markers (projectile--subproject-markers))
(dir (or dir (file-name-directory (or (buffer-file-name) default-directory))))
(result nil))
;; Walk up from current directory, stop at (but include) project root.
;; Each level costs one directory listing rather than one stat per
;; marker, which matters here - the derived marker set is long.
(while (and (not result)
dir
(string-prefix-p project-root dir))
(when (projectile--directory-marker dir markers 'files-only)
(setq result dir))
(let ((parent (file-name-directory (directory-file-name dir))))
(setq dir (unless (string= parent dir) parent))))
(or result
(user-error "No subproject found between current directory and project root"))))