Archive for the ‘Emacs’ Category

Emacs Update

I know you couldn’t possibly get bored by another Emacs post.

Emacs is really the one thing I come back to when I want to hack joyfully. Other things are interesting or relevant, but I find Emacs fun.

How could I have missed goto-address for so long? This command will buttonize URLs in a buffer; I enable it by default in change-log-mode, but I’m considering just enabling it globally. It isn’t perfect — it doesn’t recognize URLs as you type. But this is probably fairly easy to fix, and in the meantime it is still handy.

Second, my calendar (really appointment) code to use the notification area worked for the first time today. This is still a bit fragile, I don’t quite know what is going on. But, it does mean I am very close to not ever using Evolution. (Speaking of which I finally set things up so I can easily send email from my various personal accounts via Gnus. This was an incredible pain, involving writing elisp functions, etc. No wonder this stuff is so unpopular.)

I wrote a little hack over the weekend to emulate the Gnome sticky notes applet. This was pretty simple, a couple hundred lines of lisp. But, I didn’t like the result very much. Instead I think I am going to finally upgrade to Emacs 22 (which is something of a pain since I’m using some RPMs that aren’t updated) and use linkd, which looks pretty cool.

Work proceeds on package.el, but it isn’t quite ready for the next release.

I’ve been working steadily on project.el, a way to encapsulate project-specific settings in a simple data structure. The idea is, a project like GCC can publish a set of settings, and when you hack on that project, Emacs will automatically set the correct C style, correct new-file copyright template, correct tabs setting, etc. I’ve seen various projects do this already — they publish little .el files, usually bad ones, for their users. I really don’t understand why this functionality isn’t already in Emacs… right now everyone has to roll their own.

ELPA Update

I rewrote the ELPA web page the other day. Now it should be clearer about how to get your Emacs Lisp packages into the archive. I’ve also added a news section and uploaded a few more useful major modes.

Emacs Lisp package authors, please send me your code. I will upload it right away (I have an Emacs macro to upload a single .el file to ELPA directly from Gnus :-).

This code has already made my life nicer… I installed modes for javascript and CSS (for my js game) on both my machines in a few seconds.

Cool Emacs Trick

I looked around for valgrind integration into Emacs recently but I didn’t see anything out there. I had a great idea! — compilation-mode should integrate with shell-mode so I can run valgrind and then next-error will walk through the problems.

Well, it turns out this idea is so great that it has been implemented already. Yay Emacs! Unfortunately the feature is rather obscure; I had to dig around in the source to find it, and it wasn’t obvious that it handled valgrind — it does, but the valgrind error regexp is the same as one for the JVM, so it is misleadingly named “java”.

To enable this, enable compilation-shell-minor-mode in your shell-mode buffer. It will automatically start highlighting the appropriate messages, and mouse-2 will go to the source file.

I’m pretty happy about this idea of using shell mode in this way. It has that nice, integrated, “plastic” feeling I’ve come to associate with the joy of Emacs. I’ve always liked the idea of a “notebook-like” shell, where commands and structured, or even graphical, output are intermixed; this feels a little like that

What’s left? Two things I think… first, Emacs should automatically enable this minor mode when you type “make”, “valgrind”, “ant”, etc, in a shell mode buffer; meanwhile I’m just going to enable this from the mode hook.

Second, I think it would be awesome if running gdb in shell mode somehow auto-started Emacs’ gdb mode. I generally find it a pain to start (but not use) gdb in Emacs, since typically I have a complicated setup on the command line — a particular directory, command line, sometimes an environment; Emacs could simplify this. I wrote a minor mode last night that will recognize when you type “gdb” in the shell and will automatically run it in Emacs instead… I’ll post it soon, or send email if you want it.

Emacs Packages 2

Last night I was energized by BarCampBoulder (I’ll write more about it later, probably tomorrow) and so I hacked on my Emacs Lisp package manager for a while. Check out my page on installing the package manager. Just eval one lisp form and you will be all set up…

Next for this package is some rewriting — changing the archive format, fixing activation a little, and allowing for single-file packages on the server. Also I’m going to write a little tool so I can click on a message in gnu-emacs-sources and have the package automatically uploaded to ELPA.

Fun Stuff

I’ve been doing some random hacking recently in my free time — stuff to get my mind off of the mad gcj bug fixing for F7. Mostly Emacs stuff at the moment, packaging up my recent hacks and posting them to gnu-emacs-sources. But, I’ve also done a bit of javascript hacking; I wanted to write a web app, just to see what it is like (I’ll post more on that when it is really ready). Anyway, I ran across some fun things that are worth looking at.

For Emacs, check out RLX, a Rogue-like game written in Emacs Lisp. Super wacky! I’ve only looked at the screenies though, not actually tried it… 🙁

At FOSDEM I kept telling people I was going to write Space Invaders in Emacs Lisp, using the image support, and perhaps having the invaders be actual (fontified) space characters. Well, dammit, someone else got there first — in 1989, no less.

If you want to improve your Emacs experience and have some time to burn, the Emacs Wiki is great; there’s all kinds of useful info, elisp code, etc, in there.

For Javascript, I found a clone of MS Paint written as a web app. Maybe everybody out there has heard of this already? I’m so not-web-focused that I didn’t realize this was even possible.

Chris Blizzard (who I owe some email) pointed out jitblit to me. That’s pretty cool and it reminds me of what Apple is doing with LLVM and OpenGL. We’ll see more of this sort of specialized use of JITs now that they are becoming more common, generic, and library-ized.

I spent a little time looking at Elsa, a parser for C and C++. It seems nicely documented — much better than GCC. But, unfortunately, it doesn’t look like a solid way to start my incremental compilation project. For one thing the parser, according to the documentation is missing most error checks, and mostly assumes your code is valid. This is fine for analysis but not for production.

Emacs Packages

I’ve been slowly working on a simple Emacs packaging system. As I work on Emacs more, I find I want to install various packages. But, my history with Emacs shows me that I tend to leave random elisp files in my library long after they are later merged into Emacs itself.

The basics of the package system are the same as any other: a package can depend on other packages, and there is a simple way to download and install a package and its dependencies.

However, in this package system, installation and activation are separated. In particular, it can recover if the package installation is internally inconsistent. It also handles the case where multiple versions of a single package are installed.

Taken together this allows the use case I want: I want to be able to install Emacs, use it for a while; then someday upgrade ERC from the package archive, installing the new ERC into my home directory; and then later, after updating Emacs, my local copy should be deactivated.

Download the alpha release here. This requires the url package, so if you are running Emacs 21, you will need to get that from somewhere.

Once you are set up you can test the existing functionality. Get started right away by installing the fun “bubbles” game (aka “same game) by evaluating (package-install 'bubbles). This will download the game, install it, and activate it. Then M-x bubbles to play.

I haven’t written any UI yet, and the package repository is hand-maintained by me (there’s only 2 things in it, and nothing with dependencies). I’m looking for feedback on the code, features, etc, before committing to anything… once things are in better shape I want to move the archive somewhere more public and start getting packaging bits into the upstream projects.

The ideal situation would have package.el in Emacs itself, set up so that some of the larger Emacs modules are only activated by going through the package management system. I wonder how plausible this is.

There are a few other ideas in the source, and a few more I haven’t written in there. For instance, it would be nice not to require a “something-pkg.el” file for a package that is just a single .el file; that would make it much simpler to upload random emacs.sources posts to the archive.