2

I'm using Emacs, integrated with Leiningen's swank. Each time I need to start working with .clj file I have to:

  1. Run emacs pack/my-ns.clj from console.
  2. Type M-x lein-swank.
  3. Compile buffer.
  4. In Clojure REPL change namespace, i.e. type (in-ns 'pack.my-ns).

How can I automate this process to just run from console something like emacs-clj pack/my-ns.clj and get my environment ready to use?

ffriend
  • 27,562
  • 13
  • 91
  • 132

2 Answers2

2

I don't have an answer to the question you posed, but you should be able to replace your 4th step with C-c M-p while in your Clojure file and then emacs should prompt you as to what namespace you want to be in with the namespace of the file auto-detected so you can simply hit enter. C-c M-p maps to slime-repl-set-package.

Update:

Just stumbled across this. Should be able to take what is said in that answer and modify it so upon initial connection to swank files get compiled. Could also set it up to automatically switch to namespace and make the repl buffer active.

Community
  • 1
  • 1
Jake McCrary
  • 1,180
  • 9
  • 8
2

Swank should automatically load the namespace pointed to by :repl-init-script in project.clj when it starts, so if you want to set that to your starting namespace, that should get you started.

  • Thanks, but I can't make it working. What should be the value of `:repl-init-script`? If it's a path to file, what it should look like (i.e. where it must start from - project root, src directory, anything else), and if it is a package name (i.e. `:repl-init-script "pack/my-ns.clj"`) it just doesn't work for me - repl is loaded, but namespace is not changed. Leiningen version is 1.3.1. – ffriend Nov 30 '10 at 23:45
  • Oops; you're right. That code gets loaded, but it doesn't change the namespace. If you set a :main namespace in project.clj, then it will be switched to when your repl starts. But that also causes AOT to happen; not sure if you want that or not. –  Dec 02 '10 at 04:52