Choosing your clojure startup script from Emacs/SLIME

December 3rd, 2009

The standard instructions for swank-clojure (the clojure backend to SLIME) imply you always use the same binary and/or classpath for starting your clojure code. The problem with that is that for different projects you generally want to specify at least additional classpaths and possibly even a completely different clojure version.

At the same time, most projects already contain some kind of startup/REPL script, so why not use that? swank-clojure only really needs some code that starts a repl and has the swank-clojure code in its classpath.

Below is my emacs code to do just that. Just put it somewhere in your emacs init scripts, type M-x clojure and select your startup script and away you go. The following is all my clojure-specific code, but the really "interesting" bit is the (defun clojure ...) bit.

;; this is needed because swank-clojure complains if you don't have any
;; value for this variable. When you use the clojure command it'll override
;; this value
(setq swank-clojure-binary "clj")

(require 'clojure-mode)
(require 'swank-clojure-autoload)
(require 'swank-clojure)
(require 'slime)

(add-hook 'clojure-mode-hook 'slime-mode)

(add-hook 'clojure-mode-hook 'start-paredit)

(slime-setup
 '(slime-fancy ;; turns on fancy inspector, autodoc and other useful stuff
   slime-highlight-edits)) 

(defun clojure (binary)
  (interactive "fbinary: ")
  (setq swank-clojure-binary (or binary "clj"))
  (setq slime-lisp-implementations
        `((clojure (,swank-clojure-binary) :init swank-clojure-init)))
  (slime))

My complete emacs init stuff is at http://github.com/joodie/emacs-d

Oh, before I forget: the code above does assume that you're only using SLIME with clojure and not also with other lisps. If you do need that functionality, you can probably figure out how to make it work.

Why the hell doesn’t IMovie let me save movie files?

May 24th, 2009

I like my macbook for the OS, but seriously. I just recorded 20 minutes of video and now there's no way to export it? What the bloody @!#@?

Bassline Synth sourcecode now online

March 31st, 2009

I just released the source code for the simple synthesizer, for those who are interested.

A simple synthesizer in 7.17 Kb of Flash

March 19th, 2009

Flash finally raised my curiousity by adding fully programmable audio in Flash player 10. This means you can read the currently playing audio stream to provide reasonably accurate VU meters etc, but more interesting, it means you can write your own audio-generating algorithms.

To test if flash is actually fast enough and to see if it's really possible to write flash apps using nothing but the free mxmlc compiler and emacs, I wrote a simple synthesizer in flash 10. The result is fairly pleasing.

Bassline screenshot

Check it out!

Adding a modeline to emacs-rails

December 6th, 2008

I just updated emacs-rails so that feedback on the currently running test is put in the global modeline. This means you get that feedback in all buffers, so you can work on something else while your tests are running, and the minibuffer stays free for useful things.

It's started automatically when emacs-rails is loaded, but that's customizable of course, and you can switch it on and off using rails-ui:enable-mode-line / rails-ui:disable-mode-line.

the new modeline feature

Get it at http://github.com/remvee/emacs-rails/tree/master

Here are the commit details

Update: actually, the head has some nicely cleaned up code now. So just get that at http://github.com/remvee/emacs-rails/tree/master

better console/keyboard menus for emacs

September 14th, 2008

One of the projects I'm working on is in Ruby on Rails, and I'm using emacs-rails (with some small tweaks) as the development environment.

Emacs rails works fine, except for one thing: the navigation menus (x-popup-menus) are awkward when you want to use the keyboard. So I thought I'd switch on the rails-always-use-text-menus option. Which didn't actually work, but I fixed that bit.

Rails-always-use-text-menus uses tmm-prompt, which is the standard function on emacs to mimic drop-down menus on the console. and it's almost as horrible as x-popup-menu: if the items in the menu aren't static you can't predict the which key activates which item, and it takes up a lot of screen space:

Which key can I press to go to the UserPreference model?

Before

I really like iswitch buffers for buffer navigation, and it seemed to me that it should be possible to navigate the menus using the same technique, even for nested menus.

So here is iswitch-menu, a direct replacement for tmm-prompt and/or x-popup-menu. It's not quite finished yet - I'm working out the last issues with some of the more "interesting" constructs used by the menubar keymap - but it's more than adequate for use with emacs-rails, at least.

Now, I can just type some substring of the name of the model, and go there

after, step 1

First character typed, we can see which models still match

after2.png

Second character typed, only one model still matches.

after3.png

Pressing TAB completes the typed text, and goes to the selected model if there's only one. Pressing ENTER opens the first matched model. See also the iswitchb documentation for available tweaks and key bindings.

Get iswitch-menu at github

using emacs’ (compile) command to track errors

August 21st, 2008

For a mod_perl project I'm working on I wanted a way to track the apache error log and jump to the source of the errors from emacs.

Fortunately, emacs' (compile) command makes this very easy:

;; restarts apache and track the error log
(defun apache-restart-and-tail ()
      (interactive)
      (compile "sudo /etc/init.d/httpd restart && sudo tail -f /var/log/httpd/error_log"))

;; key binding
(global-set-key (kbd "<C-kp-enter>") 'apache-restart-and-compile)

Inconsolata - a nice programming font

February 26th, 2008

My current favorite Emacs*font to work with the new XFT backend is Inconsolata. I've tried a few others, but this font is just very clear, not too fat and not too skinny, and it has a slashed zero, as a programming font should.

There's a debian package too, called "ttf-inconsolata". ** See update below.

Screenshot:

Inconsolata font

Update: the current debian ttf-inconsolata has a bug somewhere that means you can't actually use the font. A simple remedy is to install the ttf-inconsolata package and then symlink /usr/share/fonts/truetype/ttf-inconsolata/Inconsolata.ttf to /usr/share/fonts/truetype/ttf-inconsolata/Inconsolata.otf

This may not be technically correct, but it does work.

Also, on my current emacs CVS builds, I need to add the following to my .Xresources to get the anti-aliasing to work reliably:

Emacs.FontBackend: xft

Rambling on Javascript: “Constructors considered mildly confusing”

February 11th, 2008

In which I poke your eye with the details of prototypes and constructors in JavaScript. Includes pretty diagrams! Read it here:
Constructors considered mildly confusing.

Emacs CVS HEAD (finally) has anti-aliased fonts

February 7th, 2008

The emacs-unicode-2 branch has been merged into the main branch. This means really good looking fonts for everyone on X11.

Get it now:


cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co

cd emacs

./configure --with-xpm --with-tiff --with-jpeg --with-png --with-freetype --with-xft --with-rsvg --with-gtk --enable-font-backend

make bootstrap

make

sudo make install

There's no gui interface to select these fonts. I just put the following entry in my .Xresources:

Emacs*font: Monospace-10

Replace "Monospace-10" with whatever font you like.