Function: projectile--collect-from-functions

projectile--collect-from-functions is a byte-compiled function defined in projectile.el.

Signature

(projectile--collect-from-functions FUNCTIONS ROOT KEY-FUNCTION WHAT)

Documentation

Call each of FUNCTIONS with ROOT and collect their results.

The lists come back concatenated in the order FUNCTIONS were given, de-duplicated by KEY-FUNCTION, so the first function to report an item is the one whose version of it survives and the earlier functions' findings are offered first. Items KEY-FUNCTION returns nil for are dropped.

A function that signals is reported and skipped rather than taking the whole lookup down with it; WHAT names the kind of function in that message.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;; Misc utility functions

(defun projectile--collect-from-functions (functions root key-function what)
  "Call each of FUNCTIONS with ROOT and collect their results.

The lists come back concatenated in the order FUNCTIONS were given,
de-duplicated by KEY-FUNCTION, so the first function to report an item
is the one whose version of it survives and the earlier functions'
findings are offered first.  Items KEY-FUNCTION returns nil for are
dropped.

A function that signals is reported and skipped rather than taking the
whole lookup down with it; WHAT names the kind of function in that
message."
  (let ((seen (make-hash-table :test 'equal))
        results)
    (dolist (fn functions)
      (dolist (item (condition-case err
                        (funcall fn root)
                      (error
                       (projectile--message "%s function %s failed: %s"
                                            what fn (error-message-string err))
                       nil)))
        (when-let* ((key (funcall key-function item))
                    ((not (gethash key seen))))
          (puthash key t seen)
          (push item results))))
    (nreverse results)))