Function: clojure--find-ns-in-direction

clojure--find-ns-in-direction is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--find-ns-in-direction DIRECTION)

Documentation

Return the nearest namespace in a specific DIRECTION.

DIRECTION is forward or backward.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
(defun clojure--find-ns-in-direction (direction)
  "Return the nearest namespace in a specific DIRECTION.
DIRECTION is `forward' or `backward'."
  (let ((candidate)
        (fn (if (eq direction 'forward)
                #'search-forward-regexp
              #'search-backward-regexp)))
    (while (and (not candidate)
                (funcall fn clojure-namespace-regexp nil t))
      (let ((start (match-beginning 0))
            (end (match-end 0)))
        (save-excursion
          (when (clojure--looking-at-top-level-form start)
            (save-match-data
              (goto-char end)
              (clojure-forward-logical-sexp)
              (setq candidate (string-remove-prefix "'" (thing-at-point 'symbol))))))))
    candidate))