Function: projectile--frecency-cap-projects

projectile--frecency-cap-projects is a byte-compiled function defined in projectile.el.

Signature

(projectile--frecency-cap-projects DATA)

Documentation

Return DATA capped at projectile-frecency-max-projects roots.

DATA is an alist of (ROOT . FILE-ENTRIES), each FILE-ENTRY a
(FILE COUNT TIME) list. The most recently active roots (highest file
timestamp) are kept and the rest dropped, so the store can't accumulate dead roots without bound.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--frecency-cap-projects (data)
  "Return DATA capped at `projectile-frecency-max-projects' roots.
DATA is an alist of (ROOT . FILE-ENTRIES), each FILE-ENTRY a
\(FILE COUNT TIME) list.  The most recently active roots (highest file
timestamp) are kept and the rest dropped, so the store can't accumulate
dead roots without bound."
  (if (<= (length data) projectile-frecency-max-projects)
      data
    (let ((ranked
           (sort (copy-sequence data)
                 (lambda (a b)
                   (> (apply #'max 0 (mapcar (lambda (fe) (or (nth 2 fe) 0)) (cdr a)))
                      (apply #'max 0 (mapcar (lambda (fe) (or (nth 2 fe) 0)) (cdr b))))))))
      (seq-take ranked projectile-frecency-max-projects))))