Function: cider--var-to-xref-location

cider--var-to-xref-location is a byte-compiled function defined in cider-xref-backend.el.

Signature

(cider--var-to-xref-location VAR)

Documentation

Get location of definition of VAR.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-xref-backend.el
(defun cider--var-to-xref-location (var)
  "Get location of definition of VAR."
  ;; Capture the originating session before opening the target buffer, so that
  ;; a dependency's source (which lives outside the project) stays pinned to the
  ;; REPL it was navigated from.  xref drives the navigation itself (via
  ;; `switch-to-buffer'), bypassing `cider-jump-to', so we do the pinning here -
  ;; otherwise evaluation in the opened buffer fails with "No linked CIDER
  ;; sessions" (see https://github.com/clojure-emacs/cider/issues/4118).
  (let ((origin-repl (ignore-errors (cider-current-repl))))
    (when-let* ((info (cider-var-info var))
                (line (nrepl-dict-get info "line"))
                (file (cider--xref-extract-file info))
                (buf (cider--find-buffer-for-file file)))
      (with-current-buffer buf
        (cider--pin-repl-if-out-of-project origin-repl))
      (xref-make-buffer-location
       buf
       (with-current-buffer buf
         (save-excursion
           (goto-char 0)
           (forward-line (1- line))
           (back-to-indentation)
           (point)))))))