Skip to content

Support shallow indentation #366

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

Closed
mkscrg opened this issue Oct 29, 2014 · 10 comments
Closed

Support shallow indentation #366

mkscrg opened this issue Oct 29, 2014 · 10 comments

Comments

@mkscrg
Copy link

mkscrg commented Oct 29, 2014

I find myself writing Haskell with mostly 4-space indents from the prior line. That applies in a lot of cases, e.g.

foobar :: Foo -> Bar
foobar foo = doSomething $
    withALong subexpression (thatDoesnt fitOn) thePrevious $ line foo

or

data Foo = Foo
    { fooBar :: Bar
    , fooBaz :: Baz
    , fooQux :: Qux
    } deriving (Eq, Show, Ord)

In fact, I find myself using 4-space indentation much more often than "align under start of this expression", which seems to be the haskell-mode approach.

Can I use haskell-mode with its indentation features disabled? 4-space indents are really easy to maintain by hand, and I find haskell-mode's other features very useful!

@ivan-m
Copy link
Contributor

ivan-m commented Oct 30, 2014

Sure: choose simple-indent mode.

@mkscrg
Copy link
Author

mkscrg commented Oct 30, 2014

I don't think that's it! Simple mode aligns code to each successive "non-whitespace character following whitespace" as noted in the docs:

  turn-on-haskell-simple-indent

A very simple indentation scheme; In this scheme, TAB will now move the cursor to the next indent point in the previous non-blank line. An indent point is a non-whitespace character following whitespace.

@ivan-m
Copy link
Contributor

ivan-m commented Oct 30, 2014

Or don't use any indentation mode at all then.

@purcell
Copy link
Member

purcell commented Oct 30, 2014

Or don't use any indentation mode at all then.

Doesn't haskell-mode protest loudly when no indentation mode is set?

@mkscrg
Copy link
Author

mkscrg commented Oct 30, 2014

Doesn't haskell-mode protest loudly when no indentation mode is set?

That's what I ran into and what led to this question. @ivan-m, how does one turn off all indentation modes?

@listx
Copy link

listx commented Oct 30, 2014

I have (remove-hook 'haskell-mode-hook 'turn-on-haskell-indent) in my configs, and use my own stupid indentation bindings. (shameless plug: https://github.com/listx/kakapo-mode --- it only depends on indent-tabs-mode and tab-width variables to figure out indentation).

@ivan-m
Copy link
Contributor

ivan-m commented Oct 30, 2014

Huh... I don't have any indentation set, but then again I'm using structured-haskell-mode which might be setting it.

@mkscrg
Copy link
Author

mkscrg commented Nov 5, 2014

Ok, glad that works well!

The issue here is haskell-mode doesn't have a built-in way to

  • turn off the indentation modes
  • support 2/4-space indentation instead of "align on expression" indentation

@gracjan
Copy link
Contributor

gracjan commented Mar 29, 2015

@mkscrg: Me too! This is a reallly good idea as one of possible options for haskell-indentation.

@gracjan gracjan changed the title Support shallow indentation? Support shallow indentation Mar 29, 2015
@gracjan gracjan changed the title Support shallow indentation [Discussion] Support shallow indentation Aug 30, 2015
@gracjan
Copy link
Contributor

gracjan commented Dec 5, 2015

So I worked a little on this and haskell-indentation is pretty close to supporting what we want here.

@gracjan gracjan changed the title [Discussion] Support shallow indentation Support shallow indentation Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants