Function: cider--debug-find-source-position
cider--debug-find-source-position is a byte-compiled function defined
in cider-debug.el.
Signature
(cider--debug-find-source-position RESPONSE &optional CREATE-IF-NEEDED)
Documentation
Return a marker of the position after the sexp specified in RESPONSE.
This marker might be in a different buffer! If the sexp can't be
found (file that contains the code is no longer visited or has been
edited), return nil. However, if CREATE-IF-NEEDED is non-nil, a new buffer
is created in this situation and the return value is never nil.
Follow the "line" and "column" entries in RESPONSE, and check whether the code at point matches the "code" entry in RESPONSE. If it doesn't, assume that the code in this file has been edited, and create a temp buffer holding the original code. Either way, navigate inside the code by following the "coor" entry which is a coordinate measure in sexps.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-debug.el
(defun cider--debug-find-source-position (response &optional create-if-needed)
"Return a marker of the position after the sexp specified in RESPONSE.
This marker might be in a different buffer! If the sexp can't be
found (file that contains the code is no longer visited or has been
edited), return nil. However, if CREATE-IF-NEEDED is non-nil, a new buffer
is created in this situation and the return value is never nil.
Follow the \"line\" and \"column\" entries in RESPONSE, and check whether
the code at point matches the \"code\" entry in RESPONSE. If it doesn't,
assume that the code in this file has been edited, and create a temp buffer
holding the original code.
Either way, navigate inside the code by following the \"coor\" entry which
is a coordinate measure in sexps."
(nrepl-dbind-response response (code file line column ns original-id coor)
(when (or code (and file line column))
;; This is for restoring current-buffer.
(save-excursion
(let ((out))
;; We prefer in-source debugging.
(when-let* ((buf (and file line column
(ignore-errors
(cider--find-buffer-for-file file)))))
;; The logic here makes it hard to use `with-current-buffer'.
(with-current-buffer buf
;; This is for restoring point inside buf.
(save-excursion
;; Get to the proper line & column in the file
(forward-line (- line (line-number-at-pos)))
;; Column numbers in the response start from 1.
;; Convert to Emacs system which starts from 0
;; Inverse of `cider-column-number-at-pos'.
(move-to-column (max 0 (1- column)))
;; Check if it worked
(when (cider--debug-position-for-code code)
;; Find the desired sexp.
(cider--debug-move-point coor)
(setq out (point-marker))))))
;; But we can create a temp buffer if that fails.
(or out
(when create-if-needed
(cider--initialize-debug-buffer
code ns original-id
(if (and line column)
"you edited the code"
"your nREPL version is older than 0.2.11"))
(save-excursion
(cider--debug-move-point coor)
(point-marker)))))))))