About Archive Tags RSS Feed

 

Where troubles melt like lemon drops

1 March 2008 21:50

I've been re-reading RFC 2822 again over the weekend, for obvious reasons, and I'm amused I've not noticed this section in the past:

3.6.5. Informational fields

The informational fields are all optional. The "Keywords:" field contains a comma-separated list of one or more words or quoted-strings. The "Subject:" and "Comments:" fields are unstructured fields as defined in section 2.2.1, and therefore may contain text or folding white space.

subject  = "Subject:" unstructured CRLF

comments = "Comments:" unstructured CRLF

keywords = "Keywords:" phrase *("," phrase) CRLF

Now we all know that emails have subjects, but how many people have ever used the Keywords: header, or the Comments: one?

It'd be nice if we could use these fields in mails - I can immediately think of "keywords" as tags, and I'm sure I'm not alone.

I've looked at multiple "tags for mutt" systems, but all of them fall down for the same reason. I can add tags to a mail, and limit a folder to those mails that contain a given tag. But I cannot do that for multiple folders and that makes them useless :(

Has anybody worked on a multi-folder tag system for Mutt? If so pointers welcome. If not I'd be tempted to create one.

I guess implementation would be very simple. There are three caeses:

  • Adding a tag
  • Deleting a tag
  • Finding all messages with agiven tag.

The first two are easy. The second could be done by writing a cronjob to scan messages for Keyword: headers, and writing a simple index. That could then be used to populate an "~/Maildir/.tag-results" folder, via hardlinks, of all matching messages.

Better yet you could pre-populate ~/Maildir/.tag-$foo containing each message with a given tag. Then theres no searching required! (Although your cronjob would need to run often enough when the tag were added to a message it would appear there within a reasonable timeframe.

Update: I've written the indexer now. It works pretty quickly after the initial run, and is quite neat! tagging messages with mutt.

| 6 comments

 

Comments on this entry

icon Angel Olivera at 13:56 on 1 March 2008
Sounds like a job for mairix or nmzmail. The former would need to be modified to index these headers, but I believe the latter already supports searching for strings contained in any header. See http://wiki.mutt.org/?UserStory/SearchingMail Cheers.
icon Steve at 14:06 on 1 March 2008

Thanks for the suggestion!

Noticing that Mutt has support for the X-Label header (and thats what every other mutt-tag system I've used has abused) I've updated my plans.

Now I've got a very hacky script which will create virtual mailboxes based on tags: index-tags-maildir.

It works for me, albeit a little slowly, but I think it proves the principle is sound. (I guess that was never in doubt).

If I can't make it much faster I'll look at the existing indexers in a while.

icon madduck at 15:53 on 1 March 2008
http://madduck.net/blog/2006.09.08:mutt-tagging/ and http://madduck.net/blog/2007.07.24:a-user-space-filesystem-for-mail-labeling come to mind. :)
Also, there's a mailtags list: http://lists.madduck.net/listinfo/mailtags
icon Steve at 16:18 on 1 March 2008

Thanks for the pointers madduck, I knew I'd vaguely read them in the past.

As things stand I think that my tag indexer script will suffice for the moment (linked in the comment above). It indexes my mails in approximately 32 seconds with no cache and and 4 seconds with one present.

It doesn't solve your hierarchal needs, but I think it will work well for me. I can navigate to each folder with a particular tag, then use mutt's limit to do refined searches.

(In practise I tend to use tags sparingly "urgent", "todo", "march", etc. But I'm going to be adding tags to all incoming mails from certain people soon - and I'm hoping it will work out nicely.)

icon Kevin Mark at 16:52 on 1 March 2008
http://sup.rubyforge.org/ This guy is trying to make a mutt-like client that uses labels
icon Steve at 17:52 on 1 March 2008

Thanks Kevin that does look neat. I think I've seen it before actually.

I'm not yet ready to remove my use of folders, and just want to augment them with tags at times, so I think I'm going to rule it out for them moment.