]> granicus.if.org Git - neomutt/commitdiff
Scoring improvements.
authorThomas Roessler <roessler@does-not-exist.org>
Sat, 16 Oct 1999 08:26:05 +0000 (08:26 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sat, 16 Oct 1999 08:26:05 +0000 (08:26 +0000)
globals.h
init.h
mutt.h
mx.c
protos.h
score.c
sort.c

index 7571533b28e4950fd34777ffafc8b90c45f07a3e..31e7ff61e95e48ce50f1eb27400a9eeaa7263501 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -129,6 +129,9 @@ WHERE short ReadInc;
 WHERE short SendmailWait;
 WHERE short Timeout;
 WHERE short WriteInc;
+WHERE short ScoreThresholdDelete;
+WHERE short ScoreThresholdRead;
+WHERE short ScoreThresholdFlag;
 
 /* flags for received signals */
 WHERE volatile sig_atomic_t SigAlrm INITVAL (0);
diff --git a/init.h b/init.h
index 7cca59242d404b2b091600bcbfc5f3f52b5bf689..4f47e2251bdffa444756f55d5169f16c68b2e0b5 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1550,6 +1550,36 @@ struct option_t MuttVars[] = {
   ** .pp
   ** Also see the ``$$force_name'' variable.
   */
+  { "score",           DT_BOOL, R_NONE, OPTSCORE, 1 },
+  /*
+  ** .pp
+  ** When this variable is \fIunset\fP, scoring is turned off.  This can
+  ** be useful to selectively disable scoring for certain folders when the
+  ** $score_threshold_delete variable and friends are used.
+  **
+  */
+  { "score_threshold_delete", DT_NUM, R_NONE, UL &ScoreThresholdDelete, -1 },
+  /*
+  ** .pp
+  ** Messages which have been assigned a score equal to or lower than the value
+  ** of this variable are automatically marked for deletion by mutt.  Since
+  ** mutt scores are always greater than or equal to zero, the default setting
+  ** of this variable will never mark a message for deletion.
+  */
+  { "score_threshold_flag", DT_NUM, R_NONE, UL &ScoreThresholdFlag, 9999 },
+  /* 
+  ** .pp
+  ** Messages wich have been assigned a score greater than or equal to this 
+  ** variable's value are automatically marked "flagged".
+  */
+  { "score_threshold_read", DT_NUM, R_NONE, UL &ScoreThresholdRead, -1 },
+  /*
+  ** .pp
+  ** Messages which have been assigned a score equal to or lower than the value
+  ** of this variable are automatically marked as read by mutt.  Since
+  ** mutt scores are always greater than or equal to zero, the default setting
+  ** of this variable will never mark a message for deletion.
+  */
   { "send_charset",    DT_STR,  R_NONE, UL &SendCharset, UL "" },
   /*
   ** .pp
diff --git a/mutt.h b/mutt.h
index 87f0403feb76673535c4d33b33711aadf6d08eff..46e7803d1f80a0e1046c498bb26b06d3dcbe14c4 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -320,6 +320,7 @@ enum
   OPTSAVEADDRESS,
   OPTSAVEEMPTY,
   OPTSAVENAME,
+  OPTSCORE,
   OPTSIGDASHES,
   OPTSORTRE,
   OPTSTATUSONTOP,
diff --git a/mx.c b/mx.c
index f3ff480ae43780be9db122221130c74a1773da55..763bf8aa61f05f126179fd622c8cf74aa97eb004 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1398,16 +1398,6 @@ void mx_update_context (CONTEXT *ctx)
   h->pgp = pgp_query (h->content);
 #endif /* _PGPPATH */
 
-  if (h->flagged)
-    ctx->flagged++;
-  if (h->deleted)
-    ctx->deleted++;
-  if (!h->read)
-  {
-    ctx->unread++;
-    if (!h->old)
-      ctx->new++;
-  }
   if (!ctx->pattern)
   {
     ctx->v2r[ctx->vcount] = ctx->msgcount;
@@ -1426,7 +1416,8 @@ void mx_update_context (CONTEXT *ctx)
     if (h2)
     {
       h2->superseded = 1;
-      mutt_score_message (h2);
+      if (option (OPTSCORE)) 
+       mutt_score_message (ctx, h2, 1);
     }
   }
 
@@ -1436,5 +1427,19 @@ void mx_update_context (CONTEXT *ctx)
   if (h->env->real_subj)
     hash_insert (ctx->subj_hash, h->env->real_subj, h, 1);
 
-  mutt_score_message (h);
+  if (option (OPTSCORE)) 
+    mutt_score_message (ctx, h, 0);
+  
+  if (h->changed)
+    ctx->changed = 1;
+  if (h->flagged)
+    ctx->flagged++;
+  if (h->deleted)
+    ctx->deleted++;
+  if (!h->read)
+  {
+    ctx->unread++;
+    if (!h->old)
+      ctx->new++;
+  }
 }
index e7079d2bf957404cb9509d2af38fbc2531b6650a..e865bc8c4f21037fb63738d8c66cdc615d69a9de 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -170,7 +170,7 @@ void mutt_query_exit (void);
 void mutt_query_menu (char *, size_t);
 void mutt_safe_path (char *s, size_t l, ADDRESS *a);
 void mutt_save_path (char *s, size_t l, ADDRESS *a);
-void mutt_score_message (HEADER *);
+void mutt_score_message (CONTEXT *, HEADER *, int);
 void mutt_select_fcc (char *, size_t, HEADER *);
 #define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,0,NULL,NULL)
 void _mutt_select_file (char *, size_t, int, int, char ***, int *);
diff --git a/score.c b/score.c
index e40890903b7237a4ca84f7e34133ed9bad289341..5d794e68ae5f79493f4f9f8f46948cb84da6eb9e 100644 (file)
--- a/score.c
+++ b/score.c
@@ -36,7 +36,7 @@ void mutt_check_rescore (CONTEXT *ctx)
 {
   int i;
 
-  if (option (OPTNEEDRESCORE))
+  if (option (OPTNEEDRESCORE) && option (OPTSCORE))
   {
     if ((Sort & SORT_MASK) == SORT_SCORE ||
        (SortAux & SORT_MASK) == SORT_SCORE)
@@ -50,15 +50,13 @@ void mutt_check_rescore (CONTEXT *ctx)
     set_option (OPTFORCEREDRAWINDEX);
     set_option (OPTFORCEREDRAWPAGER);
 
-    for (i = 0; i < ctx->msgcount; i++)
-      mutt_score_message (ctx->hdrs[i]);
-
-    /* force re-caching of index colors */
     for (i = 0; ctx && i < ctx->msgcount; i++)
+    {
+      mutt_score_message (ctx, ctx->hdrs[i], 1);
       ctx->hdrs[i]->pair = 0;
-
-    unset_option (OPTNEEDRESCORE);
+    }
   }
+  unset_option (OPTNEEDRESCORE);
 }
 
 int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
@@ -114,7 +112,7 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   return 0;
 }
 
-void mutt_score_message (HEADER *hdr)
+void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx)
 {
   SCORE *tmp;
 
@@ -133,6 +131,13 @@ void mutt_score_message (HEADER *hdr)
   }
   if (hdr->score < 0)
     hdr->score = 0;
+  
+  if (hdr->score <= ScoreThresholdDelete)
+    _mutt_set_flag (ctx, hdr, M_DELETE, 1, upd_ctx);
+  if (hdr->score <= ScoreThresholdRead)
+    _mutt_set_flag (ctx, hdr, M_READ, 1, upd_ctx);
+  if (hdr->score >= ScoreThresholdFlag)
+    _mutt_set_flag (ctx, hdr, M_FLAG, 1, upd_ctx);
 }
 
 int mutt_parse_unscore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
diff --git a/sort.c b/sort.c
index 17de52916e00de1070ed02cd5fb0b61b44343453..952fe89fb934e15af4fc462d65896f6a1f37d0a2 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -201,12 +201,13 @@ void mutt_sort_headers (CONTEXT *ctx, int init)
   if (init)
     mutt_clear_threads (ctx);
 
-  if (option (OPTNEEDRESCORE))
+  if (option (OPTNEEDRESCORE) && option (OPTSCORE))
   {
     for (i = 0; i < ctx->msgcount; i++)
-      mutt_score_message (ctx->hdrs[i]);
-    unset_option (OPTNEEDRESCORE);
+      mutt_score_message (ctx, ctx->hdrs[i], 1);
   }
+  unset_option (OPTNEEDRESCORE);
+
 
   if ((Sort & SORT_MASK) == SORT_THREADS)
   {