Skip to content

Commit b2d17dd

Browse files
anthonygaleabbatsov
authored andcommitted
[Fix #511] Fix incorrect indentation of namespaced map (#533)
1 parent 5ab2be8 commit b2d17dd

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
* [#489](https://github.com/clojure-emacs/clojure-mode/issues/489): Inserting parens before comment form doesn't move point.
3636
* [#500](https://github.com/clojure-emacs/clojure-mode/pull/500): Fix project.el integration.
37+
* [#513](https://github.com/clojure-emacs/clojure-mode/pull/513): Fix incorrect indentation of namespaced map.
3738

3839
### Changes
3940

clojure-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ Returns a list pair, e.g. (\"defn\" \"abc\") or (\"deftest\" \"some-test\")."
19771977
\"Non-logical\" sexp are ^metadata and #reader.macros."
19781978
(comment-normalize-vars)
19791979
(comment-forward (point-max))
1980-
(looking-at-p "\\^\\|#[[:alpha:]]"))
1980+
(looking-at-p "\\^\\|#:?:?[[:alpha:]]"))
19811981

19821982
(defun clojure-forward-logical-sexp (&optional n)
19831983
"Move forward N logical sexps.

test/clojure-mode-indentation-test.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ DESCRIPTION is a string with the description of the spec."
148148
(cond
149149
|x)")
150150

151+
(when-indenting-with-point-it "should indent cond-> with a namespaced map"
152+
"
153+
(cond-> #:a{:b 1}
154+
|x 1)"
155+
156+
"
157+
(cond-> #:a{:b 1}
158+
|x 1)")
159+
160+
(when-indenting-with-point-it "should indent cond-> with a namespaced map 2"
161+
"
162+
(cond-> #::a{:b 1}
163+
|x 1)"
164+
165+
"
166+
(cond-> #::a{:b 1}
167+
|x 1)")
168+
151169
(when-indenting-with-point-it "should indent threading macro with expression on first line"
152170
"
153171
(->> expr

test/clojure-mode-sexp-test.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,15 @@ and point left there."
117117
(clojure-forward-logical-sexp 2)
118118
(expect (looking-back "\\^String biverse"))
119119
(clojure-backward-logical-sexp 1)
120-
(expect (looking-at-p "\\^String biverse")))))
120+
(expect (looking-at-p "\\^String biverse"))))
121+
122+
(it "should handle a namespaced map"
123+
(with-clojure-buffer "first #:name/space{:k v}"
124+
(clojure-backward-logical-sexp 1)
125+
(expect (looking-at-p "#:name/space{:k v}"))
126+
(insert " #::ns {:k v}")
127+
(clojure-backward-logical-sexp 1)
128+
(expect (looking-at-p "#::ns {:k v}")))))
121129

122130
(describe "clojure-backward-logical-sexp"
123131
(it "should work with buffer corners"

0 commit comments

Comments
 (0)