Skip to content

Commit 5c594ae

Browse files
Malabarbabbatsov
authored andcommitted
[Fix #518] Ignore ns forms inside strings in clojure-find-ns (#519)
1 parent fbf55ac commit 5c594ae

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

clojure-mode-sexp-test.el

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,38 @@ and point left there."
146146
;; we should not cache the results of `clojure-find-ns' here
147147
(let ((clojure-cache-ns nil))
148148
(with-temp-buffer
149-
(insert "(ns ^{:doc \"Some docs\"}\nfoo-bar)")
150-
(newline)
151-
(newline)
152-
(insert "(in-ns 'baz-quux)")
153-
(clojure-mode)
154-
155-
;; From inside docstring of first ns
156-
(goto-char 18)
157-
(should (equal "foo-bar" (clojure-find-ns)))
158-
159-
;; From inside first ns's name, on its own line
160-
(goto-char 29)
161-
(should (equal "foo-bar" (clojure-find-ns)))
162-
163-
;; From inside second ns's name
164-
(goto-char 42)
165-
(should (equal "baz-quux" (clojure-find-ns))))))
149+
(insert "(ns ^{:doc \"Some docs\"}\nfoo-bar)")
150+
(newline)
151+
(newline)
152+
(insert "(in-ns 'baz-quux)")
153+
(clojure-mode)
154+
155+
;; From inside docstring of first ns
156+
(goto-char 18)
157+
(should (equal "foo-bar" (clojure-find-ns)))
158+
159+
;; From inside first ns's name, on its own line
160+
(goto-char 29)
161+
(should (equal "foo-bar" (clojure-find-ns)))
162+
163+
;; From inside second ns's name
164+
(goto-char 42)
165+
(should (equal "baz-quux" (clojure-find-ns))))
166+
(let ((data
167+
'(("\"\n(ns foo-bar)\"\n" "(in-ns 'baz-quux)" "baz-quux")
168+
(";(ns foo-bar)\n" "(in-ns 'baz-quux)" "baz-quux")
169+
("(ns foo-bar)\n" "\"\n(in-ns 'baz-quux)\"" "foo-bar")
170+
("(ns foo-bar)\n" ";(in-ns 'baz-quux)" "foo-bar"))))
171+
(pcase-dolist (`(,form1 ,form2 ,expected) data)
172+
(with-temp-buffer
173+
(insert form1)
174+
(save-excursion (insert form2))
175+
(clojure-mode)
176+
;; Between the two namespaces
177+
(should (equal expected (clojure-find-ns)))
178+
;; After both namespaces
179+
(goto-char (point-max))
180+
(should (equal expected (clojure-find-ns))))))))
166181

167182
(provide 'clojure-mode-sexp-test)
168183

0 commit comments

Comments
 (0)