Skip to content

Commit 24ea02b

Browse files
yuhan0bbatsov
authored andcommitted
Fix namespace detection with complex metadata
1 parent 5869cc6 commit 24ea02b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

clojure-mode.el

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,11 @@ content) are considered part of the preceding sexp."
18881888
(zero-or-one (any ":'")) ;; (in-ns 'foo) or (ns+ :user)
18891889
(group (one-or-more (not (any "()\"" whitespace))) symbol-end)))
18901890

1891+
(make-obsolete-variable 'clojure-namespace-name-regex 'clojure-namespace-regexp "5.12.0")
1892+
1893+
(defconst clojure-namespace-regexp
1894+
(rx line-start "(" (? "clojure.core/") (or "in-ns" "ns" "ns+")))
1895+
18911896
(defcustom clojure-cache-ns nil
18921897
"Whether to cache the results of `clojure-find-ns'.
18931898
@@ -1911,9 +1916,16 @@ DIRECTION is `forward' or `backward'."
19111916
#'search-forward-regexp
19121917
#'search-backward-regexp)))
19131918
(while (and (not candidate)
1914-
(funcall fn clojure-namespace-name-regex nil t))
1915-
(unless (or (clojure--in-string-p) (clojure--in-comment-p))
1916-
(setq candidate (match-string-no-properties 4))))
1919+
(funcall fn clojure-namespace-regexp nil t))
1920+
(let ((end (match-end 0)))
1921+
(save-excursion
1922+
(save-match-data
1923+
(goto-char end)
1924+
(clojure-forward-logical-sexp)
1925+
(when (and (looking-back clojure--sym-regexp end 'greedy)
1926+
(not (clojure--in-string-p))
1927+
(not (clojure--in-comment-p)))
1928+
(setq candidate (match-string-no-properties 0)))))))
19171929
candidate))
19181930

19191931
(defun clojure-find-ns ()

0 commit comments

Comments
 (0)