Function: elisp-refs--read-and-find

elisp-refs--read-and-find is a byte-compiled function defined in elisp-refs.el.

Signature

(elisp-refs--read-and-find BUFFER SYMBOL MATCH-P)

Documentation

Read all the forms in BUFFER, and return a list of all forms that contain SYMBOL where MATCH-P returns t.

For every matching form found, we return the form itself along with its start and end position.

Source Code

;; Defined in ~/.emacs.d/elpa/elisp-refs-20230920.201/elisp-refs.el
;; TODO: benchmark building a list with `push' rather than using
;; mapcat.
(defun elisp-refs--read-and-find (buffer symbol match-p)
  "Read all the forms in BUFFER, and return a list of all forms that
contain SYMBOL where MATCH-P returns t.

For every matching form found, we return the form itself along
with its start and end position."
  (-non-nil
   (--mapcat
    (-let [(form start-pos end-pos symbol-positions _read-start-pos) it]
      ;; Optimisation: if we have a list of positions for the current
      ;; form (Emacs 28 and earlier), and it doesn't contain the
      ;; symbol we're looking for, don't bother walking the form.
      (when (or (null symbol-positions) (assq symbol symbol-positions))
        (elisp-refs--walk buffer form start-pos end-pos symbol match-p)))
    (elisp-refs--read-all-buffer-forms buffer nil))))