Skip to content

Commit b807971

Browse files
committed
Merge branch 'master' of github.com:CommBank/emacs24-starter-kit into CommBank-master
2 parents 8a8f8ec + b55f03a commit b807971

File tree

2 files changed

+144
-2
lines changed

2 files changed

+144
-2
lines changed

starter-kit-haskell.org

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,57 @@ This is part of the [[file:starter-kit.org][Emacs Starter Kit]].
99
:END:
1010
Support for editing Haskell
1111

12+
** Setting up cabal
13+
You can skip these steps if you've already setup ghc and cabal
14+
*** Install cabal
15+
**** Linux (Debian/Ubuntu)
16+
#+begin_src sh
17+
sudo apt-get update
18+
sudo apt-get install ghc cabal-install
19+
cabal update
20+
#+end_src
21+
22+
**** OS X [with Homebrew]
23+
#+begin_src sh
24+
brew update
25+
brew install ghc cabal-install
26+
cabal update
27+
#+end_src
28+
29+
*** Update cabal
30+
#+start_src sh
31+
cabal install cabal-install
32+
#+end
33+
34+
*** Set path to ~/.cabal/bin
35+
#+begin_src sh
36+
echo 'PATH=~/.cabal/bin:$PATH'|tee -a ~/.profile
37+
source ~/.profile
38+
which cabal
39+
#+end_src
40+
41+
The last line should show you that you are now using the local and
42+
latest version of cabal located in your ~/.cabal/bin directory.
43+
44+
*** Innstall Packages for Development
45+
46+
Haskell modes usually have two components to them. One side is haskell
47+
and the other side is installed and configured in Emacs
48+
49+
We will want to install some basic haskell packages in our ~/.cabal &
50+
~/.ghc user directories. This makes them available along side cabal
51+
for doing development on your projects.
52+
53+
Running those commands in the shell might take some time - emacs
54+
appears to be frozen; trust me, it's not
55+
#+begin_src sh
56+
cabal install happy alex ;# needed but not listed as dependency
57+
#+end_src
58+
59+
Paste the following into your terminal:
60+
61+
62+
** Pretty lambdas
1263
pretty lambdas in Haskell code
1364
#+begin_src emacs-lisp
1465
(defun pretty-lambdas-haskell ()
@@ -19,9 +70,98 @@ pretty lambdas in Haskell code
1970
nil))))))
2071
#+end_src
2172

22-
Haskell mode hook
73+
74+
** Haskell Mode
75+
*** Install Haskell mode
76+
#+begin_src emacs-lisp
77+
(starter-kit-install-if-needed 'haskell-mode)
78+
#+end_src
79+
80+
*** Configure
2381
#+begin_src emacs-lisp
2482
(add-hook 'haskell-mode-hook 'run-starter-kit-coding-hook)
2583
(when (window-system)
2684
(add-hook 'haskell-mode-hook 'pretty-lambdas-haskell))
85+
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
86+
;; Ignore compiled Haskell files in filename completions
87+
(add-to-list 'completion-ignored-extensions ".hi")
88+
#+end_src
89+
90+
91+
** Stylish Haskell
92+
A simple Haskell code prettifier.
93+
94+
This tool tries to help where necessary without getting in the way.
95+
96+
*Features*
97+
98+
- Aligns and sorts import statements
99+
- Groups and wraps {-# LANGUAGE #-} pragmas, can remove (some)
100+
redundant pragmas
101+
- Removes trailing whitespace
102+
- Replaces tabs by four spaces (turned off by default)
103+
- Replaces some ASCII sequences by their Unicode equivalents (turned
104+
off by default)
105+
106+
#+begin_src sh
107+
cabal install stylish-haskell
108+
#+end_src
109+
*** Configuration
110+
To call it for every save, make sure you have C-x C-s rebound to
111+
haskell-mode-save-buffer.
112+
113+
#+begin_src emacs-lisp
114+
(defadvice haskell-mode-stylish-buffer (around skip-if-flycheck-errors activate)
115+
(unless (flycheck-has-current-errors-p 'error)
116+
ad-do-it))
117+
(setq haskell-stylish-on-save t)
118+
#+end_src
119+
120+
** GHC mod
121+
The ghc-mod command is a backend command to enrich Haskell programming
122+
on editors including Emacs, Vim, and Sublime.
123+
*** Install ghc-mod
124+
#+begin_src sh
125+
cabal install ghc-mod
126+
#+end_src
127+
#+begin_src emacs-lisp
128+
(starter-kit-install-if-needed 'ghc)
129+
#+end_src
130+
131+
132+
** Structured Haskell
133+
This minor mode provides structured editing operations based on the
134+
syntax of Haskell. In short-hand it's called SHM and throughout the
135+
codebase, too. It acts a bit like, and is heavily inspired by,
136+
paredit-mode for Emacs.
137+
138+
*** Install structured Haskell
139+
#+begin_src sh
140+
cabal install structured-haskell
141+
#+end_src
142+
#+begin_src emacs-lisp
143+
(starter-kit-install-if-needed 'shm)
144+
#+end_src
145+
146+
*** Configure
147+
#+begin_src emacs-lisp
148+
(add-hook 'haskell-mode-hook 'structured-haskell-mode)
149+
;; The following are apparently pretty good for solarized-light.
150+
;;(set-face-background 'shm-current-face "#eee8d5")
151+
;;(set-face-background 'shm-quarantine-face "lemonchiffon")
152+
#+end_src
153+
154+
155+
** Installing Haskell-Mode Extensions
156+
*** Install flycheck
157+
#+begin_src emacs-lisp
158+
(starter-kit-install-if-needed 'flycheck)
159+
(add-hook 'flycheck-mode-hook #'flycheck-haskell-setup)
160+
(global-flycheck-mode)
161+
#+end_src
162+
*** Install flyspell-haskell
163+
#+begin_src emacs-lisp
164+
(starter-kit-install-if-needed 'flyspell)
165+
(add-hook 'haskell-mode-hook 'flyspell-prog-mode)
27166
#+end_src
167+

starter-kit.org

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ project is not in elpa.
407407
After we've loaded all the Starter Kit defaults, lets load the User's stuff.
408408
#+name: starter-kit-load-files
409409
#+begin_src emacs-lisp
410-
(flet ((sk-load (base)
410+
(cl-flet ((sk-load (base)
411411
(let* ((path (expand-file-name base starter-kit-dir))
412412
(literate (concat path ".org"))
413413
(encrypted-org (concat path ".org.gpg"))
@@ -436,6 +436,8 @@ After we've loaded all the Starter Kit defaults, lets load the User's stuff.
436436
:test #'string=)))))
437437
#+end_src
438438

439+
#+RESULTS: starter-kit-load-files
440+
439441
*** Settings from M-x customize
440442
#+name: m-x-customize-customizations
441443
#+begin_src emacs-lisp

0 commit comments

Comments
 (0)