4

I am currently using Emacs as my primary IDE for developing Haskell code and I am really satisfied so far. But at the moment I can't figure out one little detail, namely how to customize the indentation width to be 4 instead of 2.

Currently I have turned on the haskell-indentation in haskell-mode, but I can't figure out what variable I have to set to customize the indentation width. So far I have tried to set '(haskell-indent-spaces 4) but this doesn't seem to have any effect at all...

Thx in advance for any help!

bmk
  • 1,548
  • 9
  • 17
  • Based on [the source](https://github.com/haskell/haskell-mode/blob/master/haskell-indentation.el) it looks like `2` is hardcoded in the file. – gallais Sep 05 '15 at 11:52
  • 1
    @gallais Thx for your reply. I guess for the time being, I have to edit the source code directly then. Can you post this as an answer, so that I can acccept it? – bmk Sep 07 '15 at 05:55

2 Answers2

6

haskell-indentation-mode offers a couple of knobs you can turn to customize indentation offsets:

haskell-indentation-layout-offset
haskell-indentation-starter-offset
haskell-indentation-left-offset
haskell-indentation-ifte-offset
haskell-indentation-where-pre-offset
haskell-indentation-where-post-offset

All of those are customization variables so you can do M-x customize-option RET and customize any of those, or if you prefer programatically:

(custom-set-variables
 ;; Customization related to indentation.
 '(haskell-indentation-layout-offset 4)
 '(haskell-indentation-starter-offset 4)
 '(haskell-indentation-left-offset 4)
 '(haskell-indentation-where-pre-offset 4)
 '(haskell-indentation-where-post-offset 4)
 )
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
Gracjan Polak
  • 596
  • 3
  • 16
  • Worked great for me! I adjusted haskell-indentation-where-pre-offset and haskell-indentation-where-post-offset to 2 though, to achieve slightly different behaviour for where, but this is certainly the best solution I found. – Martinsos Jul 23 '19 at 22:41
4

Based on the source of haskell-indentation, it looks like 2 is hardcoded in the file so you'll have to edit it manually.

gallais
  • 11,823
  • 2
  • 30
  • 63