Mercurial > emacs
annotate lisp/gnus/nnvirtual.el @ 107521:54f3a4d055ee
Document font-use-system-font.
* cmdargs.texi (Font X): Move most content to Fonts.
* frames.texi (Fonts): New node. Document font-use-system-font.
* emacs.texi (Top):
* xresources.texi (Table of Resources):
* mule.texi (Defining Fontsets, Charsets): Update xrefs.
| author | Chong Yidong <cyd@stupidchicken.com> |
|---|---|
| date | Sat, 20 Mar 2010 13:24:06 -0400 |
| parents | 1d1d5d9bd884 |
| children | 8d09094063d0 376148b31b5e |
| rev | line source |
|---|---|
| 17493 | 1 ;;; nnvirtual.el --- virtual newsgroups access for Gnus |
|
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
|
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
| 106815 | 4 ;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
| 17493 | 5 |
| 6 ;; Author: David Moore <dmoore@ucsd.edu> | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org> |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
8 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
| 17493 | 9 ;; Keywords: news |
| 10 | |
| 11 ;; This file is part of GNU Emacs. | |
| 12 | |
|
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 17493 | 14 ;; it under the terms of the GNU General Public License as published by |
|
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
|
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
| 17493 | 17 |
| 18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 ;; GNU General Public License for more details. | |
| 22 | |
| 23 ;; You should have received a copy of the GNU General Public License | |
|
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 17493 | 25 |
| 26 ;;; Commentary: | |
| 27 | |
| 28 ;; The other access methods (nntp, nnspool, etc) are general news | |
| 29 ;; access methods. This module relies on Gnus and can not be used | |
| 30 ;; separately. | |
| 31 | |
| 32 ;;; Code: | |
| 33 | |
| 34 (require 'nntp) | |
| 35 (require 'nnheader) | |
| 36 (require 'gnus) | |
| 37 (require 'nnoo) | |
| 38 (require 'gnus-util) | |
| 39 (require 'gnus-start) | |
| 40 (require 'gnus-sum) | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
41 (require 'gnus-msg) |
| 17493 | 42 (eval-when-compile (require 'cl)) |
| 43 | |
| 44 (nnoo-declare nnvirtual) | |
| 45 | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
46 (defvoo nnvirtual-always-rescan t |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
47 "If non-nil, always scan groups for unread articles when entering a group. |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
48 If this variable is nil and you read articles in a component group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
49 after the virtual group has been activated, the read articles from the |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
50 component group will show up when you enter the virtual group.") |
| 17493 | 51 |
| 52 (defvoo nnvirtual-component-regexp nil | |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
53 "Regexp to match component groups.") |
| 17493 | 54 |
| 55 (defvoo nnvirtual-component-groups nil | |
| 56 "Component group in this nnvirtual group.") | |
| 57 | |
| 58 | |
| 59 | |
| 60 (defconst nnvirtual-version "nnvirtual 1.1") | |
| 61 | |
| 62 (defvoo nnvirtual-current-group nil) | |
| 63 | |
| 64 (defvoo nnvirtual-mapping-table nil | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
65 "Table of rules on how to map between component group and article number to virtual article number.") |
| 17493 | 66 |
| 67 (defvoo nnvirtual-mapping-offsets nil | |
| 68 "Table indexed by component group to an offset to be applied to article numbers in that group.") | |
| 69 | |
| 70 (defvoo nnvirtual-mapping-len 0 | |
| 71 "Number of articles in this virtual group.") | |
| 72 | |
| 73 (defvoo nnvirtual-mapping-reads nil | |
| 74 "Compressed sequence of read articles on the virtual group as computed from the unread status of individual component groups.") | |
| 75 | |
| 76 (defvoo nnvirtual-mapping-marks nil | |
| 77 "Compressed marks alist for the virtual group as computed from the marks of individual component groups.") | |
| 78 | |
| 79 (defvoo nnvirtual-info-installed nil | |
| 80 "T if we have already installed the group info for this group, and shouldn't blast over it again.") | |
| 81 | |
| 82 (defvoo nnvirtual-status-string "") | |
| 83 | |
|
95820
645fb33380d6
Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents:
94662
diff
changeset
|
84 (autoload 'gnus-cache-articles-in-group "gnus-cache") |
| 17493 | 85 |
| 86 | |
| 87 | |
| 88 ;;; Interface functions. | |
| 89 | |
| 90 (nnoo-define-basics nnvirtual) | |
| 91 | |
| 92 | |
| 93 (deffoo nnvirtual-retrieve-headers (articles &optional newsgroup | |
| 94 server fetch-old) | |
| 95 (when (nnvirtual-possibly-change-server server) | |
| 96 (save-excursion | |
| 97 (set-buffer nntp-server-buffer) | |
| 98 (erase-buffer) | |
| 99 (if (stringp (car articles)) | |
| 100 'headers | |
| 101 (let ((vbuf (nnheader-set-temp-buffer | |
| 102 (get-buffer-create " *virtual headers*"))) | |
| 103 (carticles (nnvirtual-partition-sequence articles)) | |
| 104 (system-name (system-name)) | |
| 105 cgroup carticle article result prefix) | |
| 106 (while carticles | |
| 107 (setq cgroup (caar carticles)) | |
| 108 (setq articles (cdar carticles)) | |
| 109 (pop carticles) | |
| 110 (when (and articles | |
| 111 (gnus-check-server | |
| 112 (gnus-find-method-for-group cgroup) t) | |
| 113 (gnus-request-group cgroup t) | |
| 114 (setq prefix (gnus-group-real-prefix cgroup)) | |
| 115 ;; FIX FIX FIX we want to check the cache! | |
| 116 ;; This is probably evil if people have set | |
| 117 ;; gnus-use-cache to nil themselves, but I | |
| 118 ;; have no way of finding the true value of it. | |
| 119 (let ((gnus-use-cache t)) | |
| 120 (setq result (gnus-retrieve-headers | |
| 121 articles cgroup nil)))) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
122 (set-buffer nntp-server-buffer) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
123 ;; If we got HEAD headers, we convert them into NOV |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
124 ;; headers. This is slow, inefficient and, come to think |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
125 ;; of it, downright evil. So sue me. I couldn't be |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
126 ;; bothered to write a header parse routine that could |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
127 ;; parse a mixed HEAD/NOV buffer. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
128 (when (eq result 'headers) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
129 (nnvirtual-convert-headers)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
130 (goto-char (point-min)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
131 (while (not (eobp)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
132 (delete-region (point) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
133 (progn |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
134 (setq carticle (read nntp-server-buffer)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
135 (point))) |
| 17493 | 136 |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
137 ;; We remove this article from the articles list, if |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
138 ;; anything is left in the articles list after going through |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
139 ;; the entire buffer, then those articles have been |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
140 ;; expired or canceled, so we appropriately update the |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
141 ;; component group below. They should be coming up |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
142 ;; generally in order, so this shouldn't be slow. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
143 (setq articles (delq carticle articles)) |
| 17493 | 144 |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
145 (setq article (nnvirtual-reverse-map-article cgroup carticle)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
146 (if (null article) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
147 ;; This line has no reverse mapping, that means it |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
148 ;; was an extra article reference returned by nntp. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
149 (progn |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
150 (beginning-of-line) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
151 (delete-region (point) (progn (forward-line 1) (point)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
152 ;; Otherwise insert the virtual article number, |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
153 ;; and clean up the xrefs. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
154 (princ article nntp-server-buffer) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
155 (nnvirtual-update-xref-header cgroup carticle |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
156 prefix system-name) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
157 (forward-line 1)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
158 ) |
| 17493 | 159 |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
160 (set-buffer vbuf) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
161 (goto-char (point-max)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
162 (insert-buffer-substring nntp-server-buffer)) |
| 17493 | 163 ;; Anything left in articles is expired or canceled. |
| 164 ;; Could be smart and not tell it about articles already known? | |
| 165 (when articles | |
| 166 (gnus-group-make-articles-read cgroup articles)) | |
| 167 ) | |
| 168 | |
| 169 ;; The headers are ready for reading, so they are inserted into | |
| 170 ;; the nntp-server-buffer, which is where Gnus expects to find | |
| 171 ;; them. | |
| 172 (prog1 | |
| 173 (save-excursion | |
| 174 (set-buffer nntp-server-buffer) | |
| 175 (erase-buffer) | |
| 176 (insert-buffer-substring vbuf) | |
| 177 ;; FIX FIX FIX, we should be able to sort faster than | |
| 178 ;; this if needed, since each cgroup is sorted, we just | |
| 179 ;; need to merge | |
| 180 (sort-numeric-fields 1 (point-min) (point-max)) | |
| 181 'nov) | |
| 182 (kill-buffer vbuf))))))) | |
| 183 | |
| 184 | |
| 185 (defvoo nnvirtual-last-accessed-component-group nil) | |
| 186 | |
| 187 (deffoo nnvirtual-request-article (article &optional group server buffer) | |
| 188 (when (nnvirtual-possibly-change-server server) | |
| 189 (if (stringp article) | |
| 190 ;; This is a fetch by Message-ID. | |
| 191 (cond | |
| 192 ((not nnvirtual-last-accessed-component-group) | |
| 193 (nnheader-report | |
| 194 'nnvirtual "Don't know what server to request from")) | |
| 195 (t | |
| 196 (save-excursion | |
| 197 (when buffer | |
| 198 (set-buffer buffer)) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
199 (let* ((gnus-override-method nil) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
200 (method (gnus-find-method-for-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
201 nnvirtual-last-accessed-component-group))) |
| 17493 | 202 (funcall (gnus-get-function method 'request-article) |
| 203 article nil (nth 1 method) buffer))))) | |
| 204 ;; This is a fetch by number. | |
| 205 (let* ((amap (nnvirtual-map-article article)) | |
| 206 (cgroup (car amap))) | |
| 207 (cond | |
| 208 ((not amap) | |
| 209 (nnheader-report 'nnvirtual "No such article: %s" article)) | |
| 210 ((not (gnus-check-group cgroup)) | |
| 211 (nnheader-report | |
| 212 'nnvirtual "Can't open server where %s exists" cgroup)) | |
| 213 ((not (gnus-request-group cgroup t)) | |
| 214 (nnheader-report 'nnvirtual "Can't open component group %s" cgroup)) | |
| 215 (t | |
| 216 (setq nnvirtual-last-accessed-component-group cgroup) | |
| 217 (if buffer | |
| 218 (save-excursion | |
| 219 (set-buffer buffer) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
220 ;; We bind this here to avoid double decoding. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
221 (let ((gnus-article-decode-hook nil)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
222 (gnus-request-article-this-buffer (cdr amap) cgroup))) |
| 17493 | 223 (gnus-request-article (cdr amap) cgroup)))))))) |
| 224 | |
| 225 | |
| 226 (deffoo nnvirtual-open-server (server &optional defs) | |
| 227 (unless (assq 'nnvirtual-component-regexp defs) | |
| 228 (push `(nnvirtual-component-regexp ,server) | |
| 229 defs)) | |
| 230 (nnoo-change-server 'nnvirtual server defs) | |
| 231 (if nnvirtual-component-groups | |
| 232 t | |
| 233 (setq nnvirtual-mapping-table nil | |
| 234 nnvirtual-mapping-offsets nil | |
| 235 nnvirtual-mapping-len 0 | |
| 236 nnvirtual-mapping-reads nil | |
| 237 nnvirtual-mapping-marks nil | |
| 238 nnvirtual-info-installed nil) | |
| 239 (when nnvirtual-component-regexp | |
| 240 ;; Go through the newsrc alist and find all component groups. | |
| 241 (let ((newsrc (cdr gnus-newsrc-alist)) | |
| 242 group) | |
| 243 (while (setq group (car (pop newsrc))) | |
| 244 (when (string-match nnvirtual-component-regexp group) ; Match | |
| 245 ;; Add this group to the list of component groups. | |
| 246 (setq nnvirtual-component-groups | |
| 247 (cons group (delete group nnvirtual-component-groups))))))) | |
| 248 (if (not nnvirtual-component-groups) | |
| 249 (nnheader-report 'nnvirtual "No component groups: %s" server) | |
| 250 t))) | |
| 251 | |
| 252 | |
| 253 (deffoo nnvirtual-request-group (group &optional server dont-check) | |
| 254 (nnvirtual-possibly-change-server server) | |
| 255 (setq nnvirtual-component-groups | |
| 256 (delete (nnvirtual-current-group) nnvirtual-component-groups)) | |
| 257 (cond | |
| 258 ((null nnvirtual-component-groups) | |
| 259 (setq nnvirtual-current-group nil) | |
| 260 (nnheader-report 'nnvirtual "No component groups in %s" group)) | |
| 261 (t | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
262 (setq nnvirtual-current-group group) |
| 17493 | 263 (when (or (not dont-check) |
| 264 nnvirtual-always-rescan) | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
265 (nnvirtual-create-mapping) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
266 (when nnvirtual-always-rescan |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
267 (nnvirtual-request-update-info |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
268 (nnvirtual-current-group) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
269 (gnus-get-info (nnvirtual-current-group))))) |
| 17493 | 270 (nnheader-insert "211 %d 1 %d %s\n" |
| 271 nnvirtual-mapping-len nnvirtual-mapping-len group)))) | |
| 272 | |
| 273 | |
| 274 (deffoo nnvirtual-request-type (group &optional article) | |
| 275 (if (not article) | |
| 276 'unknown | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
277 (if (numberp article) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
278 (let ((mart (nnvirtual-map-article article))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
279 (if mart |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
280 (gnus-request-type (car mart) (cdr mart)))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
281 (gnus-request-type |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
282 nnvirtual-last-accessed-component-group nil)))) |
| 17493 | 283 |
| 284 (deffoo nnvirtual-request-update-mark (group article mark) | |
| 285 (let* ((nart (nnvirtual-map-article article)) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
286 (cgroup (car nart))) |
| 17493 | 287 (when (and nart |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
288 (memq mark gnus-auto-expirable-marks) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
289 ;; The component group might be a virtual group. |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
290 (= mark (gnus-request-update-mark cgroup (cdr nart) mark)) |
| 17493 | 291 (gnus-group-auto-expirable-p cgroup)) |
| 292 (setq mark gnus-expirable-mark))) | |
| 293 mark) | |
| 294 | |
| 295 | |
| 296 (deffoo nnvirtual-close-group (group &optional server) | |
| 297 (when (and (nnvirtual-possibly-change-server server) | |
| 298 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) | |
| 299 (nnvirtual-update-read-and-marked t t)) | |
| 300 t) | |
| 301 | |
| 302 | |
| 303 (deffoo nnvirtual-request-list (&optional server) | |
| 304 (nnheader-report 'nnvirtual "LIST is not implemented.")) | |
| 305 | |
| 306 | |
| 307 (deffoo nnvirtual-request-newgroups (date &optional server) | |
| 308 (nnheader-report 'nnvirtual "NEWGROUPS is not supported.")) | |
| 309 | |
| 310 | |
| 311 (deffoo nnvirtual-request-list-newsgroups (&optional server) | |
| 312 (nnheader-report 'nnvirtual "LIST NEWSGROUPS is not implemented.")) | |
| 313 | |
| 314 | |
| 315 (deffoo nnvirtual-request-update-info (group info &optional server) | |
| 316 (when (and (nnvirtual-possibly-change-server server) | |
| 317 (not nnvirtual-info-installed)) | |
| 318 ;; Install the precomputed lists atomically, so the virtual group | |
| 319 ;; is not left in a half-way state in case of C-g. | |
| 320 (gnus-atomic-progn | |
| 321 (setcar (cddr info) nnvirtual-mapping-reads) | |
| 322 (if (nthcdr 3 info) | |
| 323 (setcar (nthcdr 3 info) nnvirtual-mapping-marks) | |
| 324 (when nnvirtual-mapping-marks | |
| 325 (setcdr (nthcdr 2 info) (list nnvirtual-mapping-marks)))) | |
| 326 (setq nnvirtual-info-installed t)) | |
| 327 t)) | |
| 328 | |
| 329 | |
| 330 (deffoo nnvirtual-catchup-group (group &optional server all) | |
| 331 (when (and (nnvirtual-possibly-change-server server) | |
| 332 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) | |
| 333 ;; copy over existing marks first, in case they set anything | |
| 334 (nnvirtual-update-read-and-marked nil nil) | |
| 335 ;; do a catchup on all component groups | |
| 336 (let ((gnus-group-marked (copy-sequence nnvirtual-component-groups)) | |
| 337 (gnus-expert-user t)) | |
| 338 ;; Make sure all groups are activated. | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
339 (mapc |
| 17493 | 340 (lambda (g) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
341 (when (not (numberp (gnus-group-unread g))) |
| 17493 | 342 (gnus-activate-group g))) |
| 343 nnvirtual-component-groups) | |
| 344 (save-excursion | |
| 345 (set-buffer gnus-group-buffer) | |
| 346 (gnus-group-catchup-current nil all))))) | |
| 347 | |
| 348 | |
| 349 (deffoo nnvirtual-find-group-art (group article) | |
| 350 "Return the real group and article for virtual GROUP and ARTICLE." | |
| 351 (nnvirtual-map-article article)) | |
| 352 | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
353 |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
354 (deffoo nnvirtual-request-post (&optional server) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
355 (if (not gnus-message-group-art) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
356 (nnheader-report 'nnvirtual "Can't post to an nnvirtual group") |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
357 (let ((group (car (nnvirtual-find-group-art |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
358 (car gnus-message-group-art) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
359 (cdr gnus-message-group-art))))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
360 (gnus-request-post (gnus-find-method-for-group group))))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
361 |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
362 |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48588
diff
changeset
|
363 (deffoo nnvirtual-request-expire-articles (articles group |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
364 &optional server force) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
365 (nnvirtual-possibly-change-server server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
366 (setq nnvirtual-component-groups |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
367 (delete (nnvirtual-current-group) nnvirtual-component-groups)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
368 (let (unexpired) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
369 (dolist (group nnvirtual-component-groups) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
370 (setq unexpired (nconc unexpired |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
371 (mapcar |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
372 #'(lambda (article) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
373 (nnvirtual-reverse-map-article |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
374 group article)) |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
375 (gnus-uncompress-range |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
376 (gnus-group-expire-articles-1 group)))))) |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
377 (sort (delq nil unexpired) '<))) |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
378 |
| 17493 | 379 |
| 380 ;;; Internal functions. | |
| 381 | |
| 382 (defun nnvirtual-convert-headers () | |
| 383 "Convert HEAD headers into NOV headers." | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
384 (with-current-buffer nntp-server-buffer |
| 17493 | 385 (let* ((dependencies (make-vector 100 0)) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
386 (headers (gnus-get-newsgroup-headers dependencies))) |
| 17493 | 387 (erase-buffer) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
388 (mapc 'nnheader-insert-nov headers)))) |
| 17493 | 389 |
| 390 | |
| 391 (defun nnvirtual-update-xref-header (group article prefix system-name) | |
| 392 "Edit current NOV header in current buffer to have an xref to the component group, and also server prefix any existing xref lines." | |
| 393 ;; Move to beginning of Xref field, creating a slot if needed. | |
| 394 (beginning-of-line) | |
| 395 (looking-at | |
| 396 "[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t") | |
| 397 (goto-char (match-end 0)) | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
398 (unless (search-forward "\t" (point-at-eol) 'move) |
| 17493 | 399 (insert "\t")) |
| 400 | |
| 401 ;; Remove any spaces at the beginning of the Xref field. | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
402 (while (eq (char-after (1- (point))) ? ) |
| 17493 | 403 (forward-char -1) |
| 404 (delete-char 1)) | |
| 405 | |
| 406 (insert "Xref: " system-name " " group ":") | |
| 407 (princ article (current-buffer)) | |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
408 (insert " ") |
| 17493 | 409 |
| 410 ;; If there were existing xref lines, clean them up to have the correct | |
| 411 ;; component server prefix. | |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
412 (save-restriction |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
413 (narrow-to-region (point) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
414 (or (search-forward "\t" (point-at-eol) t) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
415 (point-at-eol))) |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
416 (goto-char (point-min)) |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
417 (when (re-search-forward "Xref: *[^\n:0-9 ]+ *" nil t) |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
418 (replace-match "" t t)) |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
419 (goto-char (point-min)) |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
420 (when (re-search-forward |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
421 (concat (regexp-quote (gnus-group-real-name group)) ":[0-9]+") |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
422 nil t) |
|
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
423 (replace-match "" t t)) |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
424 (unless (eobp) |
| 17493 | 425 (insert " ") |
| 426 (when (not (string= "" prefix)) | |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
427 (while (re-search-forward "[^ ]+:[0-9]+" nil t) |
| 17493 | 428 (save-excursion |
| 429 (goto-char (match-beginning 0)) | |
|
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19496
diff
changeset
|
430 (insert prefix)))))) |
| 17493 | 431 |
| 432 ;; Ensure a trailing \t. | |
| 433 (end-of-line) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
434 (or (eq (char-after (1- (point))) ?\t) |
| 17493 | 435 (insert ?\t))) |
| 436 | |
| 437 | |
| 438 (defun nnvirtual-possibly-change-server (server) | |
| 439 (or (not server) | |
| 440 (nnoo-current-server-p 'nnvirtual server) | |
| 441 (nnvirtual-open-server server))) | |
| 442 | |
| 443 | |
| 444 (defun nnvirtual-update-read-and-marked (read-p update-p) | |
| 445 "Copy marks from the virtual group to the component groups. | |
| 446 If READ-P is not nil, update the (un)read status of the components. | |
| 447 If UPDATE-P is not nil, call gnus-group-update-group on the components." | |
| 448 (when nnvirtual-current-group | |
| 449 (let ((unreads (and read-p | |
| 450 (nnvirtual-partition-sequence | |
| 451 (gnus-list-of-unread-articles | |
| 452 (nnvirtual-current-group))))) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
453 (type-marks |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
454 (delq nil |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
455 (mapcar (lambda (ml) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
456 (if (eq (car ml) 'score) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
457 nil |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
458 (cons (car ml) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
459 (nnvirtual-partition-sequence (cdr ml))))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
460 (gnus-info-marks (gnus-get-info |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
461 (nnvirtual-current-group)))))) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
462 type groups info) |
| 17493 | 463 |
| 464 ;; Ok, atomically move all of the (un)read info, clear any old | |
| 465 ;; marks, and move all of the current marks. This way if someone | |
| 466 ;; hits C-g, you won't leave the component groups in a half-way state. | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
467 (progn |
| 17493 | 468 ;; move (un)read |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
469 ;; bind for workaround guns-update-read-articles |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
470 (let ((gnus-newsgroup-active nil)) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
471 (dolist (entry unreads) |
| 17493 | 472 (gnus-update-read-articles (car entry) (cdr entry)))) |
| 473 | |
| 474 ;; clear all existing marks on the component groups | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
475 (dolist (group nnvirtual-component-groups) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
476 (when (and (setq info (gnus-get-info group)) |
| 17493 | 477 (gnus-info-marks info)) |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
478 (gnus-info-set-marks |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
479 info |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
480 (if (assq 'score (gnus-info-marks info)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
481 (list (assq 'score (gnus-info-marks info))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
482 nil)))) |
| 17493 | 483 |
| 484 ;; Ok, currently type-marks is an assq list with keys of a mark type, | |
| 485 ;; with data of an assq list with keys of component group names | |
| 486 ;; and the articles which correspond to that key/group pair. | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
487 (dolist (mark type-marks) |
| 17493 | 488 (setq type (car mark)) |
| 489 (setq groups (cdr mark)) | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
490 (dolist (carticles groups) |
| 17493 | 491 (gnus-add-marked-articles (car carticles) type (cdr carticles) |
| 492 nil t)))) | |
| 493 | |
| 494 ;; possibly update the display, it is really slow | |
| 495 (when update-p | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
496 (dolist (group nnvirtual-component-groups) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
497 (gnus-group-update-group group t)))))) |
| 17493 | 498 |
| 499 | |
| 500 (defun nnvirtual-current-group () | |
| 501 "Return the prefixed name of the current nnvirtual group." | |
| 502 (concat "nnvirtual:" nnvirtual-current-group)) | |
| 503 | |
| 504 | |
| 505 | |
| 506 ;;; This is currently O(kn^2) to merge n lists of length k. | |
| 507 ;;; You could do it in O(knlogn), but we have a small n, and the | |
| 508 ;;; overhead of the other approach is probably greater. | |
| 509 (defun nnvirtual-merge-sorted-lists (&rest lists) | |
| 510 "Merge many sorted lists of numbers." | |
| 511 (if (null (cdr lists)) | |
| 512 (car lists) | |
|
19496
77c68461cbb0
(nnvirtual-merge-sorted-lists): Use sort, not merge.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
513 (sort (apply 'nconc lists) '<))) |
| 17493 | 514 |
| 515 | |
| 516 ;;; We map between virtual articles and real articles in a manner | |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
517 ;;; which keeps the size of the virtual active list the same as the |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
518 ;;; sum of the component active lists. |
| 17493 | 519 |
|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
520 ;;; To achieve fair mixing of the groups, the last article in each of |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
521 ;;; N component groups will be in the last N articles in the virtual |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
522 ;;; group. |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
523 |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
524 ;;; If you have 3 components A, B and C, with articles 1-8, 1-5, and |
|
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
525 ;;; 6-7 respectively, then the virtual article numbers look like: |
| 17493 | 526 ;;; |
| 527 ;;; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
| 528 ;;; A1 A2 A3 A4 B1 A5 B2 A6 B3 A7 B4 C6 A8 B5 C7 | |
| 529 | |
| 530 ;;; To compute these mappings we generate a couple tables and then | |
| 531 ;;; do some fast operations on them. Tables for the example above: | |
| 532 ;;; | |
| 533 ;;; Offsets - [(A 0) (B -3) (C -1)] | |
| 534 ;;; | |
| 535 ;;; a b c d e | |
| 536 ;;; Mapping - ([ 3 0 1 3 0 ] | |
| 537 ;;; [ 6 3 2 9 3 ] | |
| 538 ;;; [ 8 6 3 15 9 ]) | |
| 539 ;;; | |
| 540 ;;; (note column 'e' is different in real algorithm, which is slightly | |
| 541 ;;; different than described here, but this gives you the methodology.) | |
| 542 ;;; | |
| 543 ;;; The basic idea is this, when going from component->virtual, apply | |
| 544 ;;; the appropriate offset to the article number. Then search the first | |
| 545 ;;; column of the table for a row where 'a' is less than or equal to the | |
| 546 ;;; modified number. You can see that only group A can therefore go to | |
| 547 ;;; the first row, groups A and B to the second, and all to the last. | |
| 548 ;;; The third column of the table is telling us the number of groups | |
| 549 ;;; which might be able to reach that row (it might increase by more than | |
| 550 ;;; 1 if several groups have the same size). | |
| 551 ;;; Then column 'b' provides an additional offset you apply when you have | |
| 552 ;;; found the correct row. You then multiply by 'c' and add on the groups | |
| 553 ;;; _position_ in the offset table. The basic idea here is that on | |
| 554 ;;; any given row we are going to map back and forth using X'=X*c+Y and | |
| 555 ;;; X=(X'/c), Y=(X' mod c). Then once you've done this transformation, | |
| 556 ;;; you apply a final offset from column 'e' to give the virtual article. | |
| 557 ;;; | |
| 558 ;;; Going the other direction, you instead search on column 'd' instead | |
| 559 ;;; of 'a', and apply everything in reverse order. | |
| 560 | |
| 561 ;;; Convert component -> virtual: | |
| 562 ;;; set num = num - Offset(group) | |
| 563 ;;; find first row in Mapping where num <= 'a' | |
| 564 ;;; num = (num-'b')*c + Position(group) + 'e' | |
| 565 | |
| 566 ;;; Convert virtual -> component: | |
| 567 ;;; find first row in Mapping where num <= 'd' | |
| 568 ;;; num = num - 'e' | |
| 569 ;;; group_pos = num mod 'c' | |
| 570 ;;; num = (num / 'c') + 'b' + Offset(group_pos) | |
| 571 | |
| 572 ;;; Easy no? :) | |
| 573 ;;; | |
| 574 ;;; Well actually, you need to keep column e offset smaller by the 'c' | |
| 575 ;;; column for that line, and always add 1 more when going from | |
| 576 ;;; component -> virtual. Otherwise you run into a problem with | |
| 577 ;;; unique reverse mapping. | |
| 578 | |
| 579 (defun nnvirtual-map-article (article) | |
| 580 "Return a cons of the component group and article corresponding to the given virtual ARTICLE." | |
| 581 (let ((table nnvirtual-mapping-table) | |
| 582 entry group-pos) | |
| 583 (while (and table | |
| 584 (> article (aref (car table) 3))) | |
| 585 (setq table (cdr table))) | |
| 586 (when (and table | |
| 587 (> article 0)) | |
| 588 (setq entry (car table)) | |
| 589 (setq article (- article (aref entry 4) 1)) | |
| 590 (setq group-pos (mod article (aref entry 2))) | |
| 591 (cons (car (aref nnvirtual-mapping-offsets group-pos)) | |
| 592 (+ (/ article (aref entry 2)) | |
| 593 (aref entry 1) | |
| 594 (cdr (aref nnvirtual-mapping-offsets group-pos))) | |
| 595 )) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
596 )) |
| 17493 | 597 |
| 598 | |
| 599 | |
| 600 (defun nnvirtual-reverse-map-article (group article) | |
| 601 "Return the virtual article number corresponding to the given component GROUP and ARTICLE." | |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
602 (when (numberp article) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
603 (let ((table nnvirtual-mapping-table) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
604 (group-pos 0) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
605 entry) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
606 (while (not (string= group (car (aref nnvirtual-mapping-offsets |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
607 group-pos)))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
608 (setq group-pos (1+ group-pos))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
609 (setq article (- article (cdr (aref nnvirtual-mapping-offsets |
| 17493 | 610 group-pos)))) |
|
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
611 (while (and table |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
612 (> article (aref (car table) 0))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
613 (setq table (cdr table))) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
614 (setq entry (car table)) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
615 (when (and entry |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
616 (> article 0) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
617 (< group-pos (aref entry 2))) ; article not out of range below |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
618 (+ (aref entry 4) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
619 group-pos |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
620 (* (- article (aref entry 1)) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
621 (aref entry 2)) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
622 1)) |
|
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
623 ))) |
| 17493 | 624 |
| 625 | |
| 626 (defsubst nnvirtual-reverse-map-sequence (group articles) | |
| 627 "Return list of virtual article numbers for all ARTICLES in GROUP. | |
| 628 The ARTICLES should be sorted, and can be a compressed sequence. | |
| 629 If any of the article numbers has no corresponding virtual article, | |
| 630 then it is left out of the result." | |
| 631 (when (numberp (cdr-safe articles)) | |
| 632 (setq articles (list articles))) | |
| 633 (let (result a i j new-a) | |
| 634 (while (setq a (pop articles)) | |
| 635 (if (atom a) | |
| 636 (setq i a | |
| 637 j a) | |
| 638 (setq i (car a) | |
| 639 j (cdr a))) | |
| 640 (while (<= i j) | |
| 641 ;; If this is slow, you can optimize by moving article checking | |
| 642 ;; into here. You don't have to recompute the group-pos, | |
| 643 ;; nor scan the table every time. | |
| 644 (when (setq new-a (nnvirtual-reverse-map-article group i)) | |
| 645 (push new-a result)) | |
| 646 (setq i (1+ i)))) | |
| 647 (nreverse result))) | |
| 648 | |
| 649 | |
| 650 (defun nnvirtual-partition-sequence (articles) | |
| 651 "Return an association list of component article numbers. | |
| 652 These are indexed by elements of nnvirtual-component-groups, based on | |
| 653 the sequence ARTICLES of virtual article numbers. ARTICLES should be | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26142
diff
changeset
|
654 sorted, and can be a compressed sequence. If any of the article |
| 17493 | 655 numbers has no corresponding component article, then it is left out of |
| 656 the result." | |
| 657 (when (numberp (cdr-safe articles)) | |
| 658 (setq articles (list articles))) | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
659 (let ((carticles (mapcar 'list nnvirtual-component-groups)) |
| 17493 | 660 a i j article entry) |
| 661 (while (setq a (pop articles)) | |
| 662 (if (atom a) | |
| 663 (setq i a | |
| 664 j a) | |
| 665 (setq i (car a) | |
| 666 j (cdr a))) | |
| 667 (while (<= i j) | |
| 668 (when (setq article (nnvirtual-map-article i)) | |
| 669 (setq entry (assoc (car article) carticles)) | |
| 670 (setcdr entry (cons (cdr article) (cdr entry)))) | |
| 671 (setq i (1+ i)))) | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
672 (mapc (lambda (x) (setcdr x (nreverse (cdr x)))) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
673 carticles) |
| 17493 | 674 carticles)) |
| 675 | |
| 676 | |
| 677 (defun nnvirtual-create-mapping () | |
| 678 "Build the tables necessary to map between component (group, article) to virtual article. | |
| 679 Generate the set of read messages and marks for the virtual group | |
| 680 based on the marks on the component groups." | |
| 681 (let ((cnt 0) | |
| 682 (tot 0) | |
| 683 (M 0) | |
| 684 (i 0) | |
| 685 actives all-unreads all-marks | |
| 686 active min max size unreads marks | |
| 687 next-M next-tot | |
| 688 reads beg) | |
| 689 ;; Ok, we loop over all component groups and collect a lot of | |
| 690 ;; information: | |
| 691 ;; Into actives we place (g size max), where size is max-min+1. | |
| 692 ;; Into all-unreads we put (g unreads). | |
| 693 ;; Into all-marks we put (g marks). | |
| 694 ;; We also increment cnt and tot here, and compute M (max of sizes). | |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
695 (mapc (lambda (g) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
696 (setq active (gnus-activate-group g) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
697 min (car active) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
698 max (cdr active)) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
699 (when (and active (>= max min) (not (zerop max))) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
700 ;; store active information |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
701 (push (list g (- max min -1) max) actives) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
702 ;; collect unread/mark info for later |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
703 (setq unreads (gnus-list-of-unread-articles g)) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
704 (setq marks (gnus-info-marks (gnus-get-info g))) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
705 (when gnus-use-cache |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
706 (push (cons 'cache |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
707 (gnus-cache-articles-in-group g)) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
708 marks)) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
709 (push (cons g unreads) all-unreads) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
710 (push (cons g marks) all-marks) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
711 ;; count groups, total #articles, and max size |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
712 (setq size (- max min -1)) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
713 (setq cnt (1+ cnt) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
714 tot (+ tot size) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
715 M (max M size)))) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
716 nnvirtual-component-groups) |
|
95820
645fb33380d6
Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents:
94662
diff
changeset
|
717 |
| 17493 | 718 ;; Number of articles in the virtual group. |
| 719 (setq nnvirtual-mapping-len tot) | |
| 720 | |
| 721 | |
| 722 ;; We want the actives list sorted by size, to build the tables. | |
| 723 (setq actives (sort actives (lambda (g1 g2) (< (nth 1 g1) (nth 1 g2))))) | |
| 724 | |
| 725 ;; Build the offset table. Largest sized groups are at the front. | |
| 726 (setq nnvirtual-mapping-offsets | |
| 727 (vconcat | |
| 728 (nreverse | |
| 729 (mapcar (lambda (entry) | |
| 730 (cons (nth 0 entry) | |
| 731 (- (nth 2 entry) M))) | |
| 732 actives)))) | |
| 733 | |
| 734 ;; Build the mapping table. | |
| 735 (setq nnvirtual-mapping-table nil) | |
| 736 (setq actives (mapcar (lambda (entry) (nth 1 entry)) actives)) | |
| 737 (while actives | |
| 738 (setq size (car actives)) | |
| 739 (setq next-M (- M size)) | |
| 740 (setq next-tot (- tot (* cnt size))) | |
| 741 ;; make current row in table | |
| 742 (push (vector M next-M cnt tot (- next-tot cnt)) | |
| 743 nnvirtual-mapping-table) | |
| 744 ;; update M and tot | |
| 745 (setq M next-M) | |
| 746 (setq tot next-tot) | |
| 747 ;; subtract the current size from all entries. | |
| 748 (setq actives (mapcar (lambda (x) (- x size)) actives)) | |
| 749 ;; remove anything that went to 0. | |
| 750 (while (and actives | |
| 751 (= (car actives) 0)) | |
| 752 (pop actives) | |
| 753 (setq cnt (- cnt 1)))) | |
| 754 | |
| 755 | |
| 756 ;; Now that the mapping tables are generated, we can convert | |
| 757 ;; and combine the separate component unreads and marks lists | |
| 758 ;; into single lists of virtual article numbers. | |
| 759 (setq unreads (apply 'nnvirtual-merge-sorted-lists | |
| 760 (mapcar (lambda (x) | |
| 761 (nnvirtual-reverse-map-sequence | |
| 762 (car x) (cdr x))) | |
| 763 all-unreads))) | |
| 764 (setq marks (mapcar | |
| 765 (lambda (type) | |
| 766 (cons (cdr type) | |
| 767 (gnus-compress-sequence | |
| 768 (apply | |
| 769 'nnvirtual-merge-sorted-lists | |
| 770 (mapcar (lambda (x) | |
| 771 (nnvirtual-reverse-map-sequence | |
| 772 (car x) | |
| 773 (cdr (assq (cdr type) (cdr x))))) | |
| 774 all-marks))))) | |
| 775 gnus-article-mark-lists)) | |
| 776 | |
| 777 ;; Remove any empty marks lists, and store. | |
|
19496
77c68461cbb0
(nnvirtual-merge-sorted-lists): Use sort, not merge.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
778 (setq nnvirtual-mapping-marks nil) |
|
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
779 (dolist (mark marks) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
780 (when (cdr mark) |
|
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
781 (push mark nnvirtual-mapping-marks))) |
| 17493 | 782 |
| 783 ;; We need to convert the unreads to reads. We compress the | |
| 784 ;; sequence as we go, otherwise it could be huge. | |
| 785 (while (and (<= (incf i) nnvirtual-mapping-len) | |
| 786 unreads) | |
| 787 (if (= i (car unreads)) | |
| 788 (setq unreads (cdr unreads)) | |
| 789 ;; try to get a range. | |
| 790 (setq beg i) | |
| 791 (while (and (<= (incf i) nnvirtual-mapping-len) | |
| 792 (not (= i (car unreads))))) | |
| 793 (setq i (- i 1)) | |
| 794 (if (= i beg) | |
| 795 (push i reads) | |
| 796 (push (cons beg i) reads)) | |
| 797 )) | |
| 798 (when (<= i nnvirtual-mapping-len) | |
| 799 (if (= i nnvirtual-mapping-len) | |
| 800 (push i reads) | |
| 801 (push (cons i nnvirtual-mapping-len) reads))) | |
| 802 | |
| 803 ;; Store the reads list for later use. | |
| 804 (setq nnvirtual-mapping-reads (nreverse reads)) | |
| 805 | |
| 806 ;; Throw flag to show we changed the info. | |
| 807 (setq nnvirtual-info-installed nil) | |
| 808 )) | |
| 809 | |
| 810 (provide 'nnvirtual) | |
| 811 | |
|
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
812 ;; arch-tag: ca8c8ad9-1bd8-4b0f-9722-90dc645a45f5 |
| 17493 | 813 ;;; nnvirtual.el ends here |
