2

I was following this guide to set up code folding for Emacs in Haskell.

But it does not seem to work: when I do what says in that guide and I try to fold code with the keybindings then it just does not work, nothing happens.

If you use Emacs to fold Haskell code could you please share the secret how you do it ?

Haskell folding works quite nicely with vim, :set foldmethod=indent, then I can just do zc zo and Haskell code folds in and out, now, how can I do something like that in Emacs ?

I have spent already a few hours trying to figure that out but I failed, someone please enlighten me.

jhegedus
  • 20,244
  • 16
  • 99
  • 167

2 Answers2

1

I'm not sure how up to date is the Haskell wiki. I prefer vimish-fold for folding Haskell code in Emacs. For folding all you have to is, select your code and then apply this function vimish-fold. For unfolding, go to the beginning of the folded code and run the command vimish-fold-unfold.

enter image description here

Sibi
  • 47,472
  • 16
  • 95
  • 163
0

You can use Emacs' outline-mode as described here. Although the article is from 2013, the solution just worked fine for me.

One thing the article doesn't mention is that you can use M-x package-install RET outline-magic in order to install it, instead of doing so manually. (Because Emacs' package manager didn't exist back in 2013.)

Mekeor Melire
  • 502
  • 5
  • 15
  • The link is dead but the Web Machine remembers: https://web.archive.org/web/20170102030836/http://blog.bezirg.net/posts/2013-08-01-outlining-haskell-code-with-emacs.html – Artem Pelenitsyn Dec 29 '21 at 21:50