bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Alex Bochannek-2
Lars Ingebrigtsen <[hidden email]> writes:

> The .info files are generated files -- the documentation goes into
> doc/misc/gnus.texi (and I expanded upon the feature somewhat based on
> your email).

Thanks for the reminder, forgot about that.

Looks like I inverted the logic for '<'. New patch attached.

> The patch is just small enough to go through without a copyright
> assignment (and I forgot to mark the commit as such; sigh), but for any
> future patches you might send, we'd need to have the copyright assigned
> to the FSF.  Would you be willing to do that?  If so, we could start the
> ball rolling now on the paperwork, so that any subsequent patches can be
> applied faster.

I believe my employer is already on file, so if there are any more
substantial contributions, I can use that.

Thanks!

--
Alex.

diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index c5156a195a..12f733ac13 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -1695,9 +1695,9 @@ gnus-score-date
   match (gnus-date-iso8601 (nth 0 kill))))
    ((eq type '<)
     (setq type 'after
-  match-func 'gnus-string>
+  match-func 'string<
   match (gnus-time-iso8601
- (time-add (current-time) (* 86400 (nth 0 kill))))))
+ (time-subtract (current-time) (* 86400 (nth 0 kill))))))
    ((eq type 'before)
     (setq match-func 'gnus-string>
   match (gnus-date-iso8601 (nth 0 kill))))
@@ -1705,7 +1705,7 @@ gnus-score-date
     (setq type 'before
   match-func 'gnus-string>
   match (gnus-time-iso8601
- (time-add (current-time) (* -86400 (nth 0 kill))))))
+ (time-subtract (current-time) (* 86400 (nth 0 kill))))))
    ((eq type 'at)
     (setq match-func 'string=
   match (gnus-date-iso8601 (nth 0 kill))))
Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Lars Ingebrigtsen
Alex Bochannek <[hidden email]> writes:

> Looks like I inverted the logic for '<'. New patch attached.

Thanks; applied.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Alex Bochannek-2
Lars Ingebrigtsen <[hidden email]> writes:

> Alex Bochannek <[hidden email]> 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)
Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Lars Ingebrigtsen
Alex Bochannek <[hidden email]> writes:

> 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.

Looks good -- you said your employer was on file (for the copyright
assignment), but you didn't say who your employer was.  :-)

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Alex Bochannek-2
Lars Ingebrigtsen <[hidden email]> writes:

> Alex Bochannek <[hidden email]> writes:
>
>> 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.
>
> Looks good -- you said your employer was on file (for the copyright
> assignment), but you didn't say who your employer was.  :-)

Yes, I heard back from the folks in Legal and they confirmed a CLA is in
place. I am at Google <[hidden email]>

Thanks!

--
Alex.



Reply | Threaded
Open this post in threaded view
|

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Lars Ingebrigtsen
Alex Bochannek <[hidden email]> writes:

> Lars Ingebrigtsen <[hidden email]> writes:
>
>> Alex Bochannek <[hidden email]> writes:
>>
>>> 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.
>>
>> Looks good -- you said your employer was on file (for the copyright
>> assignment), but you didn't say who your employer was.  :-)
>
> Yes, I heard back from the folks in Legal and they confirmed a CLA is in
> place. I am at Google <[hidden email]>

Thanks for checking; I've now applied your patch to the trunk.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no