Re: [PATCH] Re: handling List-Id header
On 04-12 14:20, Michael Elkins wrote: Attached is a patch which implement an auto-subscribe feature. When you load a mailbox, Mutt will parse the List-Post header field and add it to the 'subscribe' list automatically, unless it matches something on the 'unlists' or 'unsubscribe' list. Thanks, this is awesome. Why did you not push it into the mainline code? -- ilf@jabber.berlin.ccc.de Über 80 Millionen Deutsche benutzen keine Konsole. Klick dich nicht weg! -- Eine Initiative des Bundesamtes für Tastaturbenutzung signature.asc Description: Digital signature
Re: handling List-Id header
On Mon, Apr 12, 2010 at 10:47:21AM +0200, ilf wrote: On 04-11 20:22, Michael Elkins wrote: The reason for the distinction between lists/subscribe is that just because you received an email that was addressed to a list doesn't mean that you are subscribed to said list. But if there's a List-Id header, I am subscribed. That's not necessarily true. For example, Mutt allows you to bounce a message, headers and all, to someone else. It's also possible for a human to add a (possibly bogus) List-Id header, just to mess with you, or who knows what other reason. You might also receive spam that adds such headers. Etc.. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpK7yXO8lDUZ.pgp Description: PGP signature
Re: handling List-Id header
On 04-11 20:32, Michael Elkins wrote: On Sat, Apr 10, 2010 at 01:38:19AM +0200, ilf wrote: I would like a workaround to use Regex in 'lists' and 'subscribe', but that feels dirty. Why doesn't Mutt allow 'lists'/'subscribe' to lists based on the List-Id: header? The List-ID header is not necessarily a valid email address. All that the RFC requires is that it be a unique value for each list. As such, it's not terribly useful for figuring out where to reply. I never proposed using List-Id to figure out where to reply, List-Post is the right field for that and it's being done nicely. But I think Mutt could display messages as from a list (in index with %L and %Z) automatically, if a List-Id header is present. Then I would not need lists/subscribe at all. The problem with not using the subscribe command in Mutt is the very common case where your address appears on the To or CC line in addition to the mailing list address. In this sitation you will receive two copies of the email: one directly from the message sender, and another from the mailing list software. That's a user error in my view and not something Mutt should care about. People should use list-reply instead of reply-all. On 04-11 20:22, Michael Elkins wrote: The reason for the distinction between lists/subscribe is that just because you received an email that was addressed to a list doesn't mean that you are subscribed to said list. But if there's a List-Id header, I am subscribed. -- ilf@jabber.berlin.ccc.de Über 80 Millionen Deutsche benutzen keine Konsole. Klick dich nicht weg! -- Eine Initiative des Bundesamtes für Tastaturbenutzung signature.asc Description: Digital signature
Re: handling List-Id header
On Mon, Apr 12, 2010 at 10:47:21AM +0200, ilf wrote: On 04-11 20:32, Michael Elkins wrote: On Sat, Apr 10, 2010 at 01:38:19AM +0200, ilf wrote: I would like a workaround to use Regex in 'lists' and 'subscribe', but that feels dirty. Why doesn't Mutt allow 'lists'/'subscribe' to lists based on the List-Id: header? The List-ID header is not necessarily a valid email address. All that the RFC requires is that it be a unique value for each list. As such, it's not terribly useful for figuring out where to reply. I never proposed using List-Id to figure out where to reply, List-Post is the right field for that and it's being done nicely. But I think Mutt could display messages as from a list (in index with %L and %Z) automatically, if a List-Id header is present. Then I would not need lists/subscribe at all. And also match them with ~l when searching. Maybe. (I'm not sure how that would work for IMAP.) Another possibility would be to have a tool that scans a folder for list addresses and constructs list/subscribed lists accordingly. Nico --
[PATCH] Re: handling List-Id header
Attached is a patch which implement an auto-subscribe feature. When you load a mailbox, Mutt will parse the List-Post header field and add it to the 'subscribe' list automatically, unless it matches something on the 'unlists' or 'unsubscribe' list. me diff -r 2cd62f40d840 hcache.c --- a/hcache.c Sun Apr 11 20:00:38 2010 -0700 +++ b/hcache.c Mon Apr 12 14:16:21 2010 -0700 @@ -481,6 +481,9 @@ restore_list(e-references, d, off, 0); restore_list(e-in_reply_to, d, off, 0); restore_list(e-userhdrs, d, off, convert); + + if (e-list_post) +mutt_auto_subscribe(e-list_post); } static int diff -r 2cd62f40d840 init.c --- a/init.cSun Apr 11 20:00:38 2010 -0700 +++ b/init.cMon Apr 12 14:16:21 2010 -0700 @@ -413,16 +413,10 @@ if (!s || !*s) return 0; - if (!(rx = mutt_compile_regexp (s, flags))) - { -snprintf (err-data, err-dsize, Bad regexp: %s\n, s); -return -1; - } - /* check to make sure the item is not already on this list */ for (last = *list; last; last = last-next) { -if (ascii_strcasecmp (rx-pattern, last-rx-pattern) == 0) +if (ascii_strcasecmp (s, last-rx-pattern) == 0) { /* already on the list, so just ignore it */ last = NULL; @@ -434,6 +428,13 @@ if (!*list || last) { +/* delay compilation until after dupe check to improve performance. */ +if (!(rx = mutt_compile_regexp (s, flags))) +{ + snprintf (err-data, err-dsize, Bad regexp: %s\n, s); + return -1; +} + t = mutt_new_rx_list(); t-rx = rx; if (last) @@ -444,8 +445,6 @@ else *list = last = t; } - else /* duplicate */ -mutt_free_regexp (rx); return 0; } diff -r 2cd62f40d840 parse.c --- a/parse.c Sun Apr 11 20:00:38 2010 -0700 +++ b/parse.c Mon Apr 12 14:16:21 2010 -0700 @@ -966,6 +966,40 @@ cur-attach_valid = 0; } +/* The presence of the List-Post header field indicates the user is + * subscribed to this list. Unless the list is explicitly on the + * unlists or unsubscribe list or it matches the current subscribe + * list, automatically add it to the subscribed lists. + * + * The Subscribed list is checked first since users will often + * filter mail from a list into a separate folder, so we want to + * short-circuit the other checks as quickly as possible. + */ +void mutt_auto_subscribe(const char *mailto) +{ + ENVELOPE *lpenv = mutt_new_envelope(); /* parsed envelope from the List-Post mailto: URL */ + + if ((url_parse_mailto(lpenv, NULL, mailto) != -1) + lpenv-to lpenv-to-mailbox + !mutt_match_rx_list(lpenv-to-mailbox, SubscribedLists) + !mutt_match_rx_list(lpenv-to-mailbox, UnMailLists) + !mutt_match_rx_list(lpenv-to-mailbox, UnSubscribedLists)) + { +BUFFER err; +char errbuf[STRING]; + +memset(err, 0, sizeof(err)); +err.data = errbuf; +err.dsize = sizeof(errbuf); + +/* mutt_add_to_rx_list() detects duplicates, so it is safe to + * try to add here without any checks. */ +mutt_add_to_rx_list(MailLists, lpenv-to-mailbox, REG_ICASE, err); +mutt_add_to_rx_list(SubscribedLists, lpenv-to-mailbox, REG_ICASE, err); + } + mutt_free_envelope(lpenv); +} + int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed, short do_2047, LIST **lastp) { @@ -1110,6 +1144,7 @@ { FREE (e-list_post); e-list_post = mutt_substrdup (beg, end); + mutt_auto_subscribe(e-list_post); break; } } diff -r 2cd62f40d840 protos.h --- a/protos.h Sun Apr 11 20:00:38 2010 -0700 +++ b/protos.h Mon Apr 12 14:16:21 2010 -0700 @@ -162,6 +162,7 @@ void mutt_alias_menu (char *, size_t, ALIAS *); void mutt_allow_interrupt (int); void mutt_attach_init (BODY *); +void mutt_auto_subscribe (const char *); void mutt_block_signals (void); void mutt_block_signals_system (void); int mutt_body_handler (BODY *, STATE *); diff -r 2cd62f40d840 url.c --- a/url.c Sun Apr 11 20:00:38 2010 -0700 +++ b/url.c Mon Apr 12 14:16:21 2010 -0700 @@ -303,6 +303,7 @@ goto out; } } + rc = 0; out: FREE (tmp); pgptSzuVFrVGF.pgp Description: PGP signature
Re: handling List-Id header
On Fri, Apr 09, 2010 at 11:51:49PM -0500, Brian Ryans wrote: Quoting ilf on 2010-04-09 18:38:19: Why was it decided to set the flag only for subscribed lists and not listed lists? In my limited mutt experience (as a user) I believe it was decided that way as people would probably be more interested in subscribed than known lists. I don't recall the exact reason, but this sounds plausible. Also, I still don't have a reason for the difference of 'lists' and 'subscribe', other than that it's documented this way, too :) Other than material presented in the docs and what I've already said, I'm clueless on it. :( [1] The reason for the distinction between lists/subscribe is that just because you received an email that was addressed to a list doesn't mean that you are subscribed to said list. For the most part you can just ignore the lists command and use subscribe. me
Re: handling List-Id header
On Sat, Apr 10, 2010 at 01:38:19AM +0200, ilf wrote: I would like a workaround to use Regex in 'lists' and 'subscribe', but that feels dirty. Why doesn't Mutt allow 'lists'/'subscribe' to lists based on the List-Id: header? The List-ID header is not necessarily a valid email address. All that the RFC requires is that it be a unique value for each list. As such, it's not terribly useful for figuring out where to reply. This is why Mutt consults the List-Post header field instead when doing a list-reply. The problem with not using the subscribe command in Mutt is the very common case where your address appears on the To or CC line in addition to the mailing list address. In this sitation you will receive two copies of the email: one directly from the message sender, and another from the mailing list software. The former will *not* have any List-* headers in them, but the latter will. However, they will both have the same Message-ID field! Many Mutt users supress duplicate messages through the use of procmail/formail, so you are most likely to only see the message that came directly from the message sender (sans List-* header fields) in your mailbox. So if Mutt were to auto-detect the List-Post header field, it would only be a partial solution--you'd still have to use the subscribe command to ensure that Mutt detected all mailing lists. me
Re: handling List-Id header
Quoting ilf on 2010-04-09 18:38:19: I don't know where you got 3.1.1, my manual doesn't have that section :) That was my mistake. 2.3.1.1 (3.1.1 within Chapter 2). Why was it decided to set the flag only for subscribed lists and not listed lists? I'm unsure of the actual reason for that. One would probably have to grep hg and find and read the relevant commit log? I've searched the source, couldn't find anything pointing to reasoning. [1] In my limited mutt experience (as a user) I believe it was decided that way as people would probably be more interested in subscribed than known lists. Also, I still don't have a reason for the difference of 'lists' and 'subscribe', other than that it's documented this way, too :) Other than material presented in the docs and what I've already said, I'm clueless on it. :( [1] Which thread is that? I've searched the archives, but haven't been able to find it. I don't have network access as I write this, so I can't grep the online archives for the post, but my archive has, as one message in that thread, this message: ,Message-ID: 20100406140146.ga9...@sigpipe.org How would an MDA help in achieving this? It doesn't 'lists' or 'subscribe' mails in my muttrc :) I wasn't necessarily aiming to 'lists' or 'subscribe' anything, but rather to present a more general solution to handling mailing lists. If you decide to go this route, check a good procmail FAQ and read procmailrc(5) and procmailex(5). MDAs like procmail will, though, help you filter mail into different folders. I'm a procmail newbie myself, and such is offtopic for this list, so I won't go into that farther here. [1] Input from someone more clueful would be appreciated, as this is beyond my understanding at this point. -- _ Brian Ryans 8B2A 54C4 E275 8CFD 8A7D 5D0B 0AD0 B014 C112 13D0 . ( ) ICQ UIN: 43190205 | Mail/MSN/Jabber: brianlry...@gmail.com ..: X ASCII Ribbon Campaign Against HTML mail and v-cards: asciiribbon.org / \ Any technology distinguishable from magic is insufficiently advanced signature.asc Description: Digital signature
Re: handling List-Id header
Quoting ilf on 2010-04-08 16:09:46: I'm confused by Mutts handling of mailing lists. First, I do not understand the difference of known lists (lists) and subscribed lists (subscribe). If Mutt handles mail from a known list, I'm probably subscribed, no? Mutt's meaning of known and subscribed lists is covered in Chapter 3.11 of the manual. It's available in text [1] and html [2] formats on your local system. Secondly, I find having to manually maintain a list of subscriptions in my config unreasonable. Why doesn't Mutt automatically lists/subscribe to lists based on the List-Id header? That's what it's for: Chapter 4.8 of the manual states: --- The first thing you must do is to let Mutt know what addresses you consider to be mailing lists (technically this does not have to be a mailing list, but that is what it is most often used for) --- I believe Mutt uses List-Id: (me, ACK?), but at the time I type this message I don't have access to the sources to confirm. From a recent message on this list, to blr [3], I found that Mutt supports List-Post: natively. Quoting Michael Elkins on 2010-04-06 12:01:46 in Message-ID: 20100406140146.ga9...@sigpipe.org: If you merely want list-reply to work properly, you might not even need to add a lists/subscribe line at all because I believe the Debian mailing lists all add a List-Post: header field, which Mutt should pick up. List-Post: is specified in RFC 2369, Section 3.4 [4]. From grepping my maildir, almost all of my lists support List-Id: and List-Post:. Of course, YMMV depending on what kind of lists you read. [Snip: Rest of your message] See above: concerns you raise, indirectly, in the remainder of this post seem to be addressed above to the best of my ability. Please let me know if that's not the case. [1] file:///usr/share/doc/mutt/html/index.html [2] file:///usr/share/doc/mutt/index.txt.gz [3] I refer to myself as 'blr' and not 'me' in this to eliminate ambiguity. [4] http://www.ietf.org/rfc/rfc2919.txt -- _ Brian Ryans 8B2A 54C4 E275 8CFD 8A7D 5D0B 0AD0 B014 C112 13D0 . ( ) ICQ UIN: 43190205 | Mail/MSN/Jabber: brianlry...@gmail.com ..: X ASCII Ribbon Campaign Against HTML mail and v-cards: asciiribbon.org / \ Any technology distinguishable from magic is insufficiently advanced signature.asc Description: Digital signature
Re: handling List-Id header
On 04-09 01:21, Brian Ryans wrote: See above: concerns you raise, indirectly, in the remainder of this post seem to be addressed above to the best of my ability. Please let me know if that's not the case. Thanks for your hints. But I am still confused :) Manual section 4.8 Handling Mailing Lists sais, Mutt can do things with mailing lists once Mutt knows what [my] mailing lists are. It can: 1. show mailing list in index with - listname with $index_format including %L - message status flag 'L' with $index_format including %Z 2. use list-reply 3. use $followup_to Section 3.9 Mailing lists sais that use $followup_to is only for subscribed lists. I have not tried this. Using list-reply apparently works based on listsed lists and with the List-Post: header. Cool with me. But the first feature, showing mailing lists in index only works with subscribed lists. It does not work with listsed lists. Why? Also, it seems intuitive to me, that Mutt should show mailing lists in index not only with listsed lists, but also automatically based on the List-Id: header. And that's what I assume this Ticket is also about: http://dev.mutt.org/trac/ticket/3160 What do you think? -- ilf i...@jabber.berlin.ccc.de Über 80 Millionen Deutsche benutzen keine Konsole. Klick dich nicht weg! -- Eine Initiative des Bundesamtes für Tastaturbenutzung signature.asc Description: Digital signature
Re: handling List-Id header
Quoting ilf on 2010-04-09 12:18:08: Thanks for your hints. But I am still confused :) Now I'm confused too, see below. Manual section 4.8 Handling Mailing Lists sais, Mutt can do things with mailing lists once Mutt knows what [my] mailing lists are. It can: 1. show mailing list in index with - listname with $index_format including %L - message status flag 'L' with $index_format including %Z 2. use list-reply 3. use $followup_to Section 3.9 Mailing lists sais that use $followup_to is only for subscribed lists. I have not tried this. Confirmed. But the first feature, showing mailing lists in index only works with subscribed lists. It does not work with listsed lists. Why? That's intentional. Section 3.1.1, Status Flags, indicates that the L flag indicates a message sent to a _subscribed_ list. Also, it seems intuitive to me, that Mutt should show mailing lists in index not only with listsed lists, but also automatically based on the List-Id: header. And that's what I assume this Ticket is also about: http://dev.mutt.org/trac/ticket/3160 What do you think? This ticket seems to partially address your concerns. From how I read it, it by itself doesn't show what list it's sent to (as you stated above you need %L in $index_format for that), but it does request something that I've been looking for: ability to use regexes with List-* headers, or perhaps even arbitrary headers, in 'lists' and 'subscribe' commands. In the thread referenced in my last reply, a kludge was found, but only worked on Debian lists and involved running a shell command. I have no idea how hard it is to add a feature like that, but some would propose that a feature like that is better to be in a MDA like procmail. I'd offer to implement it myself, but it's still Beyond My Ken at this point. This, actually, is how I learn about stuff: answering questions for others, or at least trying to, will eventually get me in a position where I really grok the source and documentation. -- _ Brian Ryans 8B2A 54C4 E275 8CFD 8A7D 5D0B 0AD0 B014 C112 13D0 . ( ) ICQ UIN: 43190205 | Mail/MSN/Jabber: brianlry...@gmail.com ..: X ASCII Ribbon Campaign Against HTML mail and v-cards: asciiribbon.org / \ Any technology distinguishable from magic is insufficiently advanced signature.asc Description: Digital signature
handling List-Id header
I'm confused by Mutts handling of mailing lists. First, I do not understand the difference of known lists (lists) and subscribed lists (subscribe). If Mutt handles mail from a known list, I'm probably subscribed, no? Secondly, I find having to manually maintain a list of subscriptions in my config unreasonable. Why doesn't Mutt automatically lists/subscribe to lists based on the List-Id header? That's what it's for: By including the List-Id field, list servers can make it easier for mail clients to provide automated tools for users to perform list functions. The list identifier can serve as a key to make many automated processing tasks easier, and hence more widely available. http://www.ietf.org/rfc/rfc2919.txt This has been mentioned here before by Kyle Wheeler on 20 Jun 2007: Now, it's probably fair criticism if you want to say that mutt should also check List-Post and/or List-ID headers (if they exist), but for good or ill, it does not currently (file a bug report). http://www.mail-archive.com/mutt-users@mutt.org/msg32989.html The only related Bug on Trac is Ticket #3160, renamed support for more mailing list headers to detect list mail by pdmef on 2009-01-27. Has there been any discussion on this? What do you think? Thanks, and keep up the good work! -- ilf i...@jabber.berlin.ccc.de Über 80 Millionen Deutsche benutzen keine Konsole. Klick dich nicht weg! -- Eine Initiative des Bundesamtes für Tastaturbenutzung signature.asc Description: Digital signature