Skip to content

Commit 20b0b34

Browse files
committed
Merge pull request #350 from expez/update-ns-regexp
Make the ns regexp more permissive
2 parents 619b9a6 + 9b7885e commit 20b0b34

File tree

3 files changed

+50
-26
lines changed

3 files changed

+50
-26
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
## master (unreleased)
44

5+
### New features
6+
57
* Indent and font-lock forms that start with `let-`, `while-` or `when-` like their counterparts.
68

9+
### Bugs fixed
10+
11+
* Namespaces can now use the full palette of legal symbol characters.
12+
713
## 5.0.1 (15/11/2015)
814

915
### Bugs fixed

clojure-mode.el

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,32 +1016,8 @@ nil."
10161016
(zero-or-more "^:"
10171017
(one-or-more (not (any whitespace)))))
10181018
(one-or-more (any whitespace "\n")))
1019-
;; why is this here? oh (in-ns 'foo) or (ns+ :user)
1020-
(zero-or-one (any ":'"))
1021-
(group (one-or-more (not (any "()\"" whitespace))) word-end)))
1022-
1023-
;; for testing clojure-namespace-name-regex, you can evaluate this code and make
1024-
;; sure foo (or whatever the namespace name is) shows up in results. some of
1025-
;; these currently fail.
1026-
;; (mapcar (lambda (s) (let ((n (string-match clojure-namespace-name-regex s)))
1027-
;; (if n (match-string 4 s))))
1028-
;; '("(ns foo)"
1029-
;; "(ns
1030-
;; foo)"
1031-
;; "(ns foo.baz)"
1032-
;; "(ns ^:bar foo)"
1033-
;; "(ns ^:bar ^:baz foo)"
1034-
;; "(ns ^{:bar true} foo)"
1035-
;; "(ns #^{:bar true} foo)"
1036-
;; "(ns #^{:fail {}} foo)"
1037-
;; "(ns ^{:fail2 {}} foo.baz)"
1038-
;; "(ns ^{} foo)"
1039-
;; "(ns ^{:skip-wiki true}
1040-
;; aleph.netty
1041-
;; "
1042-
;; "(ns
1043-
;; foo)"
1044-
;; "foo"))
1019+
(zero-or-one (any ":'")) ;; (in-ns 'foo) or (ns+ :user)
1020+
(group (one-or-more (not (any "()\"" whitespace))) symbol-end)))
10451021

10461022

10471023

test/clojure-mode-util-test.el

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,48 @@
5353
(clojure-expected-ns))
5454
clj-file-ns)))))
5555

56+
(ert-deftest clojure-namespace-name-regex-test ()
57+
:tags '(regexp)
58+
(let ((ns "(ns foo)"))
59+
(should (string-match clojure-namespace-name-regex ns))
60+
(match-string 4 ns))
61+
(let ((ns "(ns
62+
foo)"))
63+
(should (string-match clojure-namespace-name-regex ns))
64+
(should (equal "foo" (match-string 4 ns))))
65+
(let ((ns "(ns foo.baz)"))
66+
(should (string-match clojure-namespace-name-regex ns))
67+
(should (equal "foo.baz" (match-string 4 ns))))
68+
(let ((ns "(ns ^:bar foo)"))
69+
(should (string-match clojure-namespace-name-regex ns))
70+
(should (equal "foo" (match-string 4 ns))))
71+
(let ((ns "(ns ^:bar ^:baz foo)"))
72+
(should (string-match clojure-namespace-name-regex ns))
73+
(should (equal "foo" (match-string 4 ns))))
74+
(let ((ns "(ns ^{:bar true} foo)"))
75+
(should (string-match clojure-namespace-name-regex ns))
76+
(should (equal "foo" (match-string 4 ns))))
77+
(let ((ns "(ns #^{:bar true} foo)"))
78+
(should (string-match clojure-namespace-name-regex ns))
79+
(should (equal "foo" (match-string 4 ns))))
80+
;; TODO
81+
;; (let ((ns "(ns #^{:fail {}} foo)"))
82+
;; (should (string-match clojure-namespace-name-regex ns))
83+
;; (match-string 4 ns))
84+
;; (let ((ns "(ns ^{:fail2 {}} foo.baz)"))
85+
;; (should (string-match clojure-namespace-name-regex ns))
86+
;; (should (equal "foo.baz" (match-string 4 ns))))
87+
(let ((ns "(ns ^{} foo)"))
88+
(should (string-match clojure-namespace-name-regex ns))
89+
(should (equal "foo" (match-string 4 ns))))
90+
(let ((ns "(ns ^{:skip-wiki true}
91+
aleph.netty"))
92+
(should (string-match clojure-namespace-name-regex ns))
93+
(should (equal "aleph.netty" (match-string 4 ns))))
94+
(let ((ns "(ns foo+)"))
95+
(should (string-match clojure-namespace-name-regex ns))
96+
(should (equal "foo+" (match-string 4 ns)))))
97+
5698
(provide 'clojure-mode-util-test)
5799

58100
;; Local Variables:

0 commit comments

Comments
 (0)