bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30356: [PATCH] Add below option to gnus-summary-limit-to-score


From: Oleg Pykhalov
Subject: bug#30356: [PATCH] Add below option to gnus-summary-limit-to-score
Date: Mon, 5 Feb 2018 16:31:43 +0300

* lisp/gnus/gnus-sum.el (gnus-summary-limit-to-score): Add below
  option.
---
 doc/misc/gnus.texi    |  3 ++-
 etc/NEWS              |  5 +++++
 lisp/gnus/gnus-sum.el | 22 +++++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 8c2fc56dd6..27baf6b11c 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -6663,7 +6663,8 @@ Limiting
 @kindex / v (Summary)
 @findex gnus-summary-limit-to-score
 Limit the summary buffer to articles that have a score at or above some
-score (@code{gnus-summary-limit-to-score}).
+score (@code{gnus-summary-limit-to-score}).  If given a prefix, below
+some score.
 
 @item / p
 @kindex / p (Summary)
diff --git a/etc/NEWS b/etc/NEWS
index 8fed15af5b..33b5073ad3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -106,6 +106,11 @@ non-text modes.
 
 * Changes in Specialized Modes and Packages in Emacs 27.1
 
+** Gnus
+
+*** A prefix argument to 'gnus-summary-limit-to-score' will limit reverse
+Limit to articles with score at below.
+
 ** Ecomplete
 *** The ecomplete sorting has changed to a decay-based algorithm.
 This can be controlled by the new `ecomplete-sort-predicate' variable.
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index b6e9ea91b6..b9996e7d93 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -8559,14 +8559,22 @@ gnus-summary-limit-to-marks
        (gnus-summary-limit articles))
     (gnus-summary-position-point)))
 
-(defun gnus-summary-limit-to-score (score)
-  "Limit to articles with score at or above SCORE."
-  (interactive "NLimit to articles with score of at least: ")
-  (let ((data gnus-newsgroup-data)
-       articles)
+(defun gnus-summary-limit-to-score (score &optional below)
+  "Limit to articles with score at or above SCORE.
+
+With a prefix argument, limit to articles with score at or below
+SCORE."
+  (interactive (list (string-to-number
+                      (read-string
+                       (format "Limit to articles with score of at %s: "
+                               (if current-prefix-arg "most" "least"))))))
+  (let* ((data gnus-newsgroup-data)
+         (compare (if (or below current-prefix-arg) #'<= #'>=))
+         articles)
     (while data
-      (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
-               score)
+      (when (funcall compare (gnus-summary-article-score
+                              (gnus-data-number (car data)))
+                     score)
        (push (gnus-data-number (car data)) articles))
       (setq data (cdr data)))
     (prog1
-- 
2.15.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]