From: Alain Bench <veronatif@free.fr>
Date: Fri, 2 Sep 2005 18:02:27 +0000 (+0000)
Subject: Adjust ~l to match all known lists, add ~u to match only subscribed lists.
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad5dbe057b922fde0f03f7fe485f3962a4e5085e;p=neomutt

Adjust ~l to match all known lists, add ~u to match only subscribed lists.
Normalise pattern ordering in docs. Closes: #2050.
---

diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head
index 7a0ea3683..5e150c455 100644
--- a/doc/manual.sgml.head
+++ b/doc/manual.sgml.head
@@ -3263,18 +3263,18 @@ messages:
 ~B EXPR         messages which contain EXPR in the whole message
 ~c USER         messages carbon-copied to USER
 ~C EXPR         message is either to: or cc: EXPR
-~D              deleted messages
 ~d [MIN]-[MAX]  messages with ``date-sent'' in a Date range
-~E              expired messages
+~D              deleted messages
 ~e EXPR         message which contains EXPR in the ``Sender'' field
+~E              expired messages
 ~F              flagged messages
 ~f USER         messages originating from USER
 ~g              cryptographically signed messages
 ~G              cryptographically encrypted messages
-~H EXPR         messages with a spam attribute matching EXPR
 ~h EXPR         messages which contain EXPR in the message header
-~k		message contains PGP key material
+~H EXPR         messages with a spam attribute matching EXPR
 ~i ID           message which match ID in the ``Message-ID'' field
+~k		message contains PGP key material
 ~L EXPR         message is either originated or received by EXPR
 ~l              message is addressed to a known mailing list
 ~m [MIN]-[MAX]  message in the range MIN to MAX *)
@@ -3284,12 +3284,13 @@ messages:
 ~p              message is addressed to you (consults alternates)
 ~P              message is from you (consults alternates)
 ~Q              messages which have been replied to
-~R              read messages
 ~r [MIN]-[MAX]  messages with ``date-received'' in a Date range
-~S              superseded messages
+~R              read messages
 ~s SUBJECT      messages having SUBJECT in the ``Subject'' field.
-~T              tagged messages
+~S              superseded messages
 ~t USER         messages addressed to USER
+~T              tagged messages
+~u		message is addressed to a subscribed mailing list
 ~U              unread messages
 ~v		message is part of a collapsed thread.
 ~V		cryptographically verified messages
diff --git a/doc/muttrc.man.head b/doc/muttrc.man.head
index fbd2e6817..9823d0527 100644
--- a/doc/muttrc.man.head
+++ b/doc/muttrc.man.head
@@ -405,20 +405,20 @@ l l.
 ~B \fIEXPR\fP	messages which contain \fIEXPR\fP in the whole message
 ~c \fIEXPR\fP	messages carbon-copied to \fIEXPR\fP
 ~C \fIEXPR\fP	message is either to: or cc: \fIEXPR\fP
