Skip to content

Commit

Permalink
[Fix #360] Reindent after aligning
Browse files Browse the repository at this point in the history
  • Loading branch information
Malabarba committed Jan 16, 2016
1 parent b26d632 commit f9f3100
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 12 additions & 10 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -825,16 +825,18 @@ When called from lisp code align everything between BEG and END."
(save-excursion
(goto-char beg)
(while (clojure--find-sexp-to-align end)
(align-region (point)
(save-excursion
(backward-up-list)
(forward-sexp 1)
(point))
nil
'((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
(group . 1)
(repeat . t)))
nil))))
(let ((sexp-end (save-excursion
(backward-up-list)
(forward-sexp 1)
(point-marker)))
(clojure-align-forms-automatically nil))
(align-region (point) sexp-end nil
'((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
(group . 1)
(repeat . t)))
nil)
;; Reindent after aligning because of #360.
(indent-region (point) sexp-end)))))

;;; Indentation
(defun clojure-indent-region (beg end)
Expand Down
5 changes: 5 additions & 0 deletions test/clojure-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ x
how well
multiple words will work)")

(def-full-align-test nested-maps
"{:a {:a :a
:bbbb :b}
:bbbb :b}")


;;; Misc

Expand Down

2 comments on commit f9f3100

@bbatsov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a changelog, please. :-)

@Malabarba
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. :)

Please sign in to comment.