Skip to content

Commit 9ec5ed8

Browse files
committed
[Fix clojure-emacs#593] clojure-find-ns breaks if the ns form is preceded by ws
Problem was that the regexp here expected (ns form to start right in the beginning of the line. I added zero or more whitespace in the beginning which corrects the issue. Adds also a unit test which covers the issue.
1 parent 33f267a commit 9ec5ed8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
* [#593] clojure-find-ns breaks if the ns form is preceded by whitespace
7+
58
## 5.13.0 (2021-05-05)
69

710
### New features

clojure-mode.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ content) are considered part of the preceding sexp."
18731873
(make-obsolete-variable 'clojure-namespace-name-regex 'clojure-namespace-regexp "5.12.0")
18741874

18751875
(defconst clojure-namespace-regexp
1876-
(rx line-start "(" (? "clojure.core/") (or "in-ns" "ns" "ns+") symbol-end))
1876+
(rx line-start (zero-or-more whitespace) "(" (? "clojure.core/") (or "in-ns" "ns" "ns+") symbol-end))
18771877

18781878
(defcustom clojure-cache-ns nil
18791879
"Whether to cache the results of `clojure-find-ns'.

test/clojure-mode-util-test.el

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
(it "should find common namespace declarations"
6262
(with-clojure-buffer "(ns foo)"
6363
(expect (clojure-find-ns) :to-equal "foo"))
64+
(with-clojure-buffer " (ns foo)"
65+
(expect (clojure-find-ns) :to-equal "foo"))
6466
(with-clojure-buffer "(ns
6567
foo)"
6668
(expect (clojure-find-ns) :to-equal "foo"))

0 commit comments

Comments
 (0)