-~D	deleted messages
 ~d \fIMIN\fP-\fIMAX\fP	messages with \(lqdate-sent\(rq in a Date range
-~E	expired messages
+~D	deleted messages
 ~e \fIEXPR\fP	message which contains \fIEXPR\fP in the \(lqSender\(rq field
-~F	flagged messages
+~E	expired messages
 ~f \fIEXPR\fP	messages originating from \fIEXPR\fP
+~F	flagged messages
 ~g	PGP signed messages
 ~G	PGP encrypted messages
-~H \fIEXPR\fP	messages with spam tags matching \fIEXPR\fP
 ~h \fIEXPR\fP	messages which contain \fIEXPR\fP in the message header
-~k	message contains PGP key material
+~H \fIEXPR\fP	messages with spam tags matching \fIEXPR\fP
 ~i \fIEXPR\fP	message which match \fIEXPR\fP in the \(lqMessage-ID\(rq field
-~L \fIEXPR\fP	message is either originated or received by \fIEXPR\fP
+~k	message contains PGP key material
 ~l	message is addressed to a known mailing list
+~L \fIEXPR\fP	message is either originated or received by \fIEXPR\fP
 ~m \fIMIN\fP-\fIMAX\fP	message in the range \fIMIN\fP to \fIMAX\fP
 ~n \fIMIN\fP-\fIMAX\fP	messages with a score in the range \fIMIN\fP to \fIMAX\fP
 ~N	new messages
@@ -426,15 +426,18 @@ l l.
 ~p	message is addressed to you (consults $alternates)
 ~P	message is from you (consults $alternates)
 ~Q	messages which have been replied to
-~R	read messages
 ~r \fIMIN\fP-\fIMAX\fP	messages with \(lqdate-received\(rq in a Date range
-~S	superseded messages
+~R	read messages
 ~s \fIEXPR\fP	messages having \fIEXPR\fP in the \(lqSubject\(rq field.
-~T	tagged messages
+~S	superseded messages
 ~t \fIEXPR\fP	messages addressed to \fIEXPR\fP
+~T	tagged messages
+~u	message is addressed to a subscribed mailing list
 ~U	unread messages
 ~v	message is part of a collapsed thread.
+~V	cryptographically verified messages
 ~x \fIEXPR\fP	messages which contain \fIEXPR\fP in the \(lqReferences\(rq field
+~y \fIEXPR\fP	messages which contain \fIEXPR\fP in the \(lqX-Label\(rq field
 ~z \fIMIN\fP-\fIMAX\fP	messages with a size in the range \fIMIN\fP to \fIMAX\fP
 ~=	duplicated messages (see $duplicate_threads)
 ~$	unreferenced message (requries threaded view)
diff --git a/mutt.h b/mutt.h
index e27c2ed8e..2e8ee1e5b 100644
--- a/mutt.h
+++ b/mutt.h
@@ -233,6 +233,7 @@ enum
   M_REFERENCE,
   M_RECIPIENT,
   M_LIST,
+  M_SUBSCRIBED_LIST,
   M_PERSONAL_RECIP,
   M_PERSONAL_FROM,
   M_ADDRESS,
diff --git a/pattern.c b/pattern.c
index 373392bcb..bcaaabf26 100644
--- a/pattern.c
+++ b/pattern.c
@@ -59,14 +59,14 @@ Flags[] =
   { 'E', M_EXPIRED,		0,		NULL },
   { 'f', M_FROM,		0,		eat_regexp },
   { 'F', M_FLAG,		0,		NULL },
-  { 'g', M_CRYPT_SIGN, 		0, 		NULL },
-  { 'G', M_CRYPT_ENCRYPT, 	0, 		NULL },
+  { 'g', M_CRYPT_SIGN,		0,		NULL },
+  { 'G', M_CRYPT_ENCRYPT,	0,		NULL },
   { 'h', M_HEADER,		M_FULL_MSG,	eat_regexp },
   { 'H', M_HORMEL,		0,		eat_regexp },
   { 'i', M_ID,			0,		eat_regexp },
-  { 'k', M_PGP_KEY, 		0, 		NULL },
-  { 'L', M_ADDRESS,		0,		eat_regexp },
+  { 'k', M_PGP_KEY,		0,		NULL },
   { 'l', M_LIST,		0,		NULL },
+  { 'L', M_ADDRESS,		0,		eat_regexp },
   { 'm', M_MESSAGE,		0,		eat_range },
   { 'n', M_SCORE,		0,		eat_range },
   { 'N', M_NEW,			0,		NULL },
@@ -74,15 +74,16 @@ Flags[] =
   { 'p', M_PERSONAL_RECIP,	0,		NULL },
   { 'P', M_PERSONAL_FROM,	0,		NULL },
   { 'Q', M_REPLIED,		0,		NULL },
-  { 'R', M_READ,		0,		NULL },
   { 'r', M_DATE_RECEIVED,	0,		eat_date },
+  { 'R', M_READ,		0,		NULL },
   { 's', M_SUBJECT,		0,		eat_regexp },
   { 'S', M_SUPERSEDED,		0,		NULL },
-  { 'T', M_TAG,			0,		NULL },
   { 't', M_TO,			0,		eat_regexp },
+  { 'T', M_TAG,			0,		NULL },
+  { 'u', M_SUBSCRIBED_LIST,	0,		NULL },
   { 'U', M_UNREAD,		0,		NULL },
   { 'v', M_COLLAPSED,		0,		NULL },
-  { 'V', M_CRYPT_VERIFIED,      0,              NULL },
+  { 'V', M_CRYPT_VERIFIED,	0,		NULL },
   { 'x', M_REFERENCE,		0,		eat_regexp },
   { 'y', M_XLABEL,		0,		eat_regexp },
   { 'z', M_SIZE,		0,		eat_range },
@@ -916,6 +917,9 @@ static int match_reference (regex_t *rx, LIST *refs)
   return 0;
 }
 
+/*
+ * Matches subscribed mailing lists
+ */
 int mutt_is_list_recipient (int alladdr, ADDRESS *a1, ADDRESS *a2)
 {
   for (; a1 ; a1 = a1->next)
@@ -927,6 +931,11 @@ int mutt_is_list_recipient (int alladdr, ADDRESS *a1, ADDRESS *a2)
   return alladdr;
 }
 
+/*
+ * Matches known mailing lists
+ * The function name may seem a little bit misleading: It checks all
+ * recipients in To and Cc for known mailing lists, subscribed or not.
+ */
 int mutt_is_list_cc (int alladdr, ADDRESS *a1, ADDRESS *a2)
 {
   for (; a1 ; a1 = a1->next)
@@ -1025,8 +1034,12 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx,
     case M_RECIPIENT:
            return (pat->not ^ (h->env && match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
 					pat->alladdr, 2, h->env->to, h->env->cc)));
-    case M_LIST:
-      return (pat->not ^ (h->env && mutt_is_list_recipient (pat->alladdr, h->env->to, h->env->cc)));
+    case M_LIST:	/* known list, subscribed or not */
+      return (pat->not ^ (h->env
+	&& mutt_is_list_cc (pat->alladdr, h->env->to, h->env->cc)));
+    case M_SUBSCRIBED_LIST:
+      return (pat->not ^ (h->env
+	&& mutt_is_list_recipient (pat->alladdr, h->env->to, h->env->cc)));
     case M_PERSONAL_RECIP:
       return (pat->not ^ (h->env && match_user (pat->alladdr, h->env->to, h->env->cc)));
     case M_PERSONAL_FROM: