Wednesday, December 3, 2008

Adding support for decompiling class files in a jar file in emacs

This simple EMACS hook checks for CAFEBABE at the beginning of a file extracted from the an archive (jar, war, etc) and decompiles it. Requries decompile.el and JDEE. Thanks for decompile.el. It is great.
(add-hook
 'archive-extract-hooks
 (lambda ()
   (cond ((string-match "\312\376\272\276"  ;;CAFEBABE
                        (buffer-substring-no-properties 1 5))
           (jdc-buffer)))))