Thursday, 2 June 2016

Clojure code browser in Emacs

A post from ProDevTips blog landed in my feed reader through PlanetClojure's RSS feed describing a custom-developed Clojure function browser in Emacs. I just wanted to post a simpler, built-in solution because I had this in my configuration and I find it a really neat feature. First, here is the end result:
Clojure function browser in Emacs
The package that does the magic is speedbar and sr-speedbar. Speedbar is a built-in feature of Emacs, the sr-speedbar package embeds speedbar in the buffer's frame, because otherwise it opens in a new frame. And to make speedbar work with Clojure you need this in your init file:
(require 'speedbar)
(speedbar-add-supported-extension ".clj")
For me this worked out-of-the-box, but I think it relies on one of the Clojure or programming packages I configured earlier. Here is the list of my packages that I think can be related:
  • cider
  • ac-cider
  • clojure-mode
  • projectile
  • company