-
-
Notifications
You must be signed in to change notification settings - Fork 247
Not properly indenting "let" binding sequences #45
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
Comments
I have a similar issue that may or may not be related. When you have a multi-line condition in a 'cond' block, the code is inappropriately indented to the right, like so: (cond (or (= foo 69)
(= foo 42)) (println "foo is magic")
(= foo (Math/sqrt -1)) (println "foo is imaginary")) Here, the lowest line should be aligned with the "(or ...", not the other "(= ...)" lines. version 1.11.5 |
With clojure-mode 2.0, you can fix the "cond" problem by adding the following to your .emacs. You need to repeat 6 8 as many times as you're likely to have clauses in your cond. I'm working on a patch to simplify that. (put 'cond 'clojure-backtracking-indent '(6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8)) Sorry, I've got nothing for the "let" case. It's more complicated because (I think) the [square brackets] don't count as a s-expr so the backtracking doesn't work right. I'm not really sure about that. |
My English is poor, but I hope you can understand me. Hi @bbatsov (progn
(if (not (> (save-excursion (forward-line 1) (point))
calculate-lisp-indent-last-sexp))
(progn (goto-char calculate-lisp-indent-last-sexp)
(beginning-of-line)
(parse-partial-sexp (point)
calculate-lisp-indent-last-sexp 0 t)))
;; Indent under the list or under the first sexp on the same
;; line as calculate-lisp-indent-last-sexp. Note that first
;; thing on that line has to be complete sexp since we are
;; inside the innermost containing sexp.
(backward-prefix-chars)
(current-column)) This code means that return a column number of first S-expression of the previous line. (let [[x
y] (range 2) ; --> indent level 3; ([[
[a ; --> indent level 2; ([
b] (["foo" "bar"])]
(print x y a b)) So, we need to make sure whether the previous line and the indentation level of the current line are equal. |
I'm not sure if "+1"s are useful, but I run into this one all the time. I sometimes work around it by writing ugly code: (let [[a b
c]
(foo bar)
d 41]) instead of the more natural but wrongly indented (let [[a b
c] (foo bar)
d 41]) Obviously all of this code looks silly, but it makes sense when you are either: a. Destructuring lots of values and need to wrap to a new line |
Patches are way more useful. :-) I have a ton of work and fixing this is pretty low on my todo list, so help is welcome. |
"let" binding blocks containing complex bindings are not indented properly.
Notice that the line that starts with
[a ...]
is lined up under they
in the line above. It should line up under the[x ...
. It appears to be a problem with having 2 s-expressions on the lines starting[x ...
The text was updated successfully, but these errors were encountered: