<<< Date Index >>>     <<< Thread Index >>>

Re: Mangling subject lines in index



On 2006-06-30 10:19 +0200, Andre Majorel wrote:
> On 2006-06-30 07:05 +0200, Michael Tatge wrote:
> > * On Thu, Jun 29, 2006 Andre Majorel (aym-ttum@xxxxxxxxx) muttered:
> > > is there a way in Mutt to transform the subject lines in the
> > > index ? Specifically, I'd like to hide certain overlong
> > > "[name-of-mailing-list]" tags.
> > 
> > There's a awfully hacky mutt way and ugly other way(s).
> > - The mutt solution will abuse $reply_regexp to cover the tags.

I couldn't get that one to work. Apparently, $reply_regexp is
only used for comparison purposes and has no effect on the
display.

> > - One other way would be to temper with the message itself, say
> >   delete the ml tags on delivery with procmail->formail.
> > 
> > Both of which are very inelegant i'm afraid. A proper solution could
> > be a patch that introduces a feature to weed out regexp based
> > subject parts in the index.
> 
> Or maybe hacking mutt_FormatString() to accept a new
> /regexp/string/flags/ conversion flag and changing the "%s" in
> $index_format to "%/^\[name-of-mailing-list] ///s".
> 
> That would be very general but cumbersome to set on a per-folder
> basis. And sensitive to whether $reply_regexp is honoured before
> or after.

Here's what I did. In PCRE terms, the result of the %s
conversion in $index_format is now s/.*\[.*?]\s*// (i.e.
everything to the closing "]" is ommitted, including any
trailing whitespace).

I'd still like a real solution, though. A regexp per folder
sounds good from a user POV.

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>
Do not use this account for regular correspondence.
See the URL above for contact information.
diff -ur mutt-1.5.11/hdrline.c mutt-1.5.11-nomltag/hdrline.c
--- mutt-1.5.11/hdrline.c       2005-02-12 19:53:35.000000000 +0100
+++ mutt-1.5.11-nomltag/hdrline.c       2006-06-30 13:17:20.000000000 +0200
@@ -542,20 +542,46 @@
       break;
 
     case 's':
-      
-      if (flags & M_FORMAT_TREE && !hdr->collapsed)
       {
-       if (flags & M_FORMAT_FORCESUBJ)
+       const char *s = hdr->env->subject;              /* AYM 2006-06-30 */
+       if (s != NULL)
        {
-         mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
-         snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
-         mutt_format_s_tree (dest, destlen, prefix, buf2);
+         while (*s != '\0' && *s != '[')
+           s++;
+         if (*s == '[')
+         {
+           const char *s0 = s;
+           s++;
+           while (*s != '\0' && *s != ']')
+           {
+             s++;
+           }
+           if (*s == ']')
+           {
+             s++;
+             while (isspace (*s))
+               s++;
+           }
+           else
+             s = s0;
+         }
+       }
+      
+       if (flags & M_FORMAT_TREE && !hdr->collapsed)
+       {
+         if (flags & M_FORMAT_FORCESUBJ)
+         {
+           mutt_format_s (dest, destlen, "", NONULL (s));
+           snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
+           mutt_format_s_tree (dest, destlen, prefix, buf2);
+         }
+         else
+           mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
        }
        else
-         mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
+         /* Normal path -- AYM 2006-06-30 */
+         mutt_format_s (dest, destlen, prefix, NONULL (s));
       }
-      else
-       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
       break;
 
     case 'S':