Re: For 1.5.8: notalternates functionality
On Thu, Feb 10, 2005 at 08:48:31AM -0600, Charles Cazabon wrote:
> Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx> wrote:
> > > The attached patch allows users to exclude portions of the namespace
> > > matched by alternates.
>
> > Mhh... I think the plan after 1.5.7 was to model unalternates after
> > the ignore/unignore combo, where we not only use unignore to remove
> > things from the ignore list, but also to add things to an unignore
> > list.
>
> I'm not entirely sure I'm clear on the meaning of this. I think you mean
> that, for example, `unnotalternates foo` would first check whether "foo" was
> one of the patterns given in `notalternates`; if so, it would simply remove
> that pattern. If it was not one of the notalternates patterns, it would then
> add it to the list of unnotalternates patterns.
Well, although I don't want to take part in this topic,
I post my another untested patch here for Alain's sake. :)
This patch hopefully makes un/alternates similar to un/ignore (instead of
no/spam).
(What Alain said is here:
http://marc.theaimsgroup.com/?l=mutt-dev&m=110703978728546&w=2 )
--
tamo
Index: alias.c
===================================================================
RCS file: /home/roessler/cvs/mutt/alias.c,v
retrieving revision 3.9
diff -u -r3.9 alias.c
--- alias.c 1 Feb 2004 17:10:43 -0000 3.9
+++ alias.c 27 Jan 2005 02:28:56 -0000
@@ -569,7 +569,10 @@
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"));
Index: globals.h
===================================================================
RCS file: /home/roessler/cvs/mutt/globals.h,v
retrieving revision 3.12
diff -u -r3.12 globals.h
--- globals.h 26 Jan 2005 13:36:44 -0000 3.12
+++ globals.h 27 Jan 2005 02:28:56 -0000
@@ -131,6 +131,7 @@
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 *SubscribedLists INITVAL(0);
WHERE SPAM_LIST *SpamList INITVAL(0);
Index: init.c
===================================================================
RCS file: /home/roessler/cvs/mutt/init.c,v
retrieving revision 3.27
diff -u -r3.27 init.c
--- init.c 7 Dec 2004 19:50:04 -0000 3.27
+++ init.c 27 Jan 2005 02:28:57 -0000
@@ -503,12 +503,16 @@
}
}
-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;
@@ -523,6 +527,7 @@
else
(*l) = p->next;
FREE (&p);
+ rv = 0;
}
else
{
@@ -531,6 +536,7 @@
}
}
}
+ return (rv);
}
static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
*err)
@@ -624,13 +630,35 @@
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);
+ if (remove_from_rx_list (&UnAlternates, buf->data) != 0)
+ {
+ 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);
+ if (remove_from_rx_list (&Alternates, buf->data) != 0)
+ {
+ if (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)
Index: init.h
===================================================================
RCS file: /home/roessler/cvs/mutt/init.h,v
retrieving revision 3.59
diff -u -r3.59 init.h
--- init.h 26 Jan 2005 13:36:44 -0000 3.59
+++ init.h 27 Jan 2005 02:28:58 -0000
@@ -2856,8 +2856,8 @@
};
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
Index: doc/manual.sgml.head
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/manual.sgml.head,v
retrieving revision 3.35
diff -u -r3.35 manual.sgml.head
--- doc/manual.sgml.head 15 Jan 2005 07:36:37 -0000 3.35
+++ doc/manual.sgml.head 27 Jan 2005 02:29:00 -0000
@@ -1191,8 +1191,19 @@
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, and
+vice versa.
<sect1>Mailing lists<label id="lists">
<p>