Function: cider-ns-edit--ns-form-start

cider-ns-edit--ns-form-start is a byte-compiled function defined in cider-ns.el.

Signature

(cider-ns-edit--ns-form-start)

Documentation

Return the start of the ns form the code at point belongs to, or nil.

That's the closest top-level ns form before point, or the first one in the buffer when there's none before point.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-ns.el
(defun cider-ns-edit--ns-form-start ()
  "Return the start of the ns form the code at point belongs to, or nil.
That's the closest top-level ns form before point, or the first one in
the buffer when there's none before point."
  (save-excursion
    (save-restriction
      (widen)
      (let ((ref (or (car (nth 9 (syntax-ppss))) (point)))
            (case-fold-search nil)
            first before)
        (goto-char (point-min))
        (while (re-search-forward cider-ns-edit--ns-regexp nil t)
          (let* ((start (match-beginning 0))
                 ;; `syntax-ppss' moves point to its argument
                 (state (save-excursion (syntax-ppss start))))
            (when (and (zerop (car state))
                       (not (nth 8 state))
                       (not (cider-ns-edit--discarded-p start)))
              (unless first (setq first start))
              (when (<= start ref) (setq before start)))))
        (or before first)))))