Skip to content

Commit fe668ee

Browse files
committed
Add a test for align separation and fix the feature
1 parent 08a4b57 commit fe668ee

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

clojure-mode.el

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,20 @@ When called from lisp code align everything between BEG and END."
927927
(backward-up-list)
928928
(forward-sexp 1)
929929
(point-marker)))
930-
(clojure-align-forms-automatically nil))
931-
(align-region (point) sexp-end "^ *$"
932-
'((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
933-
(group . 1)
934-
(repeat . t)))
935-
nil)
930+
(clojure-align-forms-automatically nil)
931+
(count 1))
932+
;; For some bizarre reason, we need to `align-region' once for each
933+
;; group.
934+
(save-excursion
935+
(while (search-forward-regexp "^ *\n" sexp-end 'noerror)
936+
(incf count)))
937+
(dotimes (_ count)
938+
(align-region (point) sexp-end nil
939+
'((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
940+
(group . 1)
941+
(separate . "^ *$")
942+
(repeat . t)))
943+
nil))
936944
;; Reindent after aligning because of #360.
937945
(indent-region (point) sexp-end)))))
938946

test/clojure-mode-indentation-test.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ x
488488
"(let [a b
489489
c d])")
490490

491+
(def-full-align-test blank-line
492+
"(let [this-is-a-form b
493+
c d
494+
495+
another form
496+
k g])"
497+
"{:this-is-a-form b
498+
c d
499+
500+
:another form
501+
k g}")
502+
491503
(def-full-align-test basic-reversed
492504
"{c d
493505
:this-is-a-form b}"

0 commit comments

Comments
 (0)