Commit 42197dd7 authored by TAKAHASHI Tamotsu's avatar TAKAHASHI Tamotsu

unalternates now also adds to a list of exceptions; same behavior

for unlists, and unsubscribe.  With some changes from tlr.
parent f252c537
......@@ -573,7 +573,10 @@ int mutt_addr_is_user (ADDRESS *addr)
if (mutt_match_rx_list (addr->mailbox, Alternates))
{
dprint (5, (debugfile, "mail_addr_is_user: yes, %s matched by alternates.\n", addr->mailbox));
return 1;
if (mutt_match_rx_list (addr->mailbox, UnAlternates))
dprint (5, (debugfile, "mail_addr_is_user: but, %s matched by unalternates.\n", addr->mailbox));
else
return 1;
}
dprint (5, (debugfile, "mail_addr_is_user: no, all failed.\n"));
......
......@@ -1191,8 +1191,18 @@ purpose of the <tt/alternates/ command: It takes a list of regular
expressions, each of which can identify an address under which you
receive e-mail.
To remove a regular expression from this list, use the
<tt/unalternates/ command.
The <tt/unalternates/ command can be used to write exceptions to
<tt/alternates/ patterns. If an address matches something in an
<tt/alternates/ command, but you nonetheless do not think it is
from you, you can list a more precise pattern under an <tt/unalternates/
command.
To remove a regular expression from the <tt/alternates/ list, use the
<tt/unalternates/ command with exactly the same <em/regexp/.
Likewise, if the <em/regexp/ for a <tt/alternates/ command matches
an entry on the <tt/unalternates/ list, that <tt/unalternates/
entry will be removed. If the <em/regexp/ for <tt/unalternates/
is ``*'', <em/all entries/ on <tt/alternates/ will be removed.
<sect1>Mailing lists<label id="lists">
<p>
......
......@@ -139,8 +139,11 @@ WHERE LIST *MimeLookupList INITVAL(0);
WHERE LIST *UnIgnore INITVAL(0);
WHERE RX_LIST *Alternates INITVAL(0);
WHERE RX_LIST *UnAlternates INITVAL(0);
WHERE RX_LIST *MailLists INITVAL(0);
WHERE RX_LIST *UnMailLists INITVAL(0);
WHERE RX_LIST *SubscribedLists INITVAL(0);
WHERE RX_LIST *UnSubscribedLists INITVAL(0);
WHERE SPAM_LIST *SpamList INITVAL(0);
WHERE RX_LIST *NoSpamList INITVAL(0);
......
......@@ -34,12 +34,17 @@
int mutt_is_mail_list (ADDRESS *addr)
{
return mutt_match_rx_list (addr->mailbox, MailLists);
if (!mutt_match_rx_list (addr->mailbox, UnMailLists))
return mutt_match_rx_list (addr->mailbox, MailLists);
return 0;
}
int mutt_is_subscribed_list (ADDRESS *addr)
{
return mutt_match_rx_list (addr->mailbox, SubscribedLists);
if (!mutt_match_rx_list (addr->mailbox, UnMailLists)
&& !mutt_match_rx_list (addr->mailbox, UnSubscribedLists))
return mutt_match_rx_list (addr->mailbox, SubscribedLists);
return 0;
}
/* Search for a mailing list in the list of addresses pointed to by adr.
......
......@@ -507,12 +507,16 @@ static void remove_from_list (LIST **l, const char *str)
}
}
static void remove_from_rx_list (RX_LIST **l, const char *str)
static int remove_from_rx_list (RX_LIST **l, const char *str)
{
RX_LIST *p, *last = NULL;
int rv = -1;
if (mutt_strcmp ("*", str) == 0)
{
mutt_free_rx_list (l); /* ``unCMD *'' means delete all current entries */
rv = 0;
}
else
{
p = *l;
......@@ -527,6 +531,7 @@ static void remove_from_rx_list (RX_LIST **l, const char *str)
else
(*l) = p->next;
FREE (&p);
rv = 0;
}
else
{
......@@ -535,6 +540,7 @@ static void remove_from_rx_list (RX_LIST **l, const char *str)
}
}
}
return (rv);
}
static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
......@@ -628,13 +634,35 @@ static void _alternates_clean (void)
static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
_alternates_clean();
return parse_rx_list (buf, s, data, err);
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&UnAlternates, buf->data);
if (add_to_rx_list (&Alternates, buf->data, REG_ICASE, err) != 0)
return -1;
}
while (MoreArgs (s));
return 0;
}
static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
_alternates_clean();
return parse_rx_unlist (buf, s, data, err);
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&Alternates, buf->data);
if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
return -1;
}
while (MoreArgs (s));
return 0;
}
static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
......@@ -731,14 +759,32 @@ static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
return 0;
}
static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&UnMailLists, buf->data);
if (add_to_rx_list (&MailLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
while (MoreArgs (s));
return 0;
}
static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&MailLists, buf->data);
remove_from_rx_list (&SubscribedLists, buf->data);
remove_from_rx_list (&MailLists, buf->data);
if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
while (MoreArgs (s));
......@@ -750,6 +796,9 @@ static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&UnMailLists, buf->data);
remove_from_rx_list (&UnSubscribedLists, buf->data);
if (add_to_rx_list (&MailLists, buf->data, REG_ICASE, err) != 0)
return -1;
if (add_to_rx_list (&SubscribedLists, buf->data, REG_ICASE, err) != 0)
......@@ -759,6 +808,22 @@ static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
return 0;
}
static int parse_unsubscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
do
{
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&SubscribedLists, buf->data);
if (mutt_strcmp (buf->data, "*") &&
add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
while (MoreArgs (s));
return 0;
}
static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
......
......@@ -2865,6 +2865,7 @@ static int parse_spam_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_rx_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_lists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
......@@ -2875,6 +2876,7 @@ static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_my_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unmy_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_subscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unsubscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
......@@ -2884,11 +2886,12 @@ struct command_t
char *name;
int (*func) (BUFFER *, BUFFER *, unsigned long, BUFFER *);
unsigned long data;
unsigned long data1;
};
struct command_t Commands[] = {
{ "alternates", parse_alternates, UL &Alternates },
{ "unalternates", parse_unalternates, UL &Alternates },
{ "alternates", parse_alternates, 0 },
{ "unalternates", parse_unalternates, 0 },
#ifdef USE_SOCKET
{ "account-hook", mutt_parse_hook, M_ACCOUNTHOOK },
#endif
......@@ -2910,7 +2913,7 @@ struct command_t Commands[] = {
{ "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
#endif
{ "ignore", parse_ignore, 0 },
{ "lists", parse_rx_list, UL &MailLists },
{ "lists", parse_lists, 0 },
{ "macro", mutt_parse_macro, 0 },
{ "mailboxes", mutt_parse_mailboxes, M_MAILBOXES },
{ "unmailboxes", mutt_parse_mailboxes, M_UNMAILBOXES },
......@@ -2946,6 +2949,6 @@ struct command_t Commands[] = {
{ "unmy_hdr", parse_unmy_hdr, 0 },
{ "unscore", mutt_parse_unscore, 0 },
{ "unset", parse_set, M_SET_UNSET },
{ "unsubscribe", parse_rx_unlist, UL &SubscribedLists },
{ "unsubscribe", parse_unsubscribe, 0 },
{ NULL }
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment