Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Haskell indentation

Tags:

Please help me set up proper indentation in Emacs haskell-mode

When I'm trying to type down something like ADT or a record, I'm getting on the wrong column after pressing <ENTER>, and pressing <TAB> won't switch to the right one until I enter either | or ';'!

data MyADT = Oh            | Hi            | Hello              | <- the cursor is here again! 

Trying to solve the problem I set

(define-key global-map (kbd "RET") 'reindent-then-newline-and-indent) 

in my .emacs file, but it won't indent the current line on pressing <enter> too!

Another strange behaviour: indentation of case

oneChar c =  case lookup c simpleEscapes of   | <- what? here?! 
like image 980
Valentin Golev Avatar asked Nov 12 '10 23:11

Valentin Golev


1 Answers

It sounds like you type <Enter> and then "|" and then <Tab>. If I do that, I get the same results. But if I type <Enter> and then <Tab> and then <Tab> again it automatically inserts the "|" and lines it up correctly, like so:

data MyADT = Oh            | Hi            |<Cursor> 

When I check my haskell-mode version using M-x eval-expression haskell-version <Enter> I get "v2_4".

Emacs haskell-mode doesn't fully analyze the source code, so the "automatic" features are approximate, I think. Typing <Tab> several times on a new line cycles through several possible indentations, and also sometimes inserts text like the "|" for algebraic data types.

like image 143
Harold L Avatar answered Sep 27 '22 23:09

Harold L