Function: projectile--common-parent
projectile--common-parent is a byte-compiled function defined in
projectile.el.
Signature
(projectile--common-parent DIRECTORIES)
Documentation
Return the innermost directory containing every one of DIRECTORIES.
Nil when they share no ancestor at all: a group mixing local and remote
(TRAMP) projects has none, and neither do two remote projects on
different hosts. Nil for an empty DIRECTORIES too.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;; Commands over a group of projects
;;
;; Everything above works on the project you're in. These two work on a set
;; of projects handed to them, because those are the two questions a group
;; actually raises: which of them was that file in, and which of them mention
;; this string.
;;
;; They're plain functions taking the list, so a command for a new kind of
;; group is a two-line wrapper. The known-projects and sibling commands are
;; exactly that, and so is anything you write yourself.
(defun projectile--common-parent (directories)
"Return the innermost directory containing every one of DIRECTORIES.
Nil when they share no ancestor at all: a group mixing local and remote
\(TRAMP) projects has none, and neither do two remote projects on
different hosts. Nil for an empty DIRECTORIES too."
(when directories
(let ((parent (file-name-as-directory (expand-file-name (car directories)))))
(dolist (dir (cdr directories) parent)
(let ((other (file-name-as-directory (expand-file-name dir))))
(while (and parent (not (string-prefix-p parent other)))
;; climb until PARENT contains OTHER too, giving up at the root
(let ((up (file-name-directory (directory-file-name parent))))
(setq parent (unless (equal up parent) up)))))))))