(eval-after-load 'ruby-mode
  '(add-hook 'ruby-mode-hook 'esk-paredit-nonlisp))

;; (eval-after-load 'swank-clojure
;;   '(add-to-list 'swank-clojure-extra-vm-args
;;                 "-agentlib:jdwp=transport=dt_socket,address=8021,server=y,suspend=n"))

(add-hook 'slime-repl-mode-hook 'turn-on-paredit)
(add-hook 'clojure-mode-hook 'turn-on-whitespace)

(setq inferior-lisp-program
      "java -cp /home/phil/src/clojure/clojure.jar clojure.main")

;; unfortunately some codebases use tabs. =(
(set-default 'tab-width 4)
(set-default 'c-basic-offset 2)

(add-hook 'xml-mode-hook 'run-coding-hook)
(add-hook 'java-mode-hook 'run-coding-hook)

(eval-after-load 'java-mode
  '(progn
     (define-key java-mode-map (kbd "C-M-h") 'backward-kill-word)))

(add-to-list 'auto-mode-alist '("\\.duby$" . ruby-mode))

(setq slime-net-coding-system 'utf-8-unix)


;; swank launchers

(defun slime-go (&optional port)
  (interactive)
  ;; use .dir-locals.el to set slime-port. Must be 4005 for maven.
  (slime-connect "localhost" (or port slime-port)))

(defun slime-start-filter (process output)
  (when (string-match "Connection opened on local port" output)
    (slime-connect "localhost" slime-port)
    (set-process-filter process nil)))

(defun mvn-swank ()
  (interactive)
  (let ((root (locate-dominating-file default-directory "pom.xml")))
    (when (not root)
      (error "Not in a Maven project."))
    (shell-command (format "cd %s && mvn -o clojure:swank &" root) "*mvn-swank*")
    (set-process-filter (get-buffer-process "*mvn-swank*") 'slime-start-filter)))

(defun lein-swank ()
  (interactive)
  (let ((root (locate-dominating-file default-directory "project.clj")))
    (when (not root)
      (error "Not in a Leiningen project."))
    ;; you can customize slime-port using .dir-locals.el
    (shell-command (format "cd %s && lein swank %s &" root slime-port)
                   "*lein-swank*")
    (set-process-filter (get-buffer-process "*lein-swank*")
                        (lambda (process output)
                          (when (string-match "Connection opened on" output)
                            (slime-connect "localhost" slime-port)
                            (set-process-filter process nil))))
    (message "Starting swank server...")))

(global-set-key (kbd "C-c C-s") 'slime-it-up)
(global-set-key (kbd "C-c C-l") 'lein-swank)
(global-set-key (kbd "C-c C-m") 'mvn-swank)

Generated by Phil Hagelberg using scpaste at Tue May 18 13:46:32 2010. PDT. (raw)