Function: projectile--file-kinds-related-files-fn
projectile--file-kinds-related-files-fn is a byte-compiled function
defined in projectile.el.
Signature
(projectile--file-kinds-related-files-fn FILE-KINDS)
Documentation
Compile FILE-KINDS into a related-files-fn.
FILE-KINDS is an alist of (KIND . SPEC). KIND is a keyword and SPEC is a plist with the following optional properties:
:path a root-relative directory prefix (e.g. "app/models/").
:prefix a basename prefix the file must have.
:suffix a basename suffix the file must have (e.g. "_controller.rb").
:key-fn a function of the file's relative path returning its resource
key string, or nil when the file is not of this kind. When
omitted the key is derived by projectile--file-kind-default-key.
The returned function, given a relative path, finds the first kind the
path belongs to and emits, for every *other* kind, an entry
(:KIND PREDICATE) whose PREDICATE matches files of that kind sharing the
same resource key.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--file-kinds-related-files-fn (file-kinds)
"Compile FILE-KINDS into a related-files-fn.
FILE-KINDS is an alist of (KIND . SPEC). KIND is a keyword and SPEC is
a plist with the following optional properties:
:path a root-relative directory prefix (e.g. \"app/models/\").
:prefix a basename prefix the file must have.
:suffix a basename suffix the file must have (e.g. \"_controller.rb\").
:key-fn a function of the file's relative path returning its resource
key string, or nil when the file is not of this kind. When
omitted the key is derived by `projectile--file-kind-default-key'.
The returned function, given a relative path, finds the first kind the
path belongs to and emits, for every *other* kind, an entry
\(:KIND PREDICATE) whose PREDICATE matches files of that kind sharing the
same resource key."
(lambda (rel-path)
(let (this-kind this-key)
(cl-dolist (entry file-kinds)
(when-let* ((key (projectile--file-kind-match rel-path (cdr entry))))
(setq this-kind (car entry)
this-key key)
(cl-return)))
(when this-kind
(let (result)
(dolist (entry file-kinds)
(let ((kind (car entry))
(spec (cdr entry)))
(unless (eq kind this-kind)
(setq result
(plist-put result kind
(lambda (other-path)
(equal this-key
(projectile--file-kind-match other-path spec))))))))
result)))))