Function: cider-sexp-at-point

cider-sexp-at-point is a byte-compiled function defined in cider-util.el.

Signature

(cider-sexp-at-point &optional BOUNDS)

Documentation

Return the sexp at point as a string, otherwise nil.

When point is on a closing delimiter, this is the sexp it closes; leading metadata is considered part of the sexp. If BOUNDS is non-nil, return a list of its starting and ending position instead.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-util.el
(defun cider-sexp-at-point (&optional bounds)
  "Return the sexp at point as a string, otherwise nil.
When point is on a closing delimiter, this is the sexp it closes; leading
metadata is considered part of the sexp.
If BOUNDS is non-nil, return a list of its starting and ending position
instead."
  (when-let* ((b (cond
                  ;; on a closing delimiter: the form it closes
                  ((eq (char-syntax (or (char-after) ?\s)) ?\))
                   (ignore-errors
                     (save-excursion
                       (up-list 1)
                       (let ((end (point)))
                         (backward-sexp 1)
                         (cons (point) end)))))
                  ;; hide stuff before ( to avoid quirks with '( etc.
                  ((and (equal (char-after) ?\()
                        (member (char-before) '(?\' ?\, ?\@)))
                   (save-restriction
                     (narrow-to-region (point) (point-max))
                     (bounds-of-thing-at-point 'sexp)))
                  (t (bounds-of-thing-at-point 'sexp)))))
    (let ((b (cider--include-leading-metadata b)))
      (funcall (if bounds #'list #'buffer-substring-no-properties)
               (car b) (cdr b)))))