Skip to content

Commit e8c71e1

Browse files
committed
[Fix #292] Indentation in reader conditionals
Before #?(:clj :foo :cljs :bar) Now #?(:clj :foo :cljs :bar)
1 parent 4079913 commit e8c71e1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clojure-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,11 @@ This function also returns nil meaning don't specify the indentation."
694694
(split-string (substring-no-properties function) "/")))))
695695
(setq method (or (get (intern-soft function) 'clojure-indent-function)
696696
(get (intern-soft function-tail) 'clojure-indent-function)))
697-
(cond ((member (char-after open-paren) '(?\[ ?\{))
697+
;; Maps, sets, vectors and reader conditionals.
698+
(cond ((or (member (char-after open-paren) '(?\[ ?\{))
699+
(ignore-errors
700+
(and (eq (char-before open-paren) ?\?)
701+
(eq (char-before (1- open-paren)) ?\#))))
698702
(goto-char open-paren)
699703
(1+ (current-column)))
700704
((or (eq method 'defun)

test/clojure-mode-indentation-test.el

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ values of customisable variables."
171171
2] a
172172
|x]")
173173

174+
(check-indentation reader-conditionals
175+
"
176+
#?(:clj :foo
177+
|:cljs :bar)"
178+
"
179+
#?(:clj :foo
180+
|:cljs :bar)")
181+
174182

175183
(provide 'clojure-mode-indentation-test)
176184

0 commit comments

Comments
 (0)