Wednesday, May 30, 2012

Scala environment in Emacs

At work we have been doing most of our development in Java, and it has been serving us quite well. For a new project that we started, we looked at other JVM based languages, that would help us develop a little bit more efficiently, as well as leverage the big code base that we have.

Since a couple of people on the team knew Groovy and Grails, and have used it in the past to develop web applications, we went with that choice, and so far it has served us well. Development became a little bit more pleasurable, and we got rid of some of the Java boilerplate.

Out of curiosity I started experimenting with other JVM based languages, and since a lot of my friends at other company were singing praises for Scala, I decided to play with that.

The first step is setting up a Scala development environment, and with a couple of additions to my .emacs file, I got just that:

For Scala development in emacs, you need a couple of things:

  1. scala-mode
  2. ensime

You can download scala-mode from

Then move the directories under your elisp directory, and add the following lines to your .emacs file, changing the PATHTOELISP accordingly

;; scala support
(add-to-list 'load-path "/PATHTOELISP/scala-mode")
(require 'scala-mode-auto)

You can download ensime from

After expanding the zipped tar archive, move the directory to your elisp directory, and add the following lines to your .emacs file

(add-to-list 'load-path "/PATHTOELISP/ensime_2.9.2/elisp")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)

And now you have syntax highlighting, auto-completion, and a Scala REPL and debugger inside of Emacs.

Thursday, May 17, 2012

More mutt goodness

I have been using mutt for some time now as my primary email client, and have found that I have not missed using any of the more graphical interfaces like Mac Mail, or Gmail web interface. Not even to look at HTML emails, PDF documents, or Word documents. Thanks to a couple of open source utilities, I can convert these documents to text, and read them from within mutt, leading to a seamless experience, and a much more pleasant email workflow.

The following lines in your  ~/.mailcap config file configure the utilities and do the magic:

HTML emails

text/html; links -html-assume-codepage utf8 -html-numbered-links 1 -dump %s; copiousoutput

I use the links browser to do the conversion from HTML to text. There are many other options to use, such as Lynx, or w3m, but I like links because it formats the HTML tables better than Lynx or w3m, and handles utf8 characters better. You can also turn off the html numbered links easily if you choose to.

PDF files

application/pdf; pdftotext -layout /dev/stdin -; copiousoutput

I receive a lot of resumes, and hate to open them in Preview or Adobe Acrobat. For me, nothing beats looking at resumes in text mode where I can focus on the candidates' skills, and experience, without being distracted by formatting and colors.

For the conversion I use the pdftotext script which you can get by installing the poppler macport.

Word documents

application/msword;             antiword -f -s %s  2> /dev/null; copiousoutput
application/vnd.openxmlformats-officedocument.wordprocessingml.document; %s - 2> /dev/null; copiousoutput

There are two formats for word documents, the older DOC format, and the newer DOCX format. For the older format I use antiword, which you can install through macports, and for the newer format I use the perl script docx2txt, which you can download from the docx2txt sourceforge repository.

I have not had a need to convert powerpoint slides or excel spreadsheets to text so far, but if you know of any utilities that help, let me know.