haskell / haskell/haskell-mode

Comments aren't taken into account when determining indent level

Open
#1,473 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

(Originally reported against Intero [here](https://github.com/commercialhaskell/intero/issues/336). All occurrences of "Intero" below mean "haskell-mode").

For example:
``` haskell
foo x = y
where
-- Let me tell you about @y@!
<-- Only TAB stop on this line is two spaces in from "where".
```
I would like to be able to indent the next line to the same level as the beginning of the comment.

On the other hand, Intero does take non-comment lines into account when determining indent level, so the following is handled correctly:
``` haskell
foo x = z
where
y = x
<-- Here I can TAB to the same indent level as "y".
```

Probably related: immediately after a `where`, Intero only supports indenting one level past the `where`, not indenting to the same level as the `where`. I thought of this as "Intero has an opinion about how to best indent my code", which is usually fine, since I can usually override Intero by manually indenting the first line (More important, common case: I'm editing an existing code base that aligns the `where`-clauses to the same level as the `where` keyword, and of course I don't want to indent all of them just to make Intero happy).

So, a simple fix might be to soften Intero's opinion of best indentation style: make the first TAB stop one more level in (or whatever Intero's opinion is), but make the "aligned with `where`" choice always be available as the second TAB stop.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.