Rick Moynihan <rick.moyni...@gmail.com> writes: > One problem I do have with clojure-mode/clojure is managing the > classpaths for clojure projects... It seems that the typical elisp > config only has one variable (which is then shared across all clojure > files) for specifying the classpath... > > Personally I'd like to maintain the required classpath with the > project and outside of my .emacs files and was wondering if anyone had > any elisp setups to work around this.... I was thinking maybe having > clojure-mode search every directory up from the file your editing for > a .classpath file to pass to a clj bash script for evaluation... How > does everyone else do this?
The solution I've settled on is the clojure-project function: (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 "src")))) (require 'swank-clojure) (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))) This just resets the classpath to include target/dependency/ as well as any jars in the lib/ directory of your project. I've included this in the Emacs Starter Kit but haven't included it in clojure-mode yet since I haven't quite decided if it's suitable for everyone. But it seems there's a demand for it; so I guess I'll include it. Another option is to use directory-local variables using a .dir-locals.el file in your project root, but that can only set values for variables, it can't do things like add a value to an existing list, so its utility is limited. -Phil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---