summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-10-16 08:26:05 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-10-16 08:26:05 +0000
commitafee807bc84e4d2ebb2ea2014be8bb3167ce0bf7 (patch)
tree7464e455754b07dc2769011b867b2efbe5debbd7
parente9907698bd680d2cbabc2f0845197debd28f4f46 (diff)
Scoring improvements.
-rw-r--r--globals.h3
-rw-r--r--init.h30
-rw-r--r--mutt.h1
-rw-r--r--mx.c29
-rw-r--r--protos.h2
-rw-r--r--score.c21
-rw-r--r--sort.c7
7 files changed, 69 insertions, 24 deletions
diff --git a/globals.h b/globals.h
index 7571533b..31e7ff61 100644
--- 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 7cca5924..4f47e225 100644
--- 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 87f0403f..46e7803d 100644
--- 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 f3ff480a..763bf8aa 100644
--- 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++;
+ }
}
diff --git a/protos.h b/protos.h
index e7079d2b..e865bc8c 100644
--- 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 e4089090..5d794e68 100644
--- 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 17de5291..952fe89f 100644
--- 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)
{