Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created January 3, 2011 19:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alandipert/763791 to your computer and use it in GitHub Desktop.
Run the mvn clojure:repl task in emacs
(defgroup mvnrepl nil
"run mvn clojure:repl from emacs"
:prefix "mvnrepl-"
:group 'applications)
(defcustom mvnrepl-mvn "mvn"
"Maven 'mvn' command."
:type 'string
:group 'mvnrepl)
(defun mvnrepl-project-root ()
"Look for pom.xml file to find project root."
(let ((cwd default-directory)
(found nil)
(max 10))
(while (and (not found) (> max 0))
(if (file-exists-p (concat cwd "pom.xml"))
(setq found cwd)
(setq cwd (concat cwd "../") max (- max 1))))
(and found (expand-file-name found))))
(defun mvnrepl ()
"From a buffer with a file in the project open, run M-x mvn-repl to get a project inferior-lisp"
(interactive)
(let ((project-root (mvnrepl-project-root)))
(if project-root
(inferior-lisp (concat mvnrepl-mvn " -f " project-root "/pom.xml clojure:repl"))
(message (concat "Maven project not found.")))))
(provide 'mvnrepl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment