diff options
| author | Andrew Cohen | 2013-04-10 22:13:37 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2013-04-10 22:13:37 +0000 |
| commit | 7d9644924ee1db68bea74ec1fbb1e89af4612076 (patch) | |
| tree | d72a7a56d626413686a1d4e0617acaf6d7101472 | |
| parent | f009190abc3a010cc0ad01df81d02585d436ea3d (diff) | |
| download | emacs-7d9644924ee1db68bea74ec1fbb1e89af4612076.tar.gz emacs-7d9644924ee1db68bea74ec1fbb1e89af4612076.zip | |
lisp/gnus/nnir.el: Improve marks handling
| -rw-r--r-- | lisp/gnus/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/gnus/nnir.el | 74 |
2 files changed, 43 insertions, 38 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index ca78e7c99b4..b5390fe938f 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-04-10 Andrew Cohen <cohen@bu.edu> | ||
| 2 | |||
| 3 | * nnir.el (number-sequence): No longer used. | ||
| 4 | (nnir-request-set-mark): New function. | ||
| 5 | (nnir-request-update-info): Improve marks updating. | ||
| 6 | (nnir-request-scan): Don't duplicate marks updating. | ||
| 7 | |||
| 1 | 2013-04-04 Andrew Cohen <cohen@bu.edu> | 8 | 2013-04-04 Andrew Cohen <cohen@bu.edu> |
| 2 | 9 | ||
| 3 | * nnir.el (gnus-nnir-group-p): New function. | 10 | * nnir.el (gnus-nnir-group-p): New function. |
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el index b96f0c1cb78..c6baa301c06 100644 --- a/lisp/gnus/nnir.el +++ b/lisp/gnus/nnir.el | |||
| @@ -173,15 +173,7 @@ | |||
| 173 | 173 | ||
| 174 | ;; For Emacs <22.2 and XEmacs. | 174 | ;; For Emacs <22.2 and XEmacs. |
| 175 | (eval-and-compile | 175 | (eval-and-compile |
| 176 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))) | 176 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
| 177 | (unless (fboundp 'number-sequence) | ||
| 178 | (defun number-sequence (from to) | ||
| 179 | (let (seq (n 0) (next from)) | ||
| 180 | (while (<= next to) | ||
| 181 | (setq seq (cons next seq) | ||
| 182 | n (1+ n) | ||
| 183 | next (+ from n ))) | ||
| 184 | (nreverse seq))))) | ||
| 185 | 177 | ||
| 186 | (require 'nnoo) | 178 | (require 'nnoo) |
| 187 | (require 'gnus-group) | 179 | (require 'gnus-group) |
| @@ -846,11 +838,31 @@ skips all prompting." | |||
| 846 | (artnumber (nnir-article-number article))) | 838 | (artnumber (nnir-article-number article))) |
| 847 | (gnus-request-update-mark artgroup artnumber mark))) | 839 | (gnus-request-update-mark artgroup artnumber mark))) |
| 848 | 840 | ||
| 841 | (deffoo nnir-request-set-mark (group actions &optional server) | ||
| 842 | (let (mlist) | ||
| 843 | (dolist (action actions) | ||
| 844 | (destructuring-bind (range action marks) action | ||
| 845 | (let ((articles-by-group (nnir-categorize | ||
| 846 | (gnus-uncompress-range range) | ||
| 847 | nnir-article-group nnir-article-number))) | ||
| 848 | (dolist (artgroup articles-by-group) | ||
| 849 | (push (list | ||
| 850 | (car artgroup) | ||
| 851 | (list (gnus-compress-sequence | ||
| 852 | (sort (cadr artgroup) '<)) action marks)) mlist))))) | ||
| 853 | (dolist (request (nnir-categorize mlist car cadr)) | ||
| 854 | (gnus-request-set-mark (car request) (cadr request))))) | ||
| 855 | |||
| 849 | 856 | ||
| 850 | (deffoo nnir-request-update-info (group info &optional server) | 857 | (deffoo nnir-request-update-info (group info &optional server) |
| 851 | (let ((articles-by-group | 858 | (nnir-possibly-change-group group) |
| 859 | ;; clear out all existing marks. | ||
| 860 | (gnus-info-set-marks info nil) | ||
| 861 | (gnus-info-set-read info nil) | ||
| 862 | (let ((group (gnus-group-guess-full-name-from-command-method group)) | ||
| 863 | (articles-by-group | ||
| 852 | (nnir-categorize | 864 | (nnir-categorize |
| 853 | (number-sequence 1 (nnir-artlist-length nnir-artlist)) | 865 | (gnus-uncompress-range (cons 1 (nnir-artlist-length nnir-artlist))) |
| 854 | nnir-article-group nnir-article-ids))) | 866 | nnir-article-group nnir-article-ids))) |
| 855 | (gnus-set-active group | 867 | (gnus-set-active group |
| 856 | (cons 1 (nnir-artlist-length nnir-artlist))) | 868 | (cons 1 (nnir-artlist-length nnir-artlist))) |
| @@ -864,23 +876,20 @@ skips all prompting." | |||
| 864 | info | 876 | info |
| 865 | (gnus-add-to-range | 877 | (gnus-add-to-range |
| 866 | (gnus-info-read info) | 878 | (gnus-info-read info) |
| 867 | (remove nil (mapcar (lambda (art) | 879 | (delq nil |
| 868 | (let ((num (cdr art))) | 880 | (mapcar |
| 869 | (when (gnus-member-of-range num read) | 881 | #'(lambda (art) |
| 870 | (car art)))) articleids)))) | 882 | (when (gnus-member-of-range (cdr art) read) (car art))) |
| 871 | (mapc (lambda (mark) | 883 | articleids)))) |
| 872 | (let ((type (car mark)) | 884 | (dolist (mark marks) |
| 873 | (range (cdr mark))) | 885 | (destructuring-bind (type . range) mark |
| 874 | (gnus-add-marked-articles | 886 | (gnus-add-marked-articles |
| 875 | group | 887 | group type |
| 876 | type | 888 | (delq nil |
| 877 | (remove nil | ||
| 878 | (mapcar | 889 | (mapcar |
| 879 | (lambda (art) | 890 | #'(lambda (art) |
| 880 | (let ((num (cdr art))) | 891 | (when (gnus-member-of-range (cdr art) range) (car art))) |
| 881 | (when (gnus-member-of-range num range) | 892 | articleids))))))))) |
| 882 | (car art)))) | ||
| 883 | articleids))))) marks))))) | ||
| 884 | 893 | ||
| 885 | 894 | ||
| 886 | (deffoo nnir-close-group (group &optional server) | 895 | (deffoo nnir-close-group (group &optional server) |
| @@ -1901,22 +1910,11 @@ article came from is also searched." | |||
| 1901 | t) | 1910 | t) |
| 1902 | 1911 | ||
| 1903 | (deffoo nnir-request-scan (group method) | 1912 | (deffoo nnir-request-scan (group method) |
| 1904 | (if group | 1913 | t) |
| 1905 | (let ((pgroup (if (gnus-group-prefixed-p group) | ||
| 1906 | group | ||
| 1907 | (gnus-group-prefixed-name group '(nnir "nnir"))))) | ||
| 1908 | (gnus-group-set-parameter | ||
| 1909 | pgroup 'nnir-artlist | ||
| 1910 | (setq nnir-artlist | ||
| 1911 | (nnir-run-query | ||
| 1912 | (gnus-group-get-parameter pgroup 'nnir-specs t)))) | ||
| 1913 | (nnir-request-update-info pgroup (gnus-get-info pgroup))) | ||
| 1914 | t)) | ||
| 1915 | 1914 | ||
| 1916 | (deffoo nnir-request-close () | 1915 | (deffoo nnir-request-close () |
| 1917 | t) | 1916 | t) |
| 1918 | 1917 | ||
| 1919 | |||
| 1920 | (nnoo-define-skeleton nnir) | 1918 | (nnoo-define-skeleton nnir) |
| 1921 | 1919 | ||
| 1922 | ;; The end. | 1920 | ;; The end. |