perfect? clojure environment

Download Perfect? clojure environment

If you can't read please download the document

Upload: john-stevenson

Post on 16-Apr-2017

5.040 views

Category:

Technology


0 download

TRANSCRIPT

(Perfect?

Environment)

ClojureMadeSimple.co.uk

Information covered in this presentation is also detailed on my website

slideshare.net/jr0cket

This slide deck is available to follow along with on slideshare.net

Something simple to start with

A taste of things to come

Get Emacs

(sorry vi people)

Download & Install Emacs

Linuxsudo apt-add-repository ppa:cassou/emacs sudo apt-get updatesudo apt-get install emacs-snapshot emacs-goodies-el

MacEmacsForMacOSX.com

WindowsUse Cygwin?

In the meantime: Usual Suspects

Netbeans IntelliJEclipse

Configure emacs

you will have an .el of a time

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.

Give Emacs a Clojure injection

lots of starter-kits, only one for Clojure

Automatic Clojure install

get your Clojure fix quickly

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/"))(package-initialize)

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 rainbow-delimiters ac-slime markdown-mode ))

(dolist (p my-packages) (when (not (package-installed-p p)) (package-install p)))

Didn't get all that typed??

Clone my Emacs Clojure Kickstart repository on github.com/jr0cket

git clone https://[email protected]/ 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

Re-start Emacs

watch clojure and other goodies be automatically downloaded and added.

In the meantime, Clooj

Clojure IDE in Clojure

github.com/arthuredelstein/clooj

github.com/arthuredelstein/clooj

Back to Emacs

keyboard on stun !!

Editing text...

...should be easy, right?

Using a mouse is bad for your health

Moving along a line

C aGo to start of a line

C eGo to end of a line

Searching for something...

C sSearch forward

C rSearch backwards

Select / Copy / Paste

C @

Or to select, use the mouse, Luke

Select / Copy / Paste

C kcut line

C wcut selected

Select / Copy / Paste

C y

Yank that text into your code

Undo / Redo

C - _

Go back change by change

Undo / Redo

C - ???

Go forward change by change

Some core keyboard commands

C g

Hit as many times as necessary to cancel a keyboard command

Getting help with keyboard commands

Just the bindings,
ma'am

C h b

List all the current keyboard bindings configured in Emacs

Just the modes,
ma'am

C h m

Modes can be either major or minor and many can be used together.

F1 bF1 m

F1 function key is the same as help C - h

Function keys Help

Funky stuff

C tSwap the current character with the previous one- good for erratic typing

Transpose characters

C +C -Make your text big for the people at the back of the room

Coding Demo? Super-size it!

Clojure project management

Leiningen

more fun than maven

Leiningen

lein newlein depslein repllein jack-in

Create a new clojure project

Download all dependencies

Start the interactive shell (repl)

Start repl server

leiningen.org

lein new my-projectcd my-projectlein deps

Create a new project

cd my-projectemacs project.clj

Open project in emacs

Default project definition

Add a REPL server

Dev Dependencies

Add libraries only needed for developmentNot packaged when deployed

Clojure project management in Emacs

C c fSelect one of the files available in the current Clojure project- the file doesnt have to be open in Emacs

Find file in project

M x clojure-jack-in

Fire up the REPL

C c C j

Define your own Global short-cut

(global-set-key (kbd "C-c C-j") 'clojure-jack-in)

Open your .emacs.d/init.el file and add:

In Emacs, start the REPL with

More Cool short-cuts later

but its easy, right!

Navigating functions
(s-expressions)

C M fC M bC M uSkip through your function piece by piece

Jump around in functions

C M HomeC M End Skip through your code function by function

Jump between function definitions

C M aC M eJump to the start or end of a function definintion

Jump between function definitions

Keep balanced,

use

ParEdit

ParEdit matches ( [ { '

Prevents unbalanced parents and quotes

ExampleCant delete either parens that surround characters (fubar) without first deleting all the characters

Pull code into brackets

Reorganise code around brackets

Pull code in

M )

Pull the next block of code inside

Push code in

M (

Push the next block of code outside ??????

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-c C-d C-d: Look up documentation for a var C-c C-z: Switch from a Clojure buffer to the repl buffer C-c M-p: Switch the repl namespace to match the current buffer C-c C-w c: List all callers of a given function

Auto-complete

The easy way

Clone Sam Aarons Live Coding repositorygithub.com/overtone/emacs-live

The manual way

Add the auto-complete package dependencies to ~/.emacs.d/init.elpopup

Download the Git repository https://github.com/m2ym/auto-completeM x load-file autocomplete/etc/install.el

Other cool stuff to help you discover Clojure

ClojureAtlas.com

Light Table (On Kickstarter)

Thank you

London Clojurians

@jr0cket ClojureMadeSimple.co.uk

C means control key, M means meta key

Muokkaa otsikon tekstimuotoa napsauttamalla

Muokkaa jsennyksen tekstimuotoa napsauttamallaToinen jsennystasoKolmas jsennystasoNeljs jsennystasoViides jsennystasoKuudes jsennystasoSeitsems jsennystasoKahdeksas jsennystasoYhdekss jsennystaso