Move score_* to mod_score
[apps/madmutt.git] / score.cpkg
similarity index 72%
rename from score.c
rename to score.cpkg
index 7bf3811..40adf78 100644 (file)
--- a/score.c
 #include "mutt.h"
 #include "sort.h"
 #include "pattern.h"
 #include "mutt.h"
 #include "sort.h"
 #include "pattern.h"
+#include "score.h"
+@import  "lib-lua/base.cpkg"
+
+@package mod_score {
+    bool enable = 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.
+     **
+     */
+    int threshold_flag = 9999;
+    /*
+     ** .pp
+     ** Messages which have been assigned a score greater than or equal to this
+     ** variable's value are automatically marked ``flagged''.
+     */
+    int threshold_delete = -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 Madmutt.  Since
+     ** Madmutt scores are always greater than or equal to zero, the default setting
+     ** of this variable will never mark a message for deletion.
+     */
+    int threshold_read   = -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 Madmutt.  Since
+     ** Madmutt scores are always greater than or equal to zero, the default setting
+     ** of this variable will never mark a message read.
+     */
+};
 
 typedef struct score_t {
   char *str;
 
 typedef struct score_t {
   char *str;
@@ -36,7 +71,7 @@ void mutt_check_rescore (CONTEXT * ctx)
 {
   int i;
 
 {
   int i;
 
-  if (option (OPTNEEDRESCORE) && option (OPTSCORE)) {
+  if (option (OPTNEEDRESCORE) && mod_score.enable) {
     if ((Sort & SORT_MASK) == SORT_SCORE ||
         (SortAux & SORT_MASK) == SORT_SCORE) {
       set_option (OPTNEEDRESORT);
     if ((Sort & SORT_MASK) == SORT_SCORE ||
         (SortAux & SORT_MASK) == SORT_SCORE) {
       set_option (OPTNEEDRESORT);
@@ -117,11 +152,11 @@ void mutt_score_message (CONTEXT * ctx, HEADER * hdr, int upd_ctx)
   if (hdr->score < 0)
     hdr->score = 0;
 
   if (hdr->score < 0)
     hdr->score = 0;
 
-  if (hdr->score <= ScoreThresholdDelete)
+  if (hdr->score <= mod_score.threshold_delete)
     _mutt_set_flag (ctx, hdr, M_DELETE, 1, upd_ctx);
     _mutt_set_flag (ctx, hdr, M_DELETE, 1, upd_ctx);
-  if (hdr->score <= ScoreThresholdRead)
+  if (hdr->score <= mod_score.threshold_flag)
     _mutt_set_flag (ctx, hdr, M_READ, 1, upd_ctx);
     _mutt_set_flag (ctx, hdr, M_READ, 1, upd_ctx);
-  if (hdr->score >= ScoreThresholdFlag)
+  if (hdr->score >= mod_score.threshold_flag)
     _mutt_set_flag (ctx, hdr, M_FLAG, 1, upd_ctx);
 }
 
     _mutt_set_flag (ctx, hdr, M_FLAG, 1, upd_ctx);
 }
 
@@ -148,3 +183,5 @@ int mutt_parse_unscore(BUFFER * buf, BUFFER * s,
     set_option (OPTNEEDRESCORE);
     return 0;
 }
     set_option (OPTNEEDRESCORE);
     return 0;
 }
+
+/* vim:set ft=c: */