Function: clojure-expected-ns
clojure-expected-ns is a byte-compiled function defined in
clojure-mode.el.
Signature
(clojure-expected-ns &optional PATH)
Documentation
Return the namespace matching PATH.
PATH is expected to be an absolute file path.
If PATH is nil, use the path to the file backing the current buffer.
Source Code
;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
;;; ns manipulation
(defun clojure-expected-ns (&optional path)
"Return the namespace matching PATH.
PATH is expected to be an absolute file path.
If PATH is nil, use the path to the file backing the current buffer."
(let* ((path (or path (file-truename (buffer-file-name))))
(relative (clojure-project-relative-path path))
(sans-file-type (substring relative 0 (- (length (file-name-extension path t)))))
(sans-file-sep (mapconcat 'identity (cdr (split-string sans-file-type "/")) "."))
(sans-underscores (replace-regexp-in-string "_" "-" sans-file-sep)))
;; Drop prefix from ns for projects with structure src/{clj,cljs,cljc}
(cl-reduce (lambda (a x) (replace-regexp-in-string x "" a))
clojure-directory-prefixes
:initial-value sans-underscores)))