Skip to content

Commit 5c42d77

Browse files
committed
Add tests for clojure-enable-indent-specs
Verify that when indent specs are disabled: - Forms like let and when get uniform (function-call) indentation instead of their special body-style indentation - The def*/with-* fallback still applies regardless, since it's handled outside the spec lookup
1 parent 8c18bc5 commit 5c42d77

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/clojure-mode-indentation-test.el

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,27 @@ x
12901290
(indent-region (point-min) (point-max))
12911291
(expect (buffer-string) :to-equal "\n(letfn [(foo [x]\n (+ x 1))]\n (foo 1))")))))
12921292

1293+
(describe "clojure-enable-indent-specs"
1294+
(it "should use uniform indentation when disabled"
1295+
(let ((clojure-enable-indent-specs nil))
1296+
;; let normally gets spec 1, but with specs disabled it should
1297+
;; indent like a regular function call.
1298+
(with-clojure-buffer "\n(let [x 1]\nx)"
1299+
(indent-region (point-min) (point-max))
1300+
(expect (buffer-string) :to-equal "\n(let [x 1]\n x)"))
1301+
;; when normally gets spec 1
1302+
(with-clojure-buffer "\n(when true\nbody)"
1303+
(indent-region (point-min) (point-max))
1304+
(expect (buffer-string) :to-equal "\n(when true\n body)"))))
1305+
1306+
(it "should still indent def*/with-* forms like body when specs are disabled"
1307+
;; The def*/with-* fallback in clojure-indent-function fires
1308+
;; regardless of clojure-enable-indent-specs.
1309+
(let ((clojure-enable-indent-specs nil))
1310+
(with-clojure-buffer "\n(defn foo\n[x]\nx)"
1311+
(indent-region (point-min) (point-max))
1312+
(expect (buffer-string) :to-equal "\n(defn foo\n [x]\n x)")))))
1313+
12931314
(provide 'clojure-mode-indentation-test)
12941315

12951316
;;; clojure-mode-indentation-test.el ends here

0 commit comments

Comments
 (0)