comparison .emacs.d/haskell-mode/examples/init.el @ 0:2764b4f45f9f

1st commit
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Mon, 21 Apr 2014 04:30:59 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2764b4f45f9f
1 ;; Sample file for the new session/process stuff
2 ;; Based on my own configuration. Well, it IS my configuration.
3 ;;
4 ;; NOTE: If you don't have cabal-dev, or you don't want to use it, you
5 ;; should change haskell-process-type (see below) to 'ghci.
6 ;;
7 ;; To merely TRY this mode (and for debugging), do the below:
8 ;;
9 ;; cd into haskell-mode's directory, and run
10 ;; $ emacs --load examples/init.el
11 ;;
12 ;; To get started, open a .hs file in one of your projects, and hit…
13 ;;
14 ;; 1. F5 to load the current file (and start a repl session), or
15 ;; 2. C-` to just start a REPL associated with this project, or
16 ;; 3. C-c C-c to build the cabal project (and start a repl session).
17
18 ;; Add the current dir for loading haskell-site-file.
19 (add-to-list 'load-path ".")
20 ;; Always load via this. If you contribute you should run `make all`
21 ;; to regenerate this.
22 (load "haskell-mode-autoloads")
23
24 ;; Customization
25 (custom-set-variables
26 ;; Use cabal-dev for the GHCi session. Ensures our dependencies are in scope.
27 ;;'(haskell-process-type 'cabal-dev)
28
29 ;; Use notify.el (if you have it installed) at the end of running
30 ;; Cabal commands or generally things worth notifying.
31 '(haskell-notify-p t)
32
33 ;; To enable tags generation on save.
34 '(haskell-tags-on-save t)
35
36 ;; To enable stylish on save.
37 '(haskell-stylish-on-save t))
38
39 (add-hook 'haskell-mode-hook 'haskell-hook)
40 (add-hook 'haskell-cabal-mode-hook 'haskell-cabal-hook)
41
42 ;; Haskell main editing mode key bindings.
43 (defun haskell-hook ()
44 ;; Use simple indentation.
45 (turn-on-haskell-simple-indent)
46 (define-key haskell-mode-map (kbd "<return>") 'haskell-simple-indent-newline-same-col)
47 (define-key haskell-mode-map (kbd "C-<return>") 'haskell-simple-indent-newline-indent)
48
49 ;; Load the current file (and make a session if not already made).
50 (define-key haskell-mode-map [?\C-c ?\C-l] 'haskell-process-load-file)
51 (define-key haskell-mode-map [f5] 'haskell-process-load-file)
52
53 ;; Switch to the REPL.
54 (define-key haskell-mode-map [?\C-c ?\C-z] 'haskell-interactive-switch)
55 ;; “Bring” the REPL, hiding all other windows apart from the source
56 ;; and the REPL.
57 (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
58
59 ;; Build the Cabal project.
60 (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
61 ;; Interactively choose the Cabal command to run.
62 (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
63
64 ;; Get the type and info of the symbol at point, print it in the
65 ;; message buffer.
66 (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
67 (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
68
69 ;; Contextually do clever things on the space key, in particular:
70 ;; 1. Complete imports, letting you choose the module name.
71 ;; 2. Show the type of the symbol after the space.
72 (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)
73
74 ;; Jump to the imports. Keep tapping to jump between import
75 ;; groups. C-u f8 to jump back again.
76 (define-key haskell-mode-map [f8] 'haskell-navigate-imports)
77
78 ;; Jump to the definition of the current symbol.
79 (define-key haskell-mode-map (kbd "M-.") 'haskell-mode-tag-find)
80
81 ;; Indent the below lines on columns after the current column.
82 (define-key haskell-mode-map (kbd "C-<right>")
83 (lambda ()
84 (interactive)
85 (haskell-move-nested 1)))
86 ;; Same as above but backwards.
87 (define-key haskell-mode-map (kbd "C-<left>")
88 (lambda ()
89 (interactive)
90 (haskell-move-nested -1))))
91
92 ;; Useful to have these keybindings for .cabal files, too.
93 (defun haskell-cabal-hook ()
94 (define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
95 (define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal)
96 (define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring)
97 (define-key haskell-cabal-mode-map [?\C-c ?\C-z] 'haskell-interactive-switch))