Function: cider--debug-find-coordinates-for-point
cider--debug-find-coordinates-for-point is a byte-compiled function
defined in cider-debug.el.
Signature
(cider--debug-find-coordinates-for-point TARGET &optional LIST-SO-FAR)
Documentation
Return the coordinates list for reaching TARGET.
Assumes that the next thing after point is a logical Clojure sexp and that
TARGET is inside it. The returned list is suitable for use in
cider--debug-move-point. LIST-SO-FAR is for internal use.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-debug.el
;;; Move here command
;; This is the inverse of `cider--debug-move-point'. However, that algorithm is
;; complicated, and trying to code its inverse would probably be insane.
;; Instead, we find the coordinate by trial and error.
(defun cider--debug-find-coordinates-for-point (target &optional list-so-far)
"Return the coordinates list for reaching TARGET.
Assumes that the next thing after point is a logical Clojure sexp and that
TARGET is inside it. The returned list is suitable for use in
`cider--debug-move-point'. LIST-SO-FAR is for internal use."
(when (looking-at (rx (or "(" "[" "#{" "{")))
(let ((starting-point (point)))
(unwind-protect
(let ((x 0))
;; Keep incrementing the last coordinate until we've moved
;; past TARGET.
(while (condition-case nil
(progn (goto-char starting-point)
(cider--debug-move-point (append list-so-far (list x)))
(< (point) target))
;; Not a valid coordinate. Move back a step and stop here.
(scan-error (setq x (1- x))
nil))
(setq x (1+ x)))
(setq list-so-far (append list-so-far (list x)))
;; We have moved past TARGET, now determine whether we should
;; stop, or if target is deeper inside the previous sexp.
(if (or (= target (point))
(progn (forward-sexp -1)
(<= target (point))))
list-so-far
(goto-char starting-point)
(cider--debug-find-coordinates-for-point target list-so-far)))
;; `unwind-protect' clause.
(goto-char starting-point)))))