About Archive Tags RSS Feed

 

And time keeps dragging on

2 March 2008 21:50

So, as I previously mentioned I want to be able to tag messages in Mutt.

There exist folder-based solutions already, using the X-Label header. There doesn't appear to be any existing solution allowing you to view all messages with a given tag across mailboxes.

So I wrote a simple shell script to create virtual mailboxes, such as ~/Maildir/tags-debian for all messages with a debian tag, using hardlinks.

My conclusion is that this solution will not work properly in practise, primarily because of deficiencies in mutt.

The simple case works just fine. I add a tag to a message, and later when the indexing job runs the virtual folder is created. I can open it and work on it just fine.

So where's the problem? Well in my case I tend to tag messages with a label such as "todo". Once I've done whatever I was supposed to I can remove the tag.

Using this hardlinking scheme I cannot remove the tag(s) in the virtual folder - I have to remove it in the original message which is a real pain.

Why? Well quite simply mutt will not let me work on my virtual message without destroying the hardlink.. If I use the edit function, for example, I am presented with a copy of the mail for editing - and the hardlink is replaced when that copy is saved.

Even the edit-label patch which allows you to edit the X-Label header from within mutt ends up replacing the hardlink with a new file!

So whats the solution? Well I guess I want to be able to run an external command against a message in mutt - passing the filename of the Maildir message as an argument. That way I can edit the live file.

Right now I don't believe that is possible, but I'd love to be told different.

If anybody has any solutions of editing, or even just deleting, a header from a message within mutt - in such a way that the hardlink isn't destroyed please do let me know.

Simple reproducer:

mkdir -p ~/Maildir/.foo/cur
mkdir    ~/Maildir/.foo/new
mkdir    ~/Maildir/.foo/tmp
cp 'validmessage' ~/Maildir/
ln validmessage ~/Maildir/.foo/cur

Now edit the message - start mutt open the message in the index and press 'e' - the hardlink is now gone. Replaced by a new file with the contents, so the original mail message is unchanged.

Update: I've got an "edit-inplace" primitive working, via the very hacky header-fu patch. It is not complete, but it demonstrates that it can be done. My world is now complete.

| 7 comments

 

Comments on this entry

icon Daniel Jacobowitz at 21:52 on 1 March 2008
Too late to help you know, but for the first part of your post - take a look at mairix (http://www.rpcurnow.force9.co.uk/mairix/). It creates virtual maildirs in response to searches.
I suspect mairix's symlinks have the same problem.
icon Steve at 22:02 on 1 March 2008

Unfortunately mairix isn't sufficient. It explicitly indexes certain header fields such as "To:", "From:", and "Subject:". Adding a new field is non-trivial.

(I looked at the code.)

nmzmail also failed. The indexer worked just fine, but changing this example from the README:

 from:foo

To this, which should have matched:

 x-label: test

resulted in "0 messages found". I'm not sure if it is the indexer or matcher to blame there, but either way it failed.

icon Ken Bloom at 04:47 on 2 March 2008
I think you're wanting Madduck's (nonexistent) MailLabelsFS for FUSE, proposed at http://madduck.net/blog/2007.07.24:a-user-space-filesystem-for-mail-labeling/
icon Uli Martens at 12:39 on 2 March 2008
Have you tried symlinking the mail files instead of hardlinking them? Writing to the symlink should overwrite the original file
icon Steve at 14:17 on 2 March 2008

As for symlinks? Well a hardlink is a type of symlink. As it happens I tried both ways:

ln -s old new
ln old new

Neither worked.

But for the moment I'm happy with my little patch. It doesnt work over IMAP, which is a shame, but otherwise it does everything I need. I even updated the sidebar patch at the same time.

icon anonymous at 23:59 on 2 March 2008
There's a mini-howto of "Labeling mail with mutt" in http://auriga.wearlab.de/~alb/other/mutt-labels/
If i am not wrong, that is what you are searching for.
icon Steve at 06:19 on 3 March 2008

Sorry anonymous but you are mistaken. That tool only allows a single folder to be tagged and searched.

If I use my hardlink solution to enable multi-folder tag searching the editlable script in that page doesn't allow the tag to be removed in the virtual folder - it edits a copy of the message.