Function: elisp-refs--show-results

elisp-refs--show-results is a byte-compiled function defined in elisp-refs.el.

Signature

(elisp-refs--show-results SYMBOL DESCRIPTION RESULTS SEARCHED-FILE-COUNT PREFIX)

Documentation

Given a RESULTS list where each element takes the form (forms . buffer), render a friendly results buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/elisp-refs-20230920.201/elisp-refs.el
;; TODO: if we have multiple matches on one line, we repeatedly show
;; that line. That's slightly confusing.
(defun elisp-refs--show-results (symbol description results
                                        searched-file-count prefix)
  "Given a RESULTS list where each element takes the form \(forms . buffer\),
render a friendly results buffer."
  (let ((buf (get-buffer-create (format "*refs: %s*" symbol))))
    (switch-to-buffer buf)
    (let ((inhibit-read-only t))
      (erase-buffer)
      (save-excursion
        ;; Insert the header.
        (insert
         (elisp-refs--format-count
          description
          (-sum (--map (length (car it)) results))
          (length results)
          searched-file-count
          prefix)
         "\n\n")
        ;; Insert the results.
        (--each results
          (-let* (((forms . buf) it)
                  (path (with-current-buffer buf elisp-refs--path)))
            (insert
             (propertize "File: " 'face 'bold)
             (elisp-refs--path-button path) "\n")
            (--each forms
              (-let [(_ start-pos end-pos) it]
                (insert (elisp-refs--containing-lines buf start-pos end-pos)
                        "\n")))
            (insert "\n")))
        ;; Prepare the buffer for the user.
        (elisp-refs-mode)))
    ;; Cleanup buffers created when highlighting results.
    (when elisp-refs--highlighting-buffer
      (kill-buffer elisp-refs--highlighting-buffer))))