[EMAIL PROTECTED] writes:

> Is there something else I can do to sort messages based on the
> header field that my filter is generating?

Well, way back I wrote a small patch that adds support for a custom
scoring header to mutt.  I'm sure it was messy, and it definately
slowed folder opening (was noticable for very large folders), but you
can take a look at this (which appears to still apply to 1.3.24!).  Of
course, while it may still apply cleanly, you're on your own to test
it and make sure it works:

diff -urN mutt-1.1.9/init.h mutt-1.1.9-extscore/init.h
--- mutt-1.1.9/init.h   Wed Mar 29 21:56:12 2000
+++ mutt-1.1.9-extscore/init.h  Tue Jan 11 06:21:08 2005
@@ -1663,6 +1663,15 @@
   ** $score_threshold_delete variable and friends are used.
   **
   */
+  { "score_header", DT_STR, R_INDEX|R_RESORT_BOTH, UL &ScoreHeader, UL "" },
+  /*
+  ** .pp
+  ** When this variable is \fIset\fP, each message header will be examined
+  ** for a header in the form of ``score_header: <integer>''. The integer
+  ** value that is found is used as an initial score value for the message.
+  ** This allows the use of external scoring (with procmail, for example)
+  ** while still taking advantage of Mutt's score sorting features
+  */
   { "score_threshold_delete", DT_NUM, R_NONE, UL &ScoreThresholdDelete, -1 },
   /*
   ** .pp
diff -urN mutt-1.1.9/score.c mutt-1.1.9-extscore/score.c
--- mutt-1.1.9/score.c  Fri Mar  3 05:10:14 2000
+++ mutt-1.1.9-extscore/score.c Tue Jan 11 06:21:13 2005
@@ -20,6 +20,7 @@
 #include "sort.h"
 #include <string.h>
 #include <stdlib.h>
+#include <mailbox.h>
 
 typedef struct score_t
 {
@@ -115,8 +116,46 @@
 void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx)
 {
   SCORE *tmp;
+  MESSAGE *msg;
+  FILE *fp = NULL;
+  HEADER *h = ctx->hdrs[hdr->msgno];
+  long lng = 0;
+  char *search = NULL;
+  char buf[STRING];
 
   hdr->score = 0; /* in case of re-scoring */
+
+  /* 
+   * If the score_header variable is set, then use
+   * that as an initial score value 
+   */
+  if(ScoreHeader && *ScoreHeader) {
+    if((msg = mx_open_message(ctx, hdr->msgno)) != NULL)
+    {
+      fp = msg->fp;
+      fseek(fp, h->offset, 0);
+      lng = h->content->offset - h->offset;
+
+      /* now, search the headers... */
+      while(lng > 0) {
+        if(fgets(buf, sizeof(buf) - 1, fp) == NULL)
+          break;
+       
+        search = strstr(buf, ScoreHeader);
+
+        if(search) {
+          search = strstr(buf, ":");
+          hdr->score = atoi(search + 1);
+          break;
+        }
+
+        lng -= mutt_strlen(buf);
+      }
+
+      mx_close_message(&msg);
+    }
+  }
+
   for (tmp = Score; tmp; tmp = tmp->next)
   {
     if (mutt_pattern_exec (tmp->pat, 0, NULL, hdr) > 0)


-- 
Josh Huber                                     | [EMAIL PROTECTED] |

Reply via email to