29 January 2011


My extension to filesets: fileset-whole


I was frustrated with the project manager I was using. It didn't do everything I wanted, and it tended to mess up settings in other buffers. I had made a nice (and tricky to code!) plugin that let a certain keysequence launch project commands from any affected buffer. But it wasn't stable. I'd use it for a while, and then find it had disappeared. Or I'd use it on a second project, and it would complain that it couldn't find data about that project. Unstable.

So even though I had contributed a fair bit of code to it and it was the best of the project managers, I was looking for a better way.

Yesterday it dawned on me that emacs' built-in filesets functionality is actually fairly close to what I want. It is a group of files, which is the core of what I wanted. It launches commands wrt them. It organizes them well for use, and allegedly co-operates with other software such as dired+. And it's stable and apparently not buggy.

So I tried filesets out. It didn't serve, because it insisted on certain ways of doing things. Nevertheless, it was tantalizingly close. If only it could be persuaded to do just a few things differently: eval args to commands, not insist on running each command on each file, and keep a little freeform data in addition to the file names, things like that. Minor things, but woven deeply into the fiber of filesets.

I turned it over in my mind most of yesterday, wondering if I should fork the filesets development, or make changes and submit them (often a frustrating experience because it places you at the mercy of someone else's attention and comprehension), or make a personal version (and get out of sync with other development). None appealing.

The answer

I realized last night that there was a way to extend filesets instead of working with its assumptions. All I had to do is define another alist from fileset name to data, this one to hold general key-value data instead of just basically file names. Then I could make it store all sorts of associated data with filesets. And of course, I had to rewrite the command runner and some other stuff.

So today I wrote fileset-whole. It basically adds twins of some of filesets' things that didn't do all I wanted:

Alist of key-value data associated with each fileset, near-twin of filesets-data
List of commands that can be launched on a fileset as a whole. Like filesets-commands, but I do args differently for various reasons.
Launcher for commands

One other neat feature: It remembers which fileset an open buffer is associated with (in buffer-local variable `fileset-whole-name-here') So already I am not prompted for fileset names nearly as often.

Current state

So far, no serious problems. The commands work, as far as I've tried them. Now I'm going to switch back to my usual project, klink, but using `fileset-whole'.

I haven't published it yet. I'll probably create a git repo for it after I've tried it out myself and fixed anything serious that comes up.

No comments:

Post a Comment