X-Label vs X-Keywords question.

313 views
Skip to first unread message

Paul Provost

unread,
Aug 8, 2012, 2:59:15 PM8/8/12
to mu-di...@googlegroups.com
Hi all,

    I'm trying to get a cross-platform (Linux and Mac) solution for e-mail tagging going, and was wondering how I could configure the field that mu uses for tags. It currently uses X-Label, but the tagging solution I use on OSX (MailTags) uses X-Keywords instead. Is there a way to make mu use that as well? I'd rather not have to write a script to synchonize the two headers, as this seems more trouble than it's worth and error prone.

Thanks for any advice!

Paul

Dirk-Jan C. Binnema

unread,
Aug 8, 2012, 5:26:10 PM8/8/12
to mu-di...@googlegroups.com
Hi Paul,
Hmm, it seems that 'X-Keywords' is similar to 'X-Label', except that the
latter uses spaces rather than commas to separate the keywords/labels.

I'll update mu to check 'X-Keywords' as well; if you can't wait for
that, you could search for 'X-Label' in the source and replace that with
X-Keywords.

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Paul Provost

unread,
Aug 9, 2012, 12:11:17 PM8/9/12
to mu-di...@googlegroups.com
Hi Dirk,

    Thanks for the quick response. So I just have to modify lib/mu-msg-file.c to test it out? Sounds great. I'll still be on the lookout for  the next version though.

    As long as we're talking, would there be a way to list all the tags/labels/keywords that are in the index? To generate a tag cloud or some other info.

Thanks again!

Paul

On Wednesday, 8 August 2012 17:26:10 UTC-4, djcb wrote:
Hi Paul,

On 2012-08-08 21:59, Paul Provost wrote:

 > Hi all,

 >     I'm trying to get a cross-platform (Linux and Mac) solution for e-mail
 > tagging going, and was wondering how I could configure the field that mu
 > uses for tags. It currently uses X-Label, but the tagging solution I use on
 > OSX (MailTags) uses X-Keywords instead. Is there a way to make mu use that
 > as well? I'd rather not have to write a script to synchonize the two
 > headers, as this seems more trouble than it's worth and error prone.

Hmm, it seems that 'X-Keywords' is similar to 'X-Label', except that the
latter uses spaces rather than commas to separate the keywords/labels.

I'll update mu to check 'X-Keywords' as well; if you can't wait for
that, you could search for 'X-Label' in the source and replace that with
X-Keywords.

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema                  Helsinki, Finland
e:d...@djcbsoftware.nl           w:www.djcbsoftware.nl

Dirk-Jan C. Binnema

unread,
Aug 9, 2012, 2:42:35 PM8/9/12
to mu-di...@googlegroups.com
Hi Paul,

On 2012-08-09 19:11, Paul Provost wrote:

> Hi Dirk,

> Thanks for the quick response. So I just have to
> modify lib/mu-msg-file.c to test it out? Sounds great. I'll still be on the
> lookout for the next version though.

I have something like below (to replace the get_tags in mu-msg-file.c),
which will get both X-Label and X-Keywords; I'll push it once I have
tested it a bit more.

--8<---------------cut here---------------start------------->8---
/* see: http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html */
static GSList*
get_tags (MuMsgFile *self)
{
GSList *lst1, *lst2, *last;
char *hdr;

lst1 = lst2 = NULL;

/* X-Label are space-separated */
hdr = mu_msg_file_get_header (self, "X-Label");
if (hdr) {
lst1 = mu_str_to_list (hdr, ' ', TRUE);
g_free (hdr);
}

/* X-Keywords are ','-separated */
hdr = mu_msg_file_get_header (self, "X-Keywords");
if (hdr) {
lst2 = mu_str_to_list (hdr, ',', TRUE);
g_free (hdr);
}

if (!lst1)
return lst2;

/* append lst2, if any */
last = g_slist_last (lst1);
last->next = lst2;

return lst1;
}
--8<---------------cut here---------------end--------------->8---

> As long as we're talking, would there be a way to list all the
> tags/labels/keywords that are in the index? To generate a tag cloud or some
> other info.

Someone was working on this, see
https://github.com/djcb/mu/pull/38
Not sure of the current status though.

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Paul Provost

unread,
Aug 9, 2012, 4:05:13 PM8/9/12
to mu-di...@googlegroups.com
Thanks for the tip on the listing of indexed words. I'll keep an eye out on that.

I noticed that the X-Keywords header on the messages that I already have tagged were not comma-separated, but space-separated. I couldn't find any official spec on this, though. There _is_ an additional Keywords header mentioned in RFC 2822 that _is_ comma-space separated.

Aren't standards fun?

So I guess you would have:

        hdr = mu_msg_file_get_header (self, "X-Keywords"); 
        if (hdr) { 
                lst2 = mu_str_to_list (hdr, ' ', TRUE); 
                g_free (hdr); 
        } 

and

        hdr = mu_msg_file_get_header (self, "Keywords"); 
        if (hdr) { 
                lst3 = mu_str_to_list (hdr, ',', TRUE); 
                g_free (hdr); 
        } 

And then manage the three lists. Whaddaya think?

Paul

Dirk-Jan C. Binnema

unread,
Aug 9, 2012, 4:55:28 PM8/9/12
to mu-di...@googlegroups.com
Hi,

On 2012-08-09 23:05, Paul Provost wrote:

> Thanks for the tip on the listing of indexed words. I'll keep an eye out on
> that.

> I noticed that the X-Keywords header on the messages that I already have
> tagged were not comma-separated, but space-separated. I couldn't find any
> official spec on this, though. There _is_ an additional Keywords header
> mentioned in RFC 2822 <http://tools.ietf.org/html/rfc2822#section-3.6.5> that
> _is_ comma-space separated.

> Aren't standards fun?

Indeed! Maybe I should change things so either commas or spaces (or any
non-word char) are accepted as separators.

> So I guess you would have:

> hdr = mu_msg_file_get_header (self, "X-Keywords");
> if (hdr) {
> lst2 = mu_str_to_list (hdr, ' ', TRUE);
> g_free (hdr);
> }

> and

> hdr = mu_msg_file_get_header (self, "Keywords");
> if (hdr) {
> lst3 = mu_str_to_list (hdr, ',', TRUE);
> g_free (hdr);
> }

> And then manage the three lists. Whaddaya think?

I found some examples of both, but they seem to be quite rare in my mail
corpus (less than 0.1%). But yeah, I can add that.

Best wishes,
Dirk.


--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Paul Provost

unread,
Aug 10, 2012, 6:45:10 AM8/10/12
to mu-di...@googlegroups.com
Keywords is used by Outlook for its categories. I have to use Outlook at work, but I file all messages to a local IMAP server running in a VirtualBox (yeah, I know...). So that would be useful to me there as well.

Thanks again!

Paul

Dirk-Jan C. Binnema

unread,
Aug 10, 2012, 6:57:25 AM8/10/12
to mu-di...@googlegroups.com
Hi,

On 2012-08-10 13:45, Paul Provost wrote:

> Keywords is used by Outlook for its categories. I have to use Outlook
> at work, but I file all messages to a local IMAP server running in a
> VirtualBox (yeah, I know...). So that would be useful to me there as
> well.

--8<---------------cut here---------------start------------->8---
/* see: http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html */
static GSList*
get_tags (MuMsgFile *self)
{
GSList *lst;
unsigned u;
struct {
const char *header;
char sepa;
} tagfields[] = {
{ "X-Label", ' ' },
{ "X-Keywords", ',' },
{ "Keywords", ' ' }
};

for (lst = NULL, u = 0; u != G_N_ELEMENTS(tagfields); ++u) {
gchar *hdr;
hdr = mu_msg_file_get_header (self, tagfields[u].header);
if (hdr) {
GSList *hlst;
hlst = mu_str_to_list (hdr, tagfields[u].sepa, TRUE);

if (lst)
(g_slist_last (lst))->next = hlst;
else
lst = hlst;

g_free (hdr);
}
}

return lst;
}
--8<---------------cut here---------------end--------------->8---

Something like this?

Best wishes,
Dirk.


--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Paul Provost

unread,
Aug 10, 2012, 7:03:36 AM8/10/12
to mu-di...@googlegroups.com
Niice! I assume that trailing spaces get stripped somewhere else? The comma-separated ones are usually comma-space separated.

Keywords: tag1, tag2, tag3

Otherwise perfect!

Paul

Dirk-Jan C. Binnema

unread,
Aug 10, 2012, 8:02:12 AM8/10/12
to mu-di...@googlegroups.com
Hi Paul,

On 2012-08-10 14:03, Paul Provost wrote:

> Niice! I assume that trailing spaces get stripped somewhere else? The
> comma-separated ones are usually comma-space separated.

> Keywords: tag1, tag2, tag3

Indeed; mu_str_to_list uses g_strstrip on the elements.

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
Reply all
Reply to author
Forward
0 new messages