Skip to content

Introduce clojure-align-separator defcustom #488

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 1 commit into from
Sep 25, 2018
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 @@ -4,6 +4,7 @@

### New features

* [#481](https://github.com/clojure-emacs/clojure-mode/issues/481): Support vertical alignment even in the presence of blank lines, with the new `clojure-align-separator` user option.
* [#483](https://github.com/clojure-emacs/clojure-mode/issues/483): Support alignment for reader conditionals, with the new `clojure-align-reader-conditionals` user option.

## 5.9.1 (2018-08-27)
Expand Down
14 changes: 12 additions & 2 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,16 @@ will align the values like this:
:safe #'booleanp
:type 'boolean)

(defconst clojure--align-separator-newline-regexp "^ *$")

(defcustom clojure-align-separator clojure--align-separator-newline-regexp
"The separator that will be passed to `align-region' when performing verical alignment."
:package-version '(clojure-mode . "5.10")
:type `(choice (const :tag "Make blank lines prevent vertical alignment from happening."
,clojure--align-separator-newline-regexp)
(other :tag "Allow blank lines to happen within a vertically-aligned expression."
'entire)))

(defcustom clojure-align-reader-conditionals nil
"Whether to align reader conditionals, as if they were maps."
:package-version '(clojure-mode . "5.10")
Expand Down Expand Up @@ -1235,9 +1245,9 @@ When called from lisp code align everything between BEG and END."
(cl-incf count)))
(dotimes (_ count)
(align-region (point) sexp-end nil
'((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
`((clojure-align (regexp . clojure--search-whitespace-after-next-sexp)
(group . 1)
(separate . "^ *$")
(separate . ,clojure-align-separator)
(repeat . t)))
nil))
;; Reindent after aligning because of #360.
Expand Down