diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-10-16 08:26:05 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-10-16 08:26:05 +0000 |
commit | afee807bc84e4d2ebb2ea2014be8bb3167ce0bf7 (patch) | |
tree | 7464e455754b07dc2769011b867b2efbe5debbd7 | |
parent | e9907698bd680d2cbabc2f0845197debd28f4f46 (diff) |
Scoring improvements.
-rw-r--r-- | globals.h | 3 | ||||
-rw-r--r-- | init.h | 30 | ||||
-rw-r--r-- | mutt.h | 1 | ||||
-rw-r--r-- | mx.c | 29 | ||||
-rw-r--r-- | protos.h | 2 | ||||
-rw-r--r-- | score.c | 21 | ||||
-rw-r--r-- | sort.c | 7 |
7 files changed, 69 insertions, 24 deletions
@@ -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); @@ -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 @@ -320,6 +320,7 @@ enum OPTSAVEADDRESS, OPTSAVEEMPTY, OPTSAVENAME, + OPTSCORE, OPTSIGDASHES, OPTSORTRE, OPTSTATUSONTOP, @@ -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++; + } } @@ -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 *); @@ -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) @@ -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) { |