Skip to content

Commit 51d6b48

Browse files
committed
[Fix clojure-emacs#608] Fix alignment issue involving margin comments.
Alignment wasn't working properly when nested, multi-line sexps were followed by margin comments.
1 parent e311868 commit 51d6b48

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
* [#588](https://github.com/clojure-emacs/clojure-mode/pull/588): Fix font-lock for character literals.
2626
* Stop `clojure-sort-ns` from calling `redisplay`.
27+
* [#608](https://github.com/clojure-emacs/clojure-mode/issues/608) Fix alignment issue involving margin comments at the end of nested forms.
2728

2829
### Changes
2930

clojure-mode.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ BOUND is bounds the whitespace search."
12601260
(unwind-protect
12611261
(ignore-errors
12621262
(clojure-forward-logical-sexp 1)
1263-
(search-forward-regexp "\\([,\s\t]*\\)" bound)
1263+
(search-forward-regexp "\\([,\s\t]*\\)\\(;+.*\\)?" bound)
12641264
(pcase (syntax-after (point))
12651265
;; End-of-line, try again on next line.
12661266
(`(12) (clojure--search-whitespace-after-next-sexp bound))

test/clojure-mode-indentation-test.el

+5
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,11 @@ x
705705
"#?@(:clj [2]
706706
:cljs [2])")
707707

708+
(when-aligning-it "should work correctly when margin comments appear after multi-line, non-terminal sexps"
709+
"(let [:x (+ 2 3
710+
3 4) ; comment
711+
:y (+ 1 2)])")
712+
708713
(it "should handle improperly indented content"
709714
(let ((content "(let [a-long-name 10\nb 20])")
710715
(aligned-content "(let [a-long-name 10\n b 20])"))

0 commit comments

Comments
 (0)