Function: projectile--frecency-sort-function
projectile--frecency-sort-function is a byte-compiled function defined
in projectile.el.
Signature
(projectile--frecency-sort-function PROJECT-ROOT)
Documentation
Return a completion sort function ranking PROJECT-ROOT's files, or nil.
The returned function puts tracked files first, ordered by
projectile--frecency-score, and preserves the order of the rest.
Return nil when frecency is disabled or nothing is tracked yet.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--frecency-sort-function (project-root)
"Return a completion sort function ranking PROJECT-ROOT's files, or nil.
The returned function puts tracked files first, ordered by
`projectile--frecency-score', and preserves the order of the rest.
Return nil when frecency is disabled or nothing is tracked yet."
(when (and projectile-enable-frecency project-root)
(when-let* ((files (gethash project-root (projectile--frecency-data))))
(when (> (hash-table-count files) 0)
(let ((scores (make-hash-table :test 'equal
:size (hash-table-count files)))
(now (projectile-time-seconds)))
(maphash (lambda (file entry)
(puthash file (projectile--frecency-score entry now)
scores))
files)
(lambda (candidates)
(let (frecent rest)
(dolist (cand candidates)
(if (gethash cand scores)
(push cand frecent)
(push cand rest)))
(nconc (sort (nreverse frecent)
(lambda (a b)
(> (gethash a scores) (gethash b scores))))
(nreverse rest)))))))))