Function: cider-symbol-at-point

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

Signature

(cider-symbol-at-point &optional LOOK-BACK)

Documentation

Return the name of the symbol at point, otherwise nil.

Ignores the REPL prompt. If LOOK-BACK is non-nil, move backwards trying to find a symbol if there isn't one at point. Does not strip the : from keywords, nor attempt to expand :: auto-resolved keywords.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-util.el
(defun cider-symbol-at-point (&optional look-back)
  "Return the name of the symbol at point, otherwise nil.
Ignores the REPL prompt.  If LOOK-BACK is non-nil, move backwards trying to
find a symbol if there isn't one at point.
Does not strip the : from keywords, nor attempt to expand :: auto-resolved
keywords."
  (or (when-let* ((str (thing-at-point 'symbol)))
        (unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str)
          ;; remove font-locking
          (setq str (substring-no-properties str))
          (if (member str '("." ".."))
              str
            ;; Remove prefix quotes, and trailing . from constructors like Record.
            (thread-last
              str
              ;; constructors (Foo.)
              (string-remove-suffix ".")
              ;; quoted symbols ('sym)
              (string-remove-prefix "'")
              ;; var references (#'inc 2)
              (string-remove-prefix "#'")))))
      (when look-back
        (save-excursion
          (ignore-errors
            (when (looking-at "(")
              (forward-char 1))
            (while (not (looking-at "\\sw\\|\\s_\\|\\`"))
              (forward-sexp -1)))
          (cider-symbol-at-point)))))