Emacs/Keybindings and simple usage
From HaskellWiki
m (Added next link.) |
(Added note about rebinding C-x C-s.) |
||
| Line 45: | Line 45: | ||
You can also use haskell-mode to load Emacs buffers with Haskell code in either Hugs or GHC. To load something in Hugs or ghci, type <code>C-c C-l</code> to load the file. Then, you can go on to type <code>C-c C-r</code> (or simply <code>C-c C-l</code> again) to reload the current module when you have made a change. | You can also use haskell-mode to load Emacs buffers with Haskell code in either Hugs or GHC. To load something in Hugs or ghci, type <code>C-c C-l</code> to load the file. Then, you can go on to type <code>C-c C-r</code> (or simply <code>C-c C-l</code> again) to reload the current module when you have made a change. | ||
| + | |||
| + | == Rebind C-x C-s == | ||
| + | |||
| + | To do specific actions on save, you need <code>haskell-mode-save-buffer</code>. It is recommended to rebind <code>C-x C-s</code> in haskell-mode to this. Add the following in your <code>haskell-mode-hook</code>. | ||
| + | |||
| + | (define-key haskell-mode-map (kbd "C-x C-s") 'haskell-mode-save-buffer) | ||
| + | |||
| + | Then you're good to go. This will behave the same as normal <code>save-buffer</code>, but with extra goodies if enabled. | ||
---- | ---- | ||
'''Next:''' [[Emacs/Indentation|Indentation]] | '''Next:''' [[Emacs/Indentation|Indentation]] | ||
Current revision
1 Key bindings and usage
Key bindings in haskell-mode (with haskell-indent and inf-haskell.el).
Code editing keys:
C-c C-=inserts ansign and lines up type signatures and other pattern matches nicely.=C-c C-|inserts a guardC-c C-oinserts a guardand lines up existing guards| otherwise =C-c C-winserts a where keywordC-c C-.aligns code over a region in a "sensible" fashion.
Haskell interpreter keys:
C-c C-lload current buffers file into Haskell interpreterC-c C-rreload current Haskell interpreter sessionC-c C-tgets :type for symbol at point, and remembers itC-u C-c C-tinserts a type annotation, for symbol at point, on the line aboveC-c C-igets :info for symbol at pointC-c M-.find definition of (interpreted) symbol at pointC-c C-borC-c C-zswitch to Haskell interpreter (starts one if needed)C-c C-dfind haddock documentation about symbolC-c TABquery the haskell interpreter for the info of the given expressionC-c C-vcheck current buffers file with hlint
(See C-h m for more information).
2 Example
Here's an example forC-c C-=. Put your cursor after C-c C-=
blah :: Int -> Int blah myInt
note how the function signature is reindented to match the column of the = sign.
blah :: Int -> Int blah myInt =
You could also achieve the same effect by selecting the region and typing C-c C-.
You can also use haskell-mode to load Emacs buffers with Haskell code in either Hugs or GHC. To load something in Hugs or ghci, type C-c C-l to load the file. Then, you can go on to type C-c C-r (or simply C-c C-l again) to reload the current module when you have made a change.
3 Rebind C-x C-s
To do specific actions on save, you need haskell-mode-save-buffer. It is recommended to rebind C-x C-s in haskell-mode to this. Add the following in your haskell-mode-hook.
(define-key haskell-mode-map (kbd "C-x C-s") 'haskell-mode-save-buffer)
Then you're good to go. This will behave the same as normal save-buffer, but with extra goodies if enabled.
Next: Indentation
