Function: cider--smart-form-bounds
cider--smart-form-bounds is a byte-compiled function defined in
cider-util.el.
Signature
(cider--smart-form-bounds &optional MIN)
Documentation
Return the bounds (START . END) of the form point targets, resolved smartly.
See cider-form-targeting for the resolution rules. When MIN is the
symbol compound and the resolved target is an atom or a string, widen
to the enclosing compound form, if there is one.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-util.el
(defun cider--smart-form-bounds (&optional min)
"Return the bounds (START . END) of the form point targets, resolved smartly.
See `cider-form-targeting' for the resolution rules. When MIN is the
symbol `compound' and the resolved target is an atom or a string, widen
to the enclosing compound form, if there is one."
(let* ((ppss (syntax-ppss))
(b (cond
;; inside a string: the string literal is the form
((nth 3 ppss)
(let ((start (nth 8 ppss)))
(cons start (save-excursion
(goto-char start)
(forward-sexp 1)
(point)))))
;; right after a closing delimiter: the form just closed
((eq (char-syntax (or (char-before) ?\s)) ?\))
(cider--preceding-form-bounds))
;; on an opening delimiter: the form it opens
((eq (char-syntax (or (char-after) ?\s)) ?\()
(cons (point) (save-excursion (forward-sexp 1) (point))))
;; on a closing delimiter: the form it closes
((eq (char-syntax (or (char-after) ?\s)) ?\))
(save-excursion
(up-list 1)
(let ((end (point)))
(backward-sexp 1)
(cons (point) end))))
;; inside or right next to an atom: the atom
((bounds-of-thing-at-point 'sexp))
;; in whitespace between forms: the preceding sexp
(t (cider--preceding-form-bounds)))))
;; A compound form (list, vector, map, set...) always ends in a
;; closing delimiter, regardless of any reader-macro prefix; anything
;; else is an atom-ish target that widens to its enclosing form when
;; the caller asked for a compound one.
(if (and (eq min 'compound)
(not (eq (char-syntax (char-before (cdr b))) ?\)))
(nth 1 ppss))
(save-excursion
(goto-char (nth 1 ppss))
(cons (point) (progn (forward-sexp 1) (point))))
b)))