Skip to content

Commit

Permalink
shuffling lisp bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
eschulte committed Oct 31, 2010
1 parent f76a12d commit 6ac95dc
Showing 1 changed file with 98 additions and 89 deletions.
187 changes: 98 additions & 89 deletions starter-kit-lisp.org
Expand Up @@ -10,11 +10,11 @@ Support for editing list dialects including [[* Emacs Lisp][Emacs Lisp]], [[* Sc
** Define keys
#+srcname: starter-kit-define-lisp-keys
#+begin_src emacs-lisp
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
;; (define-key lisp-mode-shared-map (kbd "C-c l") "lambda")
(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key lisp-mode-shared-map (kbd "C-\\") 'lisp-complete-symbol)
(define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
;; (define-key lisp-mode-shared-map (kbd "C-c l") "lambda")
(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key lisp-mode-shared-map (kbd "C-\\") 'lisp-complete-symbol)
;; (define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)
#+end_src

** Paredit
Expand Down Expand Up @@ -51,6 +51,7 @@ back, =C-M-u= up, =C-M-d= down)
(add-hook 'emacs-lisp-mode-hook 'esk-remove-elc-on-save)
;; (add-hook 'emacs-lisp-mode-hook 'idle-highlight)
(add-hook 'emacs-lisp-mode-hook 'turn-on-paredit)
(define-key emacs-lisp-mode-map (kbd "C-c v") 'eval-buffer)

(defun esk-remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid."
Expand All @@ -67,92 +68,100 @@ back, =C-M-u= up, =C-M-d= down)
** Clojure

#+begin_src emacs-lisp
(add-hook 'clojure-mode-hook 'run-coding-hook)
;; (add-hook 'clojure-mode-hook 'idle-highlight)

(font-lock-add-keywords 'clojure-mode
'(("(\\|)" . 'esk-paren-face)))

(defface esk-clojure-trace-face
'((((class color) (background dark))
(:foreground "grey50"))
(((class color) (background light))
(:foreground "grey55")))
"Face used to dim parentheses."
:group 'starter-kit-faces)

(setq esk-clojure-trace-face 'esk-clojure-trace-face)

;; This will make relevant lines stand out more in stack traces
(defun sldb-font-lock ()
(font-lock-add-keywords nil
'(("[0-9]+: \\(clojure\.\\(core\\|lang\\).*\\)"
1 esk-clojure-trace-face)
("[0-9]+: \\(java.*\\)"
1 esk-clojure-trace-face)
("[0-9]+: \\(swank.*\\)"
1 esk-clojure-trace-face)
("\\[\\([A-Z]+\\)\\]"
1 font-lock-function-name-face))))

(add-hook 'sldb-mode-hook 'sldb-font-lock)

(defun slime-jump-to-trace (&optional on)
"Jump to the file/line that the current stack trace line references.
Only works with files in your project root's src/, not in dependencies."
(interactive)
(save-excursion
(beginning-of-line)
(search-forward-regexp "[0-9]: \\([^$(]+\\).*?\\([0-9]*\\))")
(let ((line (string-to-number (match-string 2)))
(ns-path (split-string (match-string 1) "\\."))
(project-root (locate-dominating-file default-directory "src/")))
(find-file (format "%s/src/%s.clj" project-root
(mapconcat 'identity ns-path "/")))
(goto-line line))))

(eval-after-load 'slime
'(progn
(defalias 'sldb-toggle-details 'slime-jump-to-trace)
(defun sldb-prune-initial-frames (frames)
"Show all stack trace lines by default."
frames)))

(eval-after-load 'find-file-in-project
'(add-to-list 'ffip-patterns "*.clj"))

;; You might like this, but it's a bit disorienting at first:
(add-hook 'clojure-mode-hook 'turn-on-paredit)

(defun clojure-project (path)
"Setup classpaths for a clojure project and starts a new SLIME session.

Kills existing SLIME session, if any."
(interactive (list
(ido-read-directory-name
"Project root: "
(locate-dominating-file default-directory "pom.xml"))))
(when (get-buffer "*inferior-lisp*")
(kill-buffer "*inferior-lisp*"))
(add-to-list 'swank-clojure-extra-vm-args
(format "-Dclojure.compile.path=%s"
(expand-file-name "target/classes/" path)))
(setq swank-clojure-binary nil
swank-clojure-jar-path (expand-file-name "target/dependency/" path)
swank-clojure-extra-classpaths
(append (mapcar (lambda (d) (expand-file-name d path))
'("src/" "target/classes/" "test/"))
(let ((lib (expand-file-name "lib" path)))
(if (file-exists-p lib)
(directory-files lib t ".jar$"))))
slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
(remove-if #'(lambda (x) (eq (car x) 'clojure))
slime-lisp-implementations)))
(save-window-excursion
(slime)))
(require 'clojure-mode)

(add-hook 'clojure-mode-hook 'run-coding-hook)

(font-lock-add-keywords 'clojure-mode
'(("(\\|)" . 'esk-paren-face)))

(define-key clojure-mode-map (kbd "C-c v") 'slime-eval-buffer)
(define-key clojure-mode-map (kbd "C-c C-v") 'slime-eval-buffer)

(defface esk-clojure-trace-face
'((((class color) (background dark))
(:foreground "grey50"))
(((class color) (background light))
(:foreground "grey55")))
"Face used to dim parentheses."
:group 'starter-kit-faces)

(setq esk-clojure-trace-face 'esk-clojure-trace-face)

;; This will make relevant lines stand out more in stack traces
(defun sldb-font-lock ()
(font-lock-add-keywords nil
'(("[0-9]+: \\(clojure\.\\(core\\|lang\\).*\\)"
1 esk-clojure-trace-face)
("[0-9]+: \\(java.*\\)"
1 esk-clojure-trace-face)
("[0-9]+: \\(swank.*\\)"
1 esk-clojure-trace-face)
("\\[\\([A-Z]+\\)\\]"
1 font-lock-function-name-face))))

(add-hook 'sldb-mode-hook 'sldb-font-lock)

(defun slime-jump-to-trace (&optional on)
"Jump to the file/line that the current stack trace line references.
Only works with files in your project root's src/, not in dependencies."
(interactive)
(save-excursion
(beginning-of-line)
(search-forward-regexp "[0-9]: \\([^$(]+\\).*?\\([0-9]*\\))")
(let ((line (string-to-number (match-string 2)))
(ns-path (split-string (match-string 1) "\\."))
(project-root (locate-dominating-file default-directory "src/")))
(find-file (format "%s/src/%s.clj" project-root
(mapconcat 'identity ns-path "/")))
(goto-line line))))

(eval-after-load 'slime
'(progn
(defalias 'sldb-toggle-details 'slime-jump-to-trace)
(defun sldb-prune-initial-frames (frames)
"Show all stack trace lines by default."
frames)))

(eval-after-load 'find-file-in-project
'(add-to-list 'ffip-patterns "*.clj"))

;; You might like this, but it's a bit disorienting at first:
(add-hook 'clojure-mode-hook 'turn-on-paredit)

(defun clojure-project (path)
"Setup classpaths for a clojure project and starts a new SLIME session.

Kills existing SLIME session, if any."
(interactive (list
(ido-read-directory-name
"Project root: "
(locate-dominating-file default-directory "pom.xml"))))
(when (get-buffer "*inferior-lisp*")
(kill-buffer "*inferior-lisp*"))
(add-to-list 'swank-clojure-extra-vm-args
(format "-Dclojure.compile.path=%s"
(expand-file-name "target/classes/" path)))
(setq swank-clojure-binary nil
swank-clojure-jar-path (expand-file-name "target/dependency/" path)
swank-clojure-extra-classpaths
(append (mapcar (lambda (d) (expand-file-name d path))
'("src/" "target/classes/" "test/"))
(let ((lib (expand-file-name "lib" path)))
(if (file-exists-p lib)
(directory-files lib t ".jar$"))))
slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
(remove-if #'(lambda (x) (eq (car x) 'clojure))
slime-lisp-implementations)))
(save-window-excursion
(slime)))

#+end_src

#+results:
: clojure-project

pretty \lambda's in clojure
#+begin_src emacs-lisp
(eval-after-load 'clojure-mode
Expand Down

0 comments on commit 6ac95dc

Please sign in to comment.