Discovering the Clojure language is more effective when you have good tool support. I cover the setup of a really great (perfect?) clojure development environment using
Emacs 24
Clojure mode
Marmalade repository
Leiningen build tool
Autocomplete manual installation
Lightbox, the future of Clojure IDE's ?
Thank you.
8. Get Emacs
(sorry vi people)
C – means control key, M – means meta key
9. Download & Install Emacs
Linux
sudo apt-add-repository
ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs-snapshot
Mac Windows
EmacsForMacOSX.com Use Cygwin?
C – means control key, M – means meta key
10. In the meantime: Usual Suspects
Netbeans
IntelliJ
Eclipse
C – means control key, M – means meta key
11. Configure emacs
… you will have an .el of a time
C – means control key, M – means meta key
12. Configs live in ~/.emacs.d folder
~/.emacs.d
folder created when Emacs first run
~/.emacs.d/init.el
main configuration file for Emacs
You can define multiple .el config files as long as they are on the
Emacs load path. init.el is the read first.
C – means control key, M – means meta key
13. Give Emacs a
Clojure injection
… lots of starter-kits, only one for Clojure
C – means control key, M – means meta key
15. Add the package repository
;; Add Marmalade package archive for Emacs starter kit
;; and tonnes of other packages to your .emacs.d/init.el
(require 'package)
(add-to-list
'package-archives
'("marmalade" .
"http://marmalade-
repo.org/packages/"))
C – means control key, M – means meta key
16. Specify package to load
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(starter-kit
starter-kit-lisp
starter-kit-
eshell
starter-kit-
bindings
clojure-mode
clojure-test-mode M – means meta key
C – means control key,
17. Didn't get all that typed??
Clone my Emacs Clojure Kickstart repository on
github.com/jr0cket
git clone
https://jr0cket@github.com/
jr0cket/Emacs-clojure-
kickstart.git
~/.emacs.d
The git clone command should all be on one line, but would not be as readable on the slide
C – means control key, M – means meta key
18. Re-start Emacs
… watch clojure and other goodies be
automatically downloaded and added.
C – means control key, M – means meta key
19. In the meantime, Clooj
Clojure IDE in Clojure
github.com/arthuredelstein/clooj
C – means control key, M – means meta key
43. le in in g e n
Leiningen
.o rg
lein new Create a new clojure project
lein deps Download all dependencies
lein repl Start the interactive shell (repl)
lein jack-in Start repl server
C – means control key, M – means meta key
44. Create a new project
lein new my-project
cd my-project
lein deps
C – means control key, M – means meta key
45. Open project in emacs
cd my-project
emacs project.clj
C – means control key, M – means meta key
51. Find file in project
C – c f
Select one of the files available in the current
Clojure project
- the file doesnt have to be open in Emacs
C – means control key, M – means meta key
52. Fire up the REPL
M – x
clojure-
jack-in
C – means control key, M – means meta key
53. Define your own Global short-cut
Open your .emacs.d/init.el file and add:
(global-set-key
(kbd "C-c C-j") 'clojure-jack-
in)
In Emacs, start the REPL with
C – c C – j
C – means control key, M – means meta key
54. More Cool short-cuts
later
… but its easy, right!
C – means control key, M – means meta key
56. Jump around in functions
C – M – f
C – M – b
C – M – u
C – means control key, M – means meta key
57. Jump between function
definitions
C – M – Home
C – M – End
Skip through your code function by function
C – means control key, M – means meta key
58. Jump between function
definitions
C – M – a
C – M – e
Jump to the start or end of a function definintion
C – means control key, M – means meta key
59. Keep balanced,
use
ParEdit
C – means control key, M – means meta key
60. ParEdit matches ( [ { ' ”
Prevents unbalanced parents and quotes
Example
Cant delete either parens that surround characters
(fubar) without first deleting all the characters
Pull code into brackets
Reorganise code around brackets
C – means control key, M – means meta key
61. Pull code in
M – )
Pull the next block of code inside
C – means control key, M – means meta key
62. Push code in
M – (
Push the next block of code outside ??????
C – means control key, M – means meta key
63. Clojure related commands
C-c TAB: Autocomplete symbol at point
C-x C-e: Eval the form under the point
C-c C-k: Compile the current buffer
C-c C-l: Load current buffer and force
dependent namespaces to reload
M-.: Jump to the definition of a var
C-c S-i: Inspect a value
C-c C-m: Macroexpand the call under the point
C – means control key, M – means meta key
65. The easy way
Clone Sam Aarons Live Coding repository
github.com/overtone/emacs-live
C – means control key, M – means meta key
66. The manual way
Add the auto-complete package dependencies to
~/.emacs.d/init.el
popup
Download the Git repository
https://github.com/m2ym/auto-complete
M – x load-file
autocomplete/etc/install.el
C – means control key, M – means meta key
67. Other cool stuff to help
you discover Clojure
C – means control key, M – means meta key