Function: clojure-current-defun-name

clojure-current-defun-name is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure-current-defun-name)

Documentation

Return the name of the defun at point, or nil.

add-log-current-defun-function is set to this, for use by which-func.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
(defun clojure-current-defun-name ()
  "Return the name of the defun at point, or nil.

`add-log-current-defun-function' is set to this, for use by `which-func'."
  (save-excursion
    (let ((location (point)))
      ;; If we are now precisely at the beginning of a defun, make sure
      ;; beginning-of-defun finds that one rather than the previous one.
      (or (eobp) (forward-char 1))
      (beginning-of-defun-raw)
      ;; Make sure we are really inside the defun found, not after it.
      (when (and (looking-at "\\s(")
                 (progn (end-of-defun)
                        (< location (point)))
                 (progn (forward-sexp -1)
                        (>= location (point))))
        (if (looking-at "\\s(")
            (forward-char 1))
        ;; Skip the defining construct name, e.g. "defn" or "def".
        (forward-sexp 1)
        ;; The second element is usually a symbol being defined.  If it
        ;; is not, use the first symbol in it.
        (skip-chars-forward " \t\n'(")
        ;; Skip metadata
        (while (looking-at "\\^")
          (forward-sexp 1)
          (skip-chars-forward " \t\n'("))
        (buffer-substring-no-properties (point)
                                        (progn (forward-sexp 1)
                                               (point)))))))