Skip to content
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 @@ -6,6 +6,7 @@

* [#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.
* [#497](https://github.com/clojure-emacs/clojure-mode/pull/497) Indent "let", "when" and "while" as function form if not at start of a symbol

### Bugs fixed

Expand Down
5 changes: 4 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,10 @@ symbol properties."
'clojure-indent-function)
(get (intern-soft (match-string 1 function-name))
'clojure-backtracking-indent)))
(when (string-match (rx (or "let" "when" "while") (syntax symbol))
;; indent symbols starting if, when, ...
;; such as if-let, when-let, ...
;; like if, when, ...
(when (string-match (rx string-start (or "if" "when" "let" "while") (syntax symbol))
function-name)
(clojure--get-indent-method (substring (match-string 0 function-name) 0 -1)))))

Expand Down
4 changes: 3 additions & 1 deletion test/clojure-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ values of customisable variables."
(def-full-indent-test let-when-while-forms
"(let-alist [x 1]\n ())"
"(while-alist [x 1]\n ())"
"(when-alist [x 1]\n ())")
"(when-alist [x 1]\n ())"
"(if-alist [x 1]\n ())"
"(indents-like-fn-when-let-while-if-are-not-the-start [x 1]\n ())")

(defun indent-cond (indent-point state)
(goto-char (elt state 1))
Expand Down