[gnus git] branch master updated: m0-5-296-g2347133 =1= nnir.el: Improve marks handling.

Andrew Cohen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  23471335ba08ac2ddfe332ff6cbc9c1c230edf69 (commit)
      from  b6318d71b730210cd123dd373d9e800374acfb93 (commit)


- Log -----------------------------------------------------------------
commit 23471335ba08ac2ddfe332ff6cbc9c1c230edf69
Author: Andrew Cohen <[email protected]>
Date:   Wed Apr 10 10:24:43 2013 -0400

    nnir.el: Improve marks handling.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 18970c4..a10ca20 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-10  Andrew Cohen  <[email protected]>
+
+	* nnir.el (number-sequence): No longer used.
+	(nnir-request-set-mark): New function.
+	(nnir-request-update-info): Improve marks updating.
+	(nnir-request-scan): Don't duplicate marks updating.
+
 2013-04-04  Andrew Cohen  <[email protected]>
 
 	* nnir.el (gnus-nnir-group-p): New function.
diff --git a/lisp/nnir.el b/lisp/nnir.el
index 779bd2c..ef7bc24 100644
--- a/lisp/nnir.el
+++ b/lisp/nnir.el
@@ -173,15 +173,7 @@
 
 ;; For Emacs <22.2 and XEmacs.
 (eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
-  (unless (fboundp 'number-sequence)
-    (defun number-sequence (from to)
-      (let (seq (n 0) (next from))
-	(while (<= next to)
-	  (setq seq (cons next seq)
-		n (1+ n)
-		next (+ from  n )))
-	(nreverse seq)))))
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
 
 (require 'nnoo)
 (require 'gnus-group)
@@ -846,11 +838,31 @@ skips all prompting."
 	(artnumber (nnir-article-number article)))
     (gnus-request-update-mark artgroup artnumber mark)))
 
+(deffoo nnir-request-set-mark (group actions &optional server)
+  (let (mlist)
+    (dolist (action actions)
+      (destructuring-bind (range action marks) action
+        (let ((articles-by-group (nnir-categorize
+                                  (gnus-uncompress-range range)
+                                  nnir-article-group nnir-article-number)))
+          (dolist (artgroup articles-by-group)
+            (push (list
+		   (car artgroup)
+		   (list (gnus-compress-sequence
+			  (sort (cadr artgroup) '<)) action marks)) mlist)))))
+    (dolist (request (nnir-categorize  mlist car cadr))
+      (gnus-request-set-mark (car request) (cadr request)))))
+
 
 (deffoo nnir-request-update-info (group info &optional server)
-  (let ((articles-by-group
+  (nnir-possibly-change-group group)
+  ;; clear out all existing marks.
+  (gnus-info-set-marks info nil)
+  (gnus-info-set-read info nil)
+  (let ((group (gnus-group-guess-full-name-from-command-method group))
+	(articles-by-group
 	 (nnir-categorize
-	  (number-sequence 1 (nnir-artlist-length nnir-artlist))
+	  (gnus-uncompress-range (cons 1 (nnir-artlist-length nnir-artlist)))
 	  nnir-article-group nnir-article-ids)))
     (gnus-set-active group
 		     (cons 1 (nnir-artlist-length nnir-artlist)))
@@ -864,23 +876,20 @@ skips all prompting."
 	 info
 	 (gnus-add-to-range
 	  (gnus-info-read info)
-	  (remove nil  (mapcar (lambda (art)
-				 (let ((num (cdr art)))
-				   (when (gnus-member-of-range num read)
-				     (car art)))) articleids))))
-	(mapc (lambda (mark)
-		(let ((type (car mark))
-		      (range (cdr mark)))
+	  (delq nil
+		  (mapcar
+		   #'(lambda (art)
+		     (when (gnus-member-of-range (cdr art) read) (car art)))
+		   articleids))))
+	(dolist (mark marks)
+	  (destructuring-bind (type . range) mark
 		  (gnus-add-marked-articles
-		   group
-		   type
-		   (remove nil
+	     group type
+	     (delq nil
 			   (mapcar
-			    (lambda (art)
-			      (let ((num (cdr art)))
-				(when (gnus-member-of-range num range)
-				  (car art))))
-			    articleids))))) marks)))))
+		      #'(lambda (art)
+			(when (gnus-member-of-range (cdr art) range) (car art)))
+		      articleids)))))))))
 
 
 (deffoo nnir-close-group (group &optional server)
@@ -1901,22 +1910,11 @@ article came from is also searched."
   t)
 
 (deffoo nnir-request-scan (group method)
-  (if group
-      (let ((pgroup (if (gnus-group-prefixed-p group)
-			group
-		      (gnus-group-prefixed-name  group '(nnir "nnir")))))
-	(gnus-group-set-parameter
-	 pgroup 'nnir-artlist
-	 (setq nnir-artlist
-	       (nnir-run-query
-		(gnus-group-get-parameter pgroup 'nnir-specs t))))
-	(nnir-request-update-info pgroup (gnus-get-info pgroup)))
-    t))
+  t)
 
 (deffoo nnir-request-close ()
   t)
 
-
 (nnoo-define-skeleton nnir)
 
 ;; The end.

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    7 +++++
 lisp/nnir.el   |   78 +++++++++++++++++++++++++++----------------------------
 2 files changed, 45 insertions(+), 40 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.