Function: cider-jump-to

cider-jump-to is a byte-compiled function defined in cider-common.el.

Signature

(cider-jump-to BUFFER &optional POS OTHER-WINDOW)

Documentation

Push current point onto marker ring, and jump to BUFFER and POS.

POS can be either a number, a cons, or a symbol. If a number, it is the character position (the point). If a cons, it specifies the position as (LINE . COLUMN). COLUMN can be nil. If a symbol, cider-jump-to searches for something that looks like the symbol's definition in the file. If OTHER-WINDOW is non-nil don't reuse current window.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-common.el
(defun cider-jump-to (buffer &optional pos other-window)
  "Push current point onto marker ring, and jump to BUFFER and POS.
POS can be either a number, a cons, or a symbol.
If a number, it is the character position (the point).
If a cons, it specifies the position as (LINE . COLUMN).  COLUMN can be nil.
If a symbol, `cider-jump-to' searches for something that looks like the
symbol's definition in the file.
If OTHER-WINDOW is non-nil don't reuse current window."
  ;; Capture the originating session before `pop-to-buffer' moves us to the
  ;; target buffer, so out-of-project targets can be pinned to it below.
  (let ((origin-repl (ignore-errors (cider-current-repl))))
    (with-no-warnings
      (xref-push-marker-stack))
    (if other-window
        (pop-to-buffer buffer 'display-buffer-pop-up-window)
      (pop-to-buffer buffer cider-jump-to-pop-to-buffer-actions))
    (with-current-buffer buffer
      (widen)
      (goto-char (point-min))
      (cider-mode +1)
      (cider--pin-repl-if-out-of-project origin-repl)
      (let ((status
             (cond
              ;; Line-column specification.
              ((consp pos)
               (forward-line (1- (or (car pos) 1)))
               (if (cdr pos)
                   (move-to-column (cdr pos))
                 (back-to-indentation)))
              ;; Point specification.
              ((numberp pos)
               (goto-char pos))
              ;; Symbol or string.
              (pos
               ;; Try to find (def full-name ...).
               (if (or (save-excursion
                         (search-forward-regexp (format "(def.*\\s-\\(%s\\)" (regexp-quote pos))
                                                nil 'noerror))
                       (let ((name (replace-regexp-in-string ".*/" "" pos)))
                         ;; Try to find (def name ...).
                         (or (save-excursion
                               (search-forward-regexp (format "(def.*\\s-\\(%s\\)" (regexp-quote name))
                                                      nil 'noerror))
                             ;; Last resort, just find the first occurrence of `name'.
                             (save-excursion
                               (search-forward name nil 'noerror)))))
                   (goto-char (match-beginning 0))
                 (message "Can't find %s in %s" pos (buffer-file-name))
                 'not-found))
              (t 'not-found))))
        (unless (eq status 'not-found)
          ;; Make sure the location we jump to is centered within the target window
          (recenter))))))