Function: clojure--top-level-form-start

clojure--top-level-form-start is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--top-level-form-start)

Documentation

Return the start of the top-level form at point, or nil.

Point can be right after it too, or on the metadata in front of it, which is then where it starts.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20261103.1226/clojure-mode.el
(defun clojure--top-level-form-start ()
  "Return the start of the top-level form at point, or nil.
Point can be right after it too, or on the metadata in front of it,
which is then where it starts."
  (save-excursion
    (let ((ppss (syntax-ppss)))
      (when (cond
             ((nth 9 ppss) (goto-char (car (nth 9 ppss))))
             ((nth 3 ppss) (goto-char (nth 8 ppss)))
             ((nth 4 ppss) nil)
             ((looking-at-p "[([{\"]"))
             ((memq (char-before) '(?\) ?\] ?\} ?\"))
              (goto-char (or (ignore-errors (scan-sexps (point) -1))
                             (user-error "The form at point doesn't parse"))))
             ;; The ^ of metadata, or the keyword or the symbol after it
             (t (skip-syntax-backward "w_")
                (looking-at-p "\\s'\\|\\sw\\|\\s_")))
        (backward-prefix-chars)
        (point)))))