Function: projectile--file-kind-default-key
projectile--file-kind-default-key is a byte-compiled function defined
in projectile.el.
Signature
(projectile--file-kind-default-key REL-PATH SPEC)
Documentation
Derive the default resource key of REL-PATH for the kind SPEC.
The key is REL-PATH taken relative to SPEC's :path, with the final
component's :suffix (or, lacking that, its file extension) and
:prefix stripped. Any namespace directories under :path are kept,
so files that differ only by subdirectory get distinct keys. Return nil
for an empty result.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--file-kind-default-key (rel-path spec)
"Derive the default resource key of REL-PATH for the kind SPEC.
The key is REL-PATH taken relative to SPEC's `:path', with the final
component's `:suffix' (or, lacking that, its file extension) and
`:prefix' stripped. Any namespace directories under `:path' are kept,
so files that differ only by subdirectory get distinct keys. Return nil
for an empty result."
(let* ((path (plist-get spec :path))
(subpath (if (and path
(string-prefix-p (file-name-as-directory path)
rel-path))
(substring rel-path (length (file-name-as-directory path)))
rel-path))
(dir (or (file-name-directory subpath) ""))
(name (file-name-nondirectory subpath))
(prefix (plist-get spec :prefix))
(suffix (plist-get spec :suffix)))
(when (and suffix (string-suffix-p suffix name))
(setq name (substring name 0 (- (length suffix)))))
(unless suffix
(setq name (file-name-sans-extension name)))
(when (and prefix (string-prefix-p prefix name))
(setq name (substring name (length prefix))))
(unless (string-empty-p name)
(concat dir name))))