Hi list, I'm a big fan of 'c' to quickly switch between mail boxes but I have to admit that my few IMAP/POP accounts are hard to reach. I know there are a few workarounds to simulate aliases but I thought I'd try a less redundant solution. This small patch allows the following syntax when defining mailboxes:
mailboxes js=imaps://u...@myhost.com/ mailboxes errors=imaps://ot...@stuff.com/ mailboxes longpath=+work/project/x/errors/critical It also add the '*' prefix to access the aliases, e.g. you would access the above mboxes with 'c*js' or 'c*errors'. Here are a few threads/tickets with people needing a similar feature: http://marc.info/?t=123445691900006&r=1&w=2 http://marc.info/?t=117394194000032&r=1&w=2 http://marc.info/?t=114659249800001&r=1&w=2 ticket #3245 ... Cheers, Bertrand
diff -r d213f3acdb68 buffy.c --- a/buffy.c Mon Jun 15 14:24:27 2009 -0700 +++ b/buffy.c Tue Jun 16 23:04:04 2009 -0400 @@ -194,15 +194,19 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err) { BUFFY **tmp,*tmp1; + char *alias; char buf[_POSIX_PATH_MAX]; + char tbuf[_POSIX_PATH_MAX]; struct stat sb; char f1[PATH_MAX], f2[PATH_MAX]; char *p, *q; + int len; while (MoreArgs (s)) { mutt_extract_token (path, s, 0); strfcpy (buf, path->data, sizeof (buf)); + alias = NULL; if(data == M_UNMAILBOXES && mutt_strcmp(buf,"*") == 0) { @@ -220,6 +224,17 @@ /* Skip empty tokens. */ if(!*buf) continue; + /* Strip out alias for later */ + if ((p = strchr(buf, '=')) != NULL) + { + len = p - buf; + alias = malloc(len + 1); + strncpy(alias, buf, len); + alias[len] = '\0'; + strcpy(tbuf, p + 1); + strcpy(buf, tbuf); + } + /* avoid duplicates */ p = realpath (buf, f1); for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) @@ -251,13 +266,19 @@ (*tmp)->next = NULL; /* it is tempting to set magic right here */ (*tmp)->magic = 0; - + (*tmp)->alias[0] = '\0'; } (*tmp)->new = 0; (*tmp)->notified = 1; (*tmp)->newly_created = 0; + if (alias != NULL) + { + strcpy((*tmp)->alias, alias); + free(alias); + } + /* for check_mbox_size, it is important that if the folder is new (tested by * reading it), the size is set to 0 so that later when we check we see * that it increased . without check_mbox_size we probably don't care. @@ -271,6 +292,7 @@ else (*tmp)->size = 0; } + return 0; } diff -r d213f3acdb68 buffy.h --- a/buffy.h Mon Jun 15 14:24:27 2009 -0700 +++ b/buffy.h Tue Jun 16 23:04:04 2009 -0400 @@ -23,6 +23,7 @@ typedef struct buffy_t { char path[_POSIX_PATH_MAX]; + char alias[_POSIX_PATH_MAX]; off_t size; struct buffy_t *next; short new; /* mailbox has new mail */ diff -r d213f3acdb68 muttlib.c --- a/muttlib.c Mon Jun 15 14:24:27 2009 -0700 +++ b/muttlib.c Tue Jun 16 23:04:04 2009 -0400 @@ -27,6 +27,7 @@ #include "mailbox.h" #include "mx.h" #include "url.h" +#include "buffy.h" #ifdef USE_IMAP #include "imap.h" @@ -354,6 +355,7 @@ char q[_POSIX_PATH_MAX] = ""; char tmp[_POSIX_PATH_MAX]; char *t; + BUFFY *btmp; char *tail = ""; @@ -444,6 +446,20 @@ } } break; + + case '*': + { + tail = s + 1; + for (btmp = Incoming; btmp; btmp = btmp->next) { + if (s[1] != '\0' && mutt_strcmp(s + 1, btmp->alias) == 0) + { + strfcpy (p, btmp->path, sizeof (p)); + tail = ""; + break; + } + } + } + break; case '>': {