Sunday, June 24, 2012

Lein, noir and emacs

I like emacs, and I like the support emacs provides for lisp languages, including clojure. I'd like to have my clojure instance running as an inferior process as I develop my application. And given that I'm playing with web apps, I'd like that process to also include noir, my (tentative) web application framework.

Step 0: My Dev Environment

My primary box is windows 7, but I don't want to develop in windows for various reasons. So I have virtualbox running ubuntu, where I have installed emacs 24.

Step 1: clojure-mode in emacs

In emacs 24, run M-x package-list-packages, and install clojure-mode. After that, M-x clojure-jack-in starts up an inferior clojure process, and connects emacs to that process.

Step 2: Create a noir project

Install lein 2. Then,
$ lein new noir my-project
creates a new project. This is a complete web application with some sample pages.

Step 3: Load the project in emacs

Once again, run emacs and open the project.clj for my-project. Then M-x clojure-jack-in. Load your web app into clojure with:

user> (require :reload-all 'my-project.server)
user> (my-project.server/-main)
Starting server...
Server started on port [8080].
You can view the site at http://localhost:8080
#<Server org.eclipse.jetty.server.Server@5c67718d>

I had to look at the server.clj generated by noir to find the precise calls I had to make. I imagine these would be subject to change as noir evolves.


I've recently been working on getting a simple web app working with clojure. The first step was to pick a web framework. Having no real reason to pick any one in particular, I used the rigorous process of googling "clojure web framework" and picking the first web application. That turned out to be Noir. The simplicity of getting started on the first page looked nice, but not reality.

I was working with clojure 1.4.0 and lein 2. The process on Noir's front page is for clojure 1.2.1 and lein 1, which I either missed or they missed. After trying a bit, I posted on the forum, and got some quick help. With lein 2, creating a new project is more like:

$ lein new noir myproject

There are at least a couple of more steps before I feel I've got the dev environment going:
  1. Write a `hello world` app.
  2. Develop through slime/swank.

Tuesday, June 12, 2012

macfuse is dead, long live macfuse!

I had used macfuse several years ago, while I was at SRI. I have a mac again, but macfuse is now defunct. A new project has forked from macfuse, OSXFUSE. Here's hoping it offers all the same functionality...