Subject: Re: Sorting ignores square brackets?

From: Joel Boonstra <[email-masked]>
Date: Thu, 2 Jan 2003 11:41:28 -0500 (EST)

> We're using RT (Request Tracker) and it uses [ticket #123] as part of the
> subject to track tickets.
>
> Using either subject or ordered subject _ignores_ the square bracketed
> words.
>
> This means that instead of sorting all of the [ticket #123] together and
> then sorting [ticket #124] next, it sorts only based on the remainder of
> the subject line, which can change.
>
> Mutt correctly works (sorting all of the tickets in numbered order).
> But we're a PINE shop from way back, and I don't want to tell everyone to
> have to switch to Mutt.
>
> Is there a way (without munging the brackets - which RT is looking for)
> to fix the sort?   I'd be glad to recompile PINE to do so.
> Googling didn't find anything like an answer.

In my experience with RT, pine threading will still thread properly,
even if the subject line differs.  Sorting by subject, as you well know,
doesn't work too well.

I should mention that I'm not using 4.51 threading; I'm using Eduardo's
threading patch.  However, I think the threading algorithm
behind-the-scenes is the same; it's just the display that differs.

Would convincing users to use threads work?  Eduardo's patch:

  http://www.math.washington.edu/~chappa/pine/info/fancy.html

Another helpful thing for RT/pine users might be Eduardo's "rules"
patch:

  http://www.math.washington.edu/~chappa/pine/info/rules.html

He added a _REXTRIM_ token that lets you use regular expressions to
munge the *display* of the subject, thus letting things like this:

  [ticket #123]

not show up in an index listing, but still be there so that RT is happy.
Depending on how you work, this may be helpful or harmful.  For me it
was a lifesaver...

Joel

-- 
[ joel boonstra | [email-masked] ]

---

From: "Seth Cohn, EFN General Manager" <[email-masked]>
Date: Thu, 2 Jan 2003 17:32:11 -0800 (PST)

> > subject to track tickets.

I neglected to mention we were using an older version of Pine (4.21) but I
just installed 4.51 and it's doing the same thing... mostly.

> > the subject line, which can change.

Ordered subject now (4.51) does _half_ the job.  It will respect the
[ticket #123] then [ticket #124] EXCEPT with subject line changes.
If the subject matches a previous subject used (ie Help!) it will fold
into the wrong ticket number.  If the subject changes, it won't sort that
subject into the rest of the ticket, but starts a new (later) thread.  Not
much better.

> even if the subject line differs.  Sorting by subject, as you well know,

Doesn't work.  RT isn't giving pine the thread info it needs at
all.  Threading is nearly flat.  Ordered subject was closer to correct.

> Depending on how you work, this may be helpful or harmful.  For me it

I really really like this.  I'm hoping (I'll be installing this) that I
can remove from index view the "[ticket #", which will allow sorting to
work, I hope. 

I still think pine needs a 'don't ignore brackets for sorting' option.
Developers?

-- 
## Seth Cohn, General Manager of Eugene Free Community Network [email-masked]
## Businesses planned for service are apt to succeed;  Phone 541-484-9637
## Businesses planned for profit are apt to fail. - N. Butler

---

From: "Seth Cohn, EFN General Manager" <[email-masked]>
Date: Thu, 2 Jan 2003 20:06:25 -0800 (PST)

> > > Using either subject or ordered subject _ignores_ the square bracketed

It turns out, after reading the pine source, and seeing that all of the
sorts passed back to c-client, that it's in fact the c-client code that is
the source of the problem.

mail_strip_subject (or more specifically: mail_strip_subject_aux) in
mail.c explicitly strips everything between brackets.  No option for not
stripping exists.

This is NOT _always_ wanted.  My example is far from the only time a true
'sort based on exactly what you see' is needed.  It would be very very
nice if a 'raw subject sort' existed.

> can remove from index view the "[ticket #", which will allow sorting to

Doesn't help.  While I can strip the _view_, the sorting still uses the
true subject line... so I can remove all I want, but can't sort correctly.

> I still think pine needs a 'don't ignore brackets for sorting' option.

Ok, so let's change this to:  Developers at UW?  Raw Subject Sort?  I
realize the IMAP specs say sorts should ignore [bracketed] stuff in
subjects, but a raw sort is still useful at times.  Mutt does this
correctly, Pine doesn't.

---

From: "Seth Cohn, EFN General Manager" <[email-masked]>
Date: Thu, 2 Jan 2003 21:14:50 -0800 (PST)

> mail.c explicitly strips everything between brackets.  No option for not

Never let it be said that a little hacking can't go a long way.

I modded the libc-client mail.c to ignore { and } instead, figuring that
was unlikely to cause trouble... and recompiled it, installed it, and then
recompiled pine too... and it still didn't sort right... then I realized I
was trying to sort an IMAP folder which doesn't use mail.c ... I copied my
tickets over to a local file (select all, save) and behold, it
works.  Local folder sorting is fine for what I need. Ordered subjects
don't work right still, but plain subject sort does...

Unlikely to break anything else, so I'm happy.  For now, it's does what I
want.

Seth

changes to mail.c (just replaced [ and ] with { and } )
case '{':                     /* leading [ */
    for (s = t + 1; s;) switch (*s) {
    case '\0': case '{':        /* end of string or nesting */
      x = s = NIL;              /* just punt */
      break;
    default:                    /* any other character */
      s++;                      /* sniff at next */
      break;