emacs-diffs
[Top][All Lists]
Advanced

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

feature/gnus-select2 66ad25a 2/2: Store nnselect-artlist in a compressed


From: Andrew G Cohen
Subject: feature/gnus-select2 66ad25a 2/2: Store nnselect-artlist in a compressed format
Date: Thu, 24 Oct 2019 22:42:03 -0400 (EDT)

branch: feature/gnus-select2
commit 66ad25af252783cd68066fd62cf42bf82bfeadc5
Author: Andrew G Cohen <address@hidden>
Commit: Andrew G Cohen <address@hidden>

    Store nnselect-artlist in a compressed format
    
    * lisp/gnus/nnselect.el (nnselect-compress-artlist,
      nnselect-uncompress-artlist): New functions.
    
      (nnselect-get-artlist): Uncompress artlist upon retrieval. Since
      earlier data my be stored in uncompressed form, allow that too for
      now.
    
      (nnselect-request-group, nnselect-request-thread,
      nnselect-create-group): Compress artlist when storing.
---
 lisp/gnus/nnselect.el | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/lisp/gnus/nnselect.el b/lisp/gnus/nnselect.el
index d6a299e..27389ae 100644
--- a/lisp/gnus/nnselect.el
+++ b/lisp/gnus/nnselect.el
@@ -78,6 +78,25 @@
   "nnselect groups description file.")
 
 ;;; Helper routines.
+(defun nnselect-compress-artlist (artlist)
+  (let (selection)
+    (pcase-dolist (`(,artgroup . ,arts)
+                   (nnselect-categorize artlist 'nnselect-artitem-group))
+      (let (list)
+        (pcase-dolist (`(,rsv . ,articles)
+                       (nnselect-categorize
+                        arts 'nnselect-artitem-rsv 'nnselect-artitem-number))
+          (push (cons rsv (gnus-compress-sequence (sort articles '<)))
+                list))
+        (push (cons artgroup list) selection)))
+    selection))
+
+(defun nnselect-uncompress-artlist (artlist)
+  (let (selection)
+    (pcase-dolist (`(,artgroup (,artrsv . ,artseq)) artlist)
+      (dolist (art (reverse (gnus-uncompress-sequence artseq)))
+        (push (vector artgroup art artrsv) selection)))
+    (apply #'vector selection)))
 
 (defun nnselect-group-server (group)
   (gnus-group-server group))
@@ -190,9 +209,12 @@ as `(keyfunc member)' and the corresponding element is just
 (defmacro nnselect-get-artlist (group)
   "Retrieve the list of articles for the group"
   `(when (gnus-nnselect-group-p ,group)
-    (gnus-group-get-parameter
-     ,group
-     'nnselect-artlist t)))
+     (let ((artlist
+           (gnus-group-get-parameter ,group 'nnselect-artlist t)))
+       (if (vectorp artlist)
+          artlist
+        (nnselect-uncompress-artlist artlist)))))
+
 
 ;;; User Customizable Variables:
 
@@ -237,9 +259,9 @@ If this variable is nil, or if the provided function 
returns nil,
     (unless nnselect-artlist
       (gnus-group-set-parameter
        group 'nnselect-artlist
-       (setq nnselect-artlist
+       (nnselect-compress-artlist (setq nnselect-artlist
             (nnselect-run
-             (gnus-group-get-parameter group 'nnselect-specs t))))
+             (gnus-group-get-parameter group 'nnselect-specs t)))))
       (nnselect-request-update-info
        group (or info (gnus-get-info group))))
     (if (zerop (setq length (nnselect-artlist-length nnselect-artlist)))
@@ -549,7 +571,7 @@ If this variable is nil, or if the provided function 
returns nil,
            (gnus-group-set-parameter
             group
             'nnselect-artlist
-            gnus-newsgroup-selection)
+            (nnselect-compress-artlist gnus-newsgroup-selection))
            (when (>= last first)
              (let (new-marks)
                (pcase-dolist (`(,artgroup . ,artids)
@@ -607,8 +629,8 @@ If this variable is nil, or if the provided function 
returns nil,
     (gnus-group-set-parameter group 'nnselect-specs nnselect-specs)
     (gnus-group-set-parameter
      group 'nnselect-artlist
-     (or  (alist-get 'nnselect-artlist args)
-         (nnselect-run nnselect-specs)))
+     (nnselect-compress-artlist (or  (alist-get 'nnselect-artlist args)
+         (nnselect-run nnselect-specs))))
     (nnselect-request-update-info group (gnus-get-info group)))
   t)
 
@@ -642,10 +664,8 @@ If this variable is nil, or if the provided function 
returns nil,
   (let ((group (nnselect-add-prefix group)))
     (gnus-group-set-parameter
      group 'nnselect-artlist
-     (nnselect-run
-      (gnus-group-get-parameter group 'nnselect-specs t)))
-    ;; (nnselect-request-update-info
-    ;;  group (or info (gnus-get-info group)))
+     (nnselect-compress-artlist (nnselect-run
+      (gnus-group-get-parameter group 'nnselect-specs t))))
     ))
 
 ;; Add any undefined required backend functions



reply via email to

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