måndag, juni 12, 2006

A few hours with Emacs

Today I've spent some hours upgrading Emacs to version 22, and getting various stuff to work. It was an interesting experience, and I've found lots of neat tricks I didn't know about before. But first, Emacs 22! This is in no way a released version, it is still in beta and reportedly has some bugs left in the code base. That said, I've been programming and working in it during the day and not experienced any trouble at all.

The new version brings some major updates, especially in the department of internationalization. The support looks great, actually. Another cool feature that Steve Yegge have blogged about (see link to the right), is the new support for embedding elisp inside replacement in "query-replace-regexp". That's really neat.

First installation wasn't totally smooth; my JDEE environment didn't really want to play, but after a while of fiddling with the code for it, I noticed that a new minor version was available. I added this to my local installation and everything justed worked. Even my own JDEE extensions continued working.

I've never really liked the completion in JDEE, but now I've finally written a small script to make is usable when I want it, at least:

(defun indent-or-complete-jde ()
"Complete if point is at end of a line, otherwise indent line."
(if (looking-at "$")
(define-key jde-mode-map [tab] 'indent-or-complete-jde)

This code does code-completion if at end of a line, which is the most common case when you need completion. It's important to have the jde-global-classpath point to all available classes, though. (I've created a global prj.el with common options preset for JDEE, and loads this from my various projects prj-files.) Completion is still slow, especially the first time, but when you really need it, it's there. I toyed with getting dabbrev or pabbrev in there also, but that just doesn't seem right for Java.

Another nice feature I got working was integrating imenu with JDEE, so I can Shift-right-click in any Java buffer and get a nice menu list of all class definitions with method and field hyperlinks. That's probably the only thing I'll use the mouse for in Emacs, ever, and it's more like using it as a key anyway. The only annoying thing with imenu is that I want it to sort the classes alphabetically. I've set this both with imenu-sort-function and jde-imenu-sort, but it doesn't really bite.

What I haven't had time to test yet - and the things that'll probably need some work - is my tramp-paths for interactively working with files on other computers through Emacs and plink (which also enables me to use Slime for LISP editing in-process on other servers). Right now this doesn't seem to work, but I read somewhere that the plink-support has been upgraded in Emacs 22.

But all in all I'm very satisfied. I recommend any Emacs maven to try out the new version, and especially if you need to work in Cygwin or on the Mac. The support for these environments are now there.

1 kommentar:

neverov_dg sa...


I want to use emacs for java development very much. So can you tell in what projects do you use Emacs for java? Do you use it for web projects with jsp & servlets? Does Emacs satisfy your requirements for debigging? I'm trying to use JDE, but have troubles with it... (at least in emacs22). I doubt: is it practical and pragmatic for a average user to try to use emacs for java development... May be I should try to use Eclipse? Now I use Oracle jDeveloper and not very happy with it, because it does a lot of work behind the scene and I want to get full control over project. But it seems that JDE also does a lot of work behind the scene. Or I'm wrong?