Ticket #3245: mutt_mbox_alias.4.patch

File mutt_mbox_alias.4.patch, 6.1 KB (added by tamentis, 6 years ago)

Patch adding 'mbalias' command and to mutt

  • doc/manual.xml.head

    diff -r d213f3acdb68 doc/manual.xml.head
    a b  
    43554355 
    43564356</sect1> 
    43574357 
     4358<sect1 id="mbalias"> 
     4359<title>Mailbox Aliases</title> 
     4360 
     4361<para>Usage:</para> 
     4362 
     4363<cmdsynopsis> 
     4364<command>mbalias</command> 
     4365<arg choice="plain"> 
     4366<replaceable class="parameter">name</replaceable> 
     4367</arg> 
     4368<arg choice="plain"> 
     4369<replaceable class="parameter">path</replaceable> 
     4370</arg> 
     4371</cmdsynopsis> 
     4372 
     4373<para> 
     4374This command will let you define aliases for your mailboxes. This is  
     4375typically used with IMAP or POP mailboxes with longer path/URLs but it 
     4376can be used for any other path. Within Mutt you can use the '*' prefix 
     4377to use and access your alias like any other path. Here is an example with 
     4378<command>mailboxes</command>: 
     4379<screen> 
     4380mbalias work imaps://user@imap.bigcompany.com/projects/x/inbox 
     4381mailboxes *work</screen> 
     4382</para> 
     4383 
     4384</sect1> 
     4385 
    43584386</chapter> 
    43594387 
    43604388<chapter id="advancedusage"> 
     
    53615389@<emphasis>alias</emphasis> &mdash; refers to the <link linkend="save-hook">default save folder</link> as determined by the address of the alias 
    53625390</para> 
    53635391</listitem> 
     5392<listitem> 
     5393 
     5394<para> 
     5395*<emphasis>alias</emphasis> &mdash; refers to a <link linkend="mbalias">Mailbox alias</link> 
     5396</para> 
     5397</listitem> 
    53645398 
    53655399</itemizedlist> 
    53665400 
  • doc/muttrc.man.head

    diff -r d213f3acdb68 doc/muttrc.man.head
    a b  
    272272and subscribed mailing lists.  The \fBunsubscribe\fP command removes 
    273273it from the list of subscribed mailing lists. The \fb-group\fP flag 
    274274adds all of the subsequent regular expressions to the named group. 
    275 .TP 
     275.PP 
     276.nf 
     277\fBmbalias\fP \fIname\fP \fIpath\fP 
     278.fi 
     279.IP 
     280This command lets you define aliases for your mailboxes. It is used 
     281mostly to shorten very long path and URLs such as IMAP or POP accounts but 
     282can also be used with any other prefix or path. You can use it within mutt 
     283with the '*' prefix. 
     284.PP 
     285.nf 
    276286\fBmbox-hook\fP [\fB!\fP]\fIpattern\fP \fImailbox\fP 
     287.fi 
     288.IP 
    277289When mutt changes to a mail folder which matches \fIpattern\fP, 
    278290\fImailbox\fP will be used as the \(lqmbox\(rq folder, i.e., read 
    279291messages will be moved to that folder when the mail folder is left. 
  • globals.h

    diff -r d213f3acdb68 globals.h
    a b  
    220220 
    221221WHERE ALIAS *Aliases INITVAL (0); 
    222222WHERE LIST *UserHeader INITVAL (0); 
     223WHERE MBALIAS *MbAliases INITVAL (0); 
    223224 
    224225/*-- formerly in pgp.h --*/ 
    225226WHERE REGEXP PgpGoodSign; 
  • init.c

    diff -r d213f3acdb68 init.c
    a b  
    13881388  return -1; 
    13891389} 
    13901390 
     1391static int parse_mbalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 
     1392{ 
     1393  MBALIAS *tmp = MbAliases; 
     1394  MBALIAS *last = NULL; 
     1395  BUFFER name, path; 
     1396  char exp_path[_POSIX_PATH_MAX]; 
     1397 
     1398  memset (&name, 0, sizeof (name)); 
     1399  memset (&path, 0, sizeof (path)); 
     1400 
     1401  if (!MoreArgs (s)) 
     1402  { 
     1403    strfcpy (err->data, _("too few arguments"), err->dsize); 
     1404    goto error; 
     1405  } 
     1406 
     1407  mutt_extract_token (&name, s, 0); 
     1408 
     1409  if (!buf->data) 
     1410  { 
     1411    strfcpy (err->data, _("too few arguments"), err->dsize); 
     1412    goto error; 
     1413  } 
     1414 
     1415  mutt_extract_token (&path, s, 0); 
     1416 
     1417  if (MoreArgs (s)) 
     1418  { 
     1419    strfcpy (err->data, _("too many arguments"), err->dsize); 
     1420    goto error; 
     1421  } 
     1422 
     1423  /* keep the expanded path with the alias */ 
     1424  strfcpy (exp_path, path.data, sizeof (exp_path)); 
     1425  mutt_expand_path (exp_path, sizeof (exp_path)); 
     1426  FREE (&path.data); 
     1427 
     1428  /* check to see if an alias with this name already exists */ 
     1429  for (; tmp; tmp = tmp->next) 
     1430  { 
     1431    if (!mutt_strcasecmp (tmp->name, name.data)) 
     1432      break; 
     1433    last = tmp; 
     1434  } 
     1435 
     1436  if (!tmp) 
     1437  { 
     1438    /* create a new alias */ 
     1439    tmp = (MBALIAS *) safe_calloc (1, sizeof (MBALIAS)); 
     1440    tmp->name = safe_strdup (name.data); 
     1441    FREE (&name.data); 
     1442    tmp->path = safe_strdup (exp_path); 
     1443  } 
     1444  else 
     1445  { 
     1446    /* override the previous value */ 
     1447    mutt_str_replace(&tmp->path, exp_path); 
     1448  } 
     1449 
     1450 
     1451  if (last) 
     1452    last->next = tmp; 
     1453  else 
     1454    MbAliases = tmp; 
     1455 
     1456  return 0; 
     1457 
     1458error: 
     1459  FREE (&name.data); 
     1460  FREE (&path.data); 
     1461  return (-1); 
     1462} 
     1463 
    13911464static int 
    13921465parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 
    13931466{ 
  • init.h

    diff -r d213f3acdb68 init.h
    a b  
    34143414static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    34153415static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    34163416static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
     3417static int parse_mbalias (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    34173418static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    34183419static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
    34193420static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *); 
     
    34723473  { "macro",            mutt_parse_macro,       0 }, 
    34733474  { "mailboxes",        mutt_parse_mailboxes,   M_MAILBOXES }, 
    34743475  { "unmailboxes",      mutt_parse_mailboxes,   M_UNMAILBOXES }, 
     3476  { "mbalias",          parse_mbalias,          0 }, 
    34753477  { "message-hook",     mutt_parse_hook,        M_MESSAGEHOOK }, 
    34763478  { "mbox-hook",        mutt_parse_hook,        M_MBOXHOOK }, 
    34773479  { "mime_lookup",      parse_list,     UL &MimeLookupList }, 
  • mutt.h

    diff -r d213f3acdb68 mutt.h
    a b  
    568568  short num; 
    569569} ALIAS; 
    570570 
     571typedef struct mbalias 
     572{ 
     573  char *name; 
     574  char *path; 
     575  struct mbalias *next; 
     576} MBALIAS; 
     577 
    571578typedef struct envelope 
    572579{ 
    573580  ADDRESS *return_path; 
  • muttlib.c

    diff -r d213f3acdb68 muttlib.c
    a b  
    444444        } 
    445445      } 
    446446      break; 
     447 
     448      case '*': 
     449      { 
     450        MBALIAS *alias = MbAliases; 
     451 
     452        tail = s + 1; 
     453        for (; alias; alias = alias->next) 
     454        { 
     455          if (!mutt_strcasecmp (alias->name, s + 1)) { 
     456            strfcpy (p, alias->path, sizeof (p)); 
     457            tail = ""; 
     458            break; 
     459          } 
     460        } 
     461      } 
     462      break; 
    447463       
    448464      case '>': 
    449465      {