Function: projectile--other-extension-files
projectile--other-extension-files is a byte-compiled function defined
in projectile.el.
Signature
(projectile--other-extension-files CURRENT-FILE PROJECT-FILE-LIST &optional FLEX-MATCHING)
Documentation
Narrow to files with the same names but different extensions.
Returns a list of possible files for users to choose.
With FLEX-MATCHING, match any file that contains the base name of current file
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(defun projectile--other-extension-files (current-file project-file-list &optional flex-matching)
"Narrow to files with the same names but different extensions.
Returns a list of possible files for users to choose.
With FLEX-MATCHING, match any file that contains the base name of current file"
(let* ((file-ext-list (projectile-associated-file-name-extensions current-file))
(fulldirname (if (file-name-directory current-file)
(file-name-directory current-file) "./"))
(dirname (file-name-nondirectory (directory-file-name fulldirname)))
(filename (regexp-quote (projectile--file-name-sans-extensions current-file)))
(file-list (mapcar (lambda (ext)
(if flex-matching
(concat ".*" filename ".*" "\." ext "\\'")
(concat "^" filename
(unless (equal ext "")
(concat "\." ext))
"\\'")))
file-ext-list))
(candidates (seq-filter
(lambda (project-file)
(string-match filename project-file))
project-file-list))
(candidates
(flatten-tree (mapcar
(lambda (file)
(seq-filter
(lambda (project-file)
(string-match file
(concat (file-name-base project-file)
(when (file-name-extension project-file)
(concat "\." (file-name-extension project-file))))))
candidates))
file-list)))
(candidates
(seq-filter (lambda (file) (not (backup-file-name-p file))) candidates))
(sibling-dir-p (lambda (file)
(let ((candidate-dirname (file-name-nondirectory
(directory-file-name
(or (file-name-directory file) "./")))))
(and (not (equal fulldirname (file-name-directory file)))
(equal dirname candidate-dirname)))))
(candidates (append (seq-filter sibling-dir-p candidates)
(seq-remove sibling-dir-p candidates))))
candidates))