Function: elisp--refs-visit-match

elisp--refs-visit-match is an interactive and byte-compiled function defined in elisp-refs.el.

Signature

(elisp--refs-visit-match OPEN-FN)

Documentation

Go to the search result at point.

Open file with function OPEN_FN. `find-file` or `find-file-other-window`

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/elisp-refs-20230920.201/elisp-refs.el
(defun elisp--refs-visit-match (open-fn)
  "Go to the search result at point.
Open file with function OPEN_FN. `find-file` or `find-file-other-window`"
  (interactive)
  (let* ((path (get-text-property (point) 'elisp-refs-path))
         (pos (get-text-property (point) 'elisp-refs-start-pos))
         (unindent (get-text-property (point) 'elisp-refs-unindented))
         (column-offset (current-column))
         (line-offset -1))
    (when (null path)
      (user-error "No match here"))

    ;; If point is not on the first line of the match, work out how
    ;; far away the first line is.
    (save-excursion
      (while (equal pos (get-text-property (point) 'elisp-refs-start-pos))
        (forward-line -1)
        (cl-incf line-offset)))

    (funcall open-fn path)
    (goto-char pos)
    ;; Move point so we're on the same char in the buffer that we were
    ;; on in the results buffer.
    (forward-line line-offset)
    (beginning-of-line)
    (let ((target-offset (+ column-offset unindent))
          (i 0))
      (while (< i target-offset)
        (if (looking-at "\t")
            (cl-incf i tab-width)
          (cl-incf i))
        (forward-char 1)))))