About Archive Tags RSS Feed

 

Feeling with your skin

3 March 2008 21:50

One final post then I'm done discussing mutt. (Primarily because too many people failed to understand the problem, I guess I wasn't being as good at explaining as I could have been.)

So the goal was to be able to tag individual messages within mutt, such that a short while later a new folder would be created containing all messages of that tag, regardless of which folder the message(s) are in.

Actually finding the tags and creating the virtual folders is easy to do. I wrote a simple indexer which scans for tags in messages and creates hardlinks as necessary.

The problem with this is that many operations on those hardlinked messags would create a new copy of the message and operate on that - trashing the hardlink. For some operations that's just fine. But I did specifically want to be able to untag a tagged message and not have to hunt around for the original. (e.g. remove the "todo" tag from messages where I'd done the relevant action.)

So after a bit of trial and error I came up with a patch which allows the editing of a message in-place, in the hardlinked folder, without trashing the hardlink. This patch just invokes "$EDITINPLACE <filename>" where "filename" is the name actual file the message I'm working on is stored on disk. (i.e. ~/Maildir/.people.thewomanmeg/cur/1.2.3.txt).

By setting the EDITINPLACE variable to point to my ~/bin/editlabel script I may easily remove any tags from the hardlinked-message and have it apply to the original. Job done!

There are some limitations with this approach that are worth mentioning though:

  • IMAP? Ha! Nope. We only work on Maildirs.
  • The header-cache facility of Mutt breaks my "find the filename of the Maildir message" function. Not sure why, so I just disabled it.
  • Many operations on the virtual mailbox will still break the symlink; because they don't edit in place.

I've documented things in a rather random fashion, and I've made a backported package of mutt with my patch available online too. Primarily so I dont lose the source like I did with my mutt-ng backport.

Pointless Work

I spent about 30 minutes rebuilding mutt to use a bubble-sort on the folder list which is displayed in the sidebar.

Only when I was just about to install this patched build did I realise that the mailboxes were displayed in the order they are listed in my .muttrc file. One quick edit with Emacs and the folder list was sorted properly.

Boy is my face red..

ObRandom: I'm loving my deaf-friendly alarm clock. It rocks.

Place it under your pillow and it vibrates to wake you up. Simple. Effective, and above all it doesn't disturb my partner up when I get up to catch an early morning train.

(Thought to be fair I usually wake her up anyway; can't leave without a goodbye kiss!)

I'm still waiting for the vibrating ring, but this is good enough in the meantime.

| 2 comments

 

Comments on this entry

icon anonymous at 07:10 on 3 March 2008
Editing files in place is bad software engineering practice because if anything goes wrong after the file truncation (e.g. power loss) you lose both, the old contents and the new contents.
icon Steve at 07:15 on 3 March 2008

In general you're correct.

However it is worth looking at my script, it doesn't actually edit in place. It is just careful to ensure that the hard-link isn't replaced with a new file. (i.e. it creates a temporary file to work with then "cat new > old" as the last step.)