[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by a
From: |
Alex Bochannek |
Subject: |
bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age |
Date: |
Thu, 10 Sep 2020 17:58:30 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Alex Bochannek <alex@bochannek.com> writes:
>
>> Looks like I inverted the logic for '<'. New patch attached.
>
> Thanks; applied.
Thanks, Lars! Below is another small patch to also support article age
in interactive scoring. I wasn't sure about the error handling, so feel
free to change that if there is a preferred style.
--
Alex.
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 6a0e8ceb99..fce7b68db1 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -862,6 +862,18 @@ gnus-summary-score-entry
(setq match (string-to-number match)))
(set-text-properties 0 (length match) nil match))
+ ;; Modify match and type for article age scoring.
+ (if (string= "date" (nth 0 (assoc header gnus-header-index)))
+ (let ((age (string-to-number match)))
+ (if (or (< age 0)
+ (string= "0" match))
+ (user-error "Article age must be a positive number"))
+ (setq match age
+ type (cond ((eq type 'after)
+ '<)
+ ((eq type 'before)
+ '>)))))
+
(unless (eq date 'now)
;; Add the score entry to the score file.
(when (= score gnus-score-interactive-default-score)