Skip to content

Fix alignment issue involving margin comments. #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

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

### Changes

Expand Down
6 changes: 5 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,9 @@ Place point as in `clojure--position-for-alignment'."

(defun clojure--search-whitespace-after-next-sexp (&optional bound _noerror)
"Move point after all whitespace after the next sexp.
Additionally, move past a comment if one exists (this is only
possible when the end of the sexp coincides with the end of a
line).

Set the match data group 1 to be this region of whitespace and
return point.
Expand All @@ -1260,7 +1263,8 @@ BOUND is bounds the whitespace search."
(unwind-protect
(ignore-errors
(clojure-forward-logical-sexp 1)
(search-forward-regexp "\\([,\s\t]*\\)" bound)
;; Move past any whitespace or comment.
(search-forward-regexp "\\([,\s\t]*\\)\\(;+.*\\)?" bound)
(pcase (syntax-after (point))
;; End-of-line, try again on next line.
(`(12) (clojure--search-whitespace-after-next-sexp bound))
Expand Down
Loading