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

Re: %t as To or Newsgroup?



Hi,

does the lack of response mean that nobody is interested in that
extension or does it just mean nobody has time to look into it?  Note
that I'm not just asking for somebody else to do it, I'm implementing it
myself.  That's why a preliminary patch is attached inline.


Thanks,
Corinna


On Feb 25 10:04, Corinna Vinschen wrote:
> Ping?
> 
> On Feb 20 22:02, Corinna Vinschen wrote:
> > On Feb 20 20:33, Corinna Vinschen wrote:
> > > On Feb 20 10:55, David Champion wrote:
> > > > The most consistent and flexible approach to this, IMO, would be:
> > > > 
> > > >  * add an "if (optional)" clause in the "case 't'" switch of
> > > >    hdr_format_str() in hdrline.c, so that mutt can detect whether the
> > > >    to: field is empty or null, and
> > > > 
> > > >  * either:
> > > > 
> > > >    * add a new formatter (say, 'G') to the same function which renders
> > > >      the Newsgroup: header -- but realize that there is an NNTP patch
> > > >      extant which likely does this already if you're prepared to track
> > > >      complex and unsupported patches -- or
> > > > 
> > > >    * add a formatter to render arbitrary headers, for which many people
> > > >      would thank you
> > > > 
> > > > If you took option 1, you could then use
> > > > 
> > > >   %?t?%24.24t&%24.24G? to get the if-else behavior.
> > > 
> > > The second option looks more interesting.  I'll have a look if that's
> > > something I can contribute or if I rather go for the first option.
> > 
> > Given the fact that none of the additional header lines is stored so far
> > in struct HEADER or struct ENVELOPE, I created a preliminary patch along
> > the lines of the first option.  I expected the additional header lines
> > to appear in the ENVELOPE::userhdrs, but apparently this list is only
> > used in a restricted context.  So I added a newsgroups member to struct
> > ENVELOPE to store just the newsgroups information.
> > 
> > See the patch below.  It's missing comments and documentation so far.
> > Apart from adding the documentation I guess it would also be a good idea
> > to add newsgroup munging if the field width is smaller than the length
> > of the newsgroup name.  For instance, assuming the field width is 18
> > chars, then
> > 
> >    Ng de.alt.rec.digitalfotografie
> > 
> > becomes
> > 
> >    Ng de.alt.rec.digi
> > 
> > It should better tweaked into
> > 
> >   Ng d.a.r.digitalfot
> > 
> > However, before I put more time into this little project, I'd like to
> > know if that has any chance of inclusion into mutt at all.  If so, I'd
> > be quite happy to implement the missing stuff as above.
> > 
> > Another question is this:  Is it too time consuming or to wasteful in
> > terms of memory to always add all additional header lines to
> > ENVELOPE::userhdrs?  I'm asking since having all header files present
> > would simplify something as outlined above to allow to specify any
> > header in the format string.
> > 
> > Ok, see preliminary patch for new 'G' format specifier below.
> > 
> > 
> > Corinna
> > 
> > 
> > ChangeLog entry:
> > 
> >     * mutt.h, parse.c, hdrline.c: Read Newsgroups header and store in new 
> >     newsgroups memeber to struct ENVELOPE.  Add 'G' format specifer to
> >     print Newsgroup header.  Add optional handling to 't' format specifier.
> > 
> > 
> > diff -r e37e857afc14 hdrline.c
> > --- a/hdrline.c     Fri Feb 20 13:23:59 2009 +0100
> > +++ b/hdrline.c     Fri Feb 20 21:55:23 2009 +0100
> > @@ -443,6 +443,18 @@ hdr_format_str (char *dest,
> >          optional = 0;
> >        break;
> >  
> > +    case 'G':
> > +      {
> > +   if (hdr->env->newsgroups)
> > +   {
> > +     snprintf (buf2, sizeof (buf2), "Ng %s", hdr->env->newsgroups);
> > +     mutt_format_s (dest, destlen, prefix, buf2);
> > +   }
> > +   else
> > +     strfcpy(dest, "Ng ?", destlen);
> > +      }
> > +      break;
> > +
> >      case 'H':
> >        /* (Hormel) spam score */
> >        if (optional)
> > @@ -588,16 +600,21 @@ hdr_format_str (char *dest,
> >        break;
> >  
> >      case 't':
> > -      buf2[0] = 0;
> > -      if (!check_for_mailing_list (hdr->env->to, "To ", buf2, sizeof 
> > (buf2)) &&
> > -     !check_for_mailing_list (hdr->env->cc, "Cc ", buf2, sizeof (buf2)))
> > +      if (!optional)
> >        {
> > -   if (hdr->env->to)
> > -     snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name (hdr->env->to));
> > -   else if (hdr->env->cc)
> > -     snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name (hdr->env->cc));
> > +   buf2[0] = 0;
> > +   if (!check_for_mailing_list (hdr->env->to, "To ", buf2, sizeof (buf2)) 
> > &&
> > +       !check_for_mailing_list (hdr->env->cc, "Cc ", buf2, sizeof (buf2)))
> > +   {
> > +     if (hdr->env->to)
> > +       snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name 
> > (hdr->env->to));
> > +     else if (hdr->env->cc)
> > +       snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name 
> > (hdr->env->cc));
> > +   }
> > +   mutt_format_s (dest, destlen, prefix, buf2);
> >        }
> > -      mutt_format_s (dest, destlen, prefix, buf2);
> > +      else if (!hdr->env->to && !hdr->env->cc)
> > +           optional = 0;
> >        break;
> >  
> >      case 'T':
> > diff -r e37e857afc14 mutt.h
> > --- a/mutt.h        Fri Feb 20 13:23:59 2009 +0100
> > +++ b/mutt.h        Fri Feb 20 21:55:23 2009 +0100
> > @@ -577,6 +577,7 @@ typedef struct envelope
> >    char *supersedes;
> >    char *date;
> >    char *x_label;
> > +  char *newsgroups;
> >    BUFFER *spam;
> >    LIST *references;                /* message references (in reverse 
> > order) */
> >    LIST *in_reply_to;               /* in-reply-to header content */
> > diff -r e37e857afc14 parse.c
> > --- a/parse.c       Fri Feb 20 13:23:59 2009 +0100
> > +++ b/parse.c       Fri Feb 20 21:55:23 2009 +0100
> > @@ -1151,6 +1151,19 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
> >      }
> >      break;
> >      
> > +    case 'n':
> > +    if (!ascii_strcasecmp (line + 1, "ewsgroups"))
> > +    {
> > +      FREE (&e->newsgroups);
> > +      p = line + strlen (line) + 1;
> > +      SKIPWS (p);
> > +      e->newsgroups = safe_strdup (p);
> > +      if (do_2047)
> > +   rfc2047_decode (&e->newsgroups);
> > +      matched = 1;
> > +    }
> > +    break;
> > +
> >      case 'r':
> >      if (!ascii_strcasecmp (line + 1, "eferences"))
> >      {

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat