Mercurial > hg > xemacs-beta
comparison lisp/gnus/nnvirtual.el @ 108:360340f9fd5f r20-1b6
Import from CVS: tag r20-1b6
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:18:39 +0200 |
parents | 0d2f883870bc |
children | fe104dbd9147 |
comparison
equal
deleted
inserted
replaced
107:523141596bda | 108:360340f9fd5f |
---|---|
98 (save-excursion | 98 (save-excursion |
99 (set-buffer nntp-server-buffer) | 99 (set-buffer nntp-server-buffer) |
100 (erase-buffer) | 100 (erase-buffer) |
101 (if (stringp (car articles)) | 101 (if (stringp (car articles)) |
102 'headers | 102 'headers |
103 (let ((vbuf (nnheader-set-temp-buffer | 103 (let ((vbuf (nnheader-set-temp-buffer |
104 (get-buffer-create " *virtual headers*"))) | 104 (get-buffer-create " *virtual headers*"))) |
105 (carticles (nnvirtual-partition-sequence articles)) | 105 (carticles (nnvirtual-partition-sequence articles)) |
106 (system-name (system-name)) | 106 (system-name (system-name)) |
107 cgroup carticle article result prefix) | 107 cgroup carticle article result prefix) |
108 (while carticles | 108 (while carticles |
141 ;; the entire buffer, then those articles have been | 141 ;; the entire buffer, then those articles have been |
142 ;; expired or canceled, so we appropriately update the | 142 ;; expired or canceled, so we appropriately update the |
143 ;; component group below. They should be coming up | 143 ;; component group below. They should be coming up |
144 ;; generally in order, so this shouldn't be slow. | 144 ;; generally in order, so this shouldn't be slow. |
145 (setq articles (delq carticle articles)) | 145 (setq articles (delq carticle articles)) |
146 | 146 |
147 (setq article (nnvirtual-reverse-map-article cgroup carticle)) | 147 (setq article (nnvirtual-reverse-map-article cgroup carticle)) |
148 (if (null article) | 148 (if (null article) |
149 ;; This line has no reverse mapping, that means it | 149 ;; This line has no reverse mapping, that means it |
150 ;; was an extra article reference returned by nntp. | 150 ;; was an extra article reference returned by nntp. |
151 (progn | 151 (progn |
156 (princ article nntp-server-buffer) | 156 (princ article nntp-server-buffer) |
157 (nnvirtual-update-xref-header cgroup carticle | 157 (nnvirtual-update-xref-header cgroup carticle |
158 prefix system-name) | 158 prefix system-name) |
159 (forward-line 1)) | 159 (forward-line 1)) |
160 ) | 160 ) |
161 | 161 |
162 (set-buffer vbuf) | 162 (set-buffer vbuf) |
163 (goto-char (point-max)) | 163 (goto-char (point-max)) |
164 (insert-buffer-substring nntp-server-buffer)) | 164 (insert-buffer-substring nntp-server-buffer)) |
165 ;; Anything left in articles is expired or canceled. | 165 ;; Anything left in articles is expired or canceled. |
166 ;; Could be smart and not tell it about articles already known? | 166 ;; Could be smart and not tell it about articles already known? |
194 ((not nnvirtual-last-accessed-component-group) | 194 ((not nnvirtual-last-accessed-component-group) |
195 (nnheader-report | 195 (nnheader-report |
196 'nnvirtual "Don't know what server to request from")) | 196 'nnvirtual "Don't know what server to request from")) |
197 (t | 197 (t |
198 (save-excursion | 198 (save-excursion |
199 (when buffer | 199 (when buffer |
200 (set-buffer buffer)) | 200 (set-buffer buffer)) |
201 (let ((method (gnus-find-method-for-group | 201 (let ((method (gnus-find-method-for-group |
202 nnvirtual-last-accessed-component-group))) | 202 nnvirtual-last-accessed-component-group))) |
203 (funcall (gnus-get-function method 'request-article) | 203 (funcall (gnus-get-function method 'request-article) |
204 article nil (nth 1 method) buffer))))) | 204 article nil (nth 1 method) buffer))))) |
213 'nnvirtual "Can't open server where %s exists" cgroup)) | 213 'nnvirtual "Can't open server where %s exists" cgroup)) |
214 ((not (gnus-request-group cgroup t)) | 214 ((not (gnus-request-group cgroup t)) |
215 (nnheader-report 'nnvirtual "Can't open component group %s" cgroup)) | 215 (nnheader-report 'nnvirtual "Can't open component group %s" cgroup)) |
216 (t | 216 (t |
217 (setq nnvirtual-last-accessed-component-group cgroup) | 217 (setq nnvirtual-last-accessed-component-group cgroup) |
218 (if buffer | 218 (if buffer |
219 (save-excursion | 219 (save-excursion |
220 (set-buffer buffer) | 220 (set-buffer buffer) |
221 (gnus-request-article-this-buffer (cdr amap) cgroup)) | 221 (gnus-request-article-this-buffer (cdr amap) cgroup)) |
222 (gnus-request-article (cdr amap) cgroup)))))))) | 222 (gnus-request-article (cdr amap) cgroup)))))))) |
223 | 223 |
260 (t | 260 (t |
261 (when (or (not dont-check) | 261 (when (or (not dont-check) |
262 nnvirtual-always-rescan) | 262 nnvirtual-always-rescan) |
263 (nnvirtual-create-mapping)) | 263 (nnvirtual-create-mapping)) |
264 (setq nnvirtual-current-group group) | 264 (setq nnvirtual-current-group group) |
265 (nnheader-insert "211 %d 1 %d %s\n" | 265 (nnheader-insert "211 %d 1 %d %s\n" |
266 nnvirtual-mapping-len nnvirtual-mapping-len group)))) | 266 nnvirtual-mapping-len nnvirtual-mapping-len group)))) |
267 | 267 |
268 | 268 |
269 (deffoo nnvirtual-request-type (group &optional article) | 269 (deffoo nnvirtual-request-type (group &optional article) |
270 (if (not article) | 270 (if (not article) |
282 (= mark nmark) | 282 (= mark nmark) |
283 (gnus-group-auto-expirable-p cgroup)) | 283 (gnus-group-auto-expirable-p cgroup)) |
284 (setq mark gnus-expirable-mark))) | 284 (setq mark gnus-expirable-mark))) |
285 mark) | 285 mark) |
286 | 286 |
287 | 287 |
288 (deffoo nnvirtual-close-group (group &optional server) | 288 (deffoo nnvirtual-close-group (group &optional server) |
289 (when (and (nnvirtual-possibly-change-server server) | 289 (when (and (nnvirtual-possibly-change-server server) |
290 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) | 290 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) |
291 (nnvirtual-update-read-and-marked t t)) | 291 (nnvirtual-update-read-and-marked t t)) |
292 t) | 292 t) |
293 | 293 |
294 | 294 |
295 (deffoo nnvirtual-request-list (&optional server) | 295 (deffoo nnvirtual-request-list (&optional server) |
296 (nnheader-report 'nnvirtual "LIST is not implemented.")) | 296 (nnheader-report 'nnvirtual "LIST is not implemented.")) |
297 | 297 |
298 | 298 |
315 (setcar (nthcdr 3 info) nnvirtual-mapping-marks) | 315 (setcar (nthcdr 3 info) nnvirtual-mapping-marks) |
316 (when nnvirtual-mapping-marks | 316 (when nnvirtual-mapping-marks |
317 (setcdr (nthcdr 2 info) (list nnvirtual-mapping-marks)))) | 317 (setcdr (nthcdr 2 info) (list nnvirtual-mapping-marks)))) |
318 (setq nnvirtual-info-installed t)) | 318 (setq nnvirtual-info-installed t)) |
319 t)) | 319 t)) |
320 | 320 |
321 | 321 |
322 (deffoo nnvirtual-catchup-group (group &optional server all) | 322 (deffoo nnvirtual-catchup-group (group &optional server all) |
323 (when (and (nnvirtual-possibly-change-server server) | 323 (when (and (nnvirtual-possibly-change-server server) |
324 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) | 324 (not (gnus-ephemeral-group-p (nnvirtual-current-group)))) |
325 ;; copy over existing marks first, in case they set anything | 325 ;; copy over existing marks first, in case they set anything |
407 "Copy marks from the virtual group to the component groups. | 407 "Copy marks from the virtual group to the component groups. |
408 If READ-P is not nil, update the (un)read status of the components. | 408 If READ-P is not nil, update the (un)read status of the components. |
409 If UPDATE-P is not nil, call gnus-group-update-group on the components." | 409 If UPDATE-P is not nil, call gnus-group-update-group on the components." |
410 (when nnvirtual-current-group | 410 (when nnvirtual-current-group |
411 (let ((unreads (and read-p | 411 (let ((unreads (and read-p |
412 (nnvirtual-partition-sequence | 412 (nnvirtual-partition-sequence |
413 (gnus-list-of-unread-articles | 413 (gnus-list-of-unread-articles |
414 (nnvirtual-current-group))))) | 414 (nnvirtual-current-group))))) |
415 (type-marks (mapcar (lambda (ml) | 415 (type-marks (mapcar (lambda (ml) |
416 (cons (car ml) | 416 (cons (car ml) |
417 (nnvirtual-partition-sequence (cdr ml)))) | 417 (nnvirtual-partition-sequence (cdr ml)))) |
418 (gnus-info-marks (gnus-get-info | 418 (gnus-info-marks (gnus-get-info |
432 (setq groups nnvirtual-component-groups) | 432 (setq groups nnvirtual-component-groups) |
433 (while groups | 433 (while groups |
434 (when (and (setq info (gnus-get-info (pop groups))) | 434 (when (and (setq info (gnus-get-info (pop groups))) |
435 (gnus-info-marks info)) | 435 (gnus-info-marks info)) |
436 (gnus-info-set-marks info nil))) | 436 (gnus-info-set-marks info nil))) |
437 | 437 |
438 ;; Ok, currently type-marks is an assq list with keys of a mark type, | 438 ;; Ok, currently type-marks is an assq list with keys of a mark type, |
439 ;; with data of an assq list with keys of component group names | 439 ;; with data of an assq list with keys of component group names |
440 ;; and the articles which correspond to that key/group pair. | 440 ;; and the articles which correspond to that key/group pair. |
441 (while (setq mark (pop type-marks)) | 441 (while (setq mark (pop type-marks)) |
442 (setq type (car mark)) | 442 (setq type (car mark)) |
443 (setq groups (cdr mark)) | 443 (setq groups (cdr mark)) |
444 (while (setq carticles (pop groups)) | 444 (while (setq carticles (pop groups)) |
445 (gnus-add-marked-articles (car carticles) type (cdr carticles) | 445 (gnus-add-marked-articles (car carticles) type (cdr carticles) |
446 nil t)))) | 446 nil t)))) |
447 | 447 |
448 ;; possibly update the display, it is really slow | 448 ;; possibly update the display, it is really slow |
449 (when update-p | 449 (when update-p |
450 (setq groups nnvirtual-component-groups) | 450 (setq groups nnvirtual-component-groups) |
451 (while groups | 451 (while groups |
452 (gnus-group-update-group (pop groups) t)))))) | 452 (gnus-group-update-group (pop groups) t)))))) |
630 carticles) | 630 carticles) |
631 carticles)) | 631 carticles)) |
632 | 632 |
633 | 633 |
634 (defun nnvirtual-create-mapping () | 634 (defun nnvirtual-create-mapping () |
635 "Build the tables necessary to map between component (group, article) to virtual article. | 635 "Build the tables necessary to map between component (group, article) to virtual article. |
636 Generate the set of read messages and marks for the virtual group | 636 Generate the set of read messages and marks for the virtual group |
637 based on the marks on the component groups." | 637 based on the marks on the component groups." |
638 (let ((cnt 0) | 638 (let ((cnt 0) |
639 (tot 0) | 639 (tot 0) |
640 (M 0) | 640 (M 0) |
676 (setq nnvirtual-mapping-len tot) | 676 (setq nnvirtual-mapping-len tot) |
677 | 677 |
678 | 678 |
679 ;; We want the actives list sorted by size, to build the tables. | 679 ;; We want the actives list sorted by size, to build the tables. |
680 (setq actives (sort actives (lambda (g1 g2) (< (nth 1 g1) (nth 1 g2))))) | 680 (setq actives (sort actives (lambda (g1 g2) (< (nth 1 g1) (nth 1 g2))))) |
681 | 681 |
682 ;; Build the offset table. Largest sized groups are at the front. | 682 ;; Build the offset table. Largest sized groups are at the front. |
683 (setq nnvirtual-mapping-offsets | 683 (setq nnvirtual-mapping-offsets |
684 (vconcat | 684 (vconcat |
685 (nreverse | 685 (nreverse |
686 (mapcar (lambda (entry) | 686 (mapcar (lambda (entry) |
687 (cons (nth 0 entry) | 687 (cons (nth 0 entry) |
688 (- (nth 2 entry) M))) | 688 (- (nth 2 entry) M))) |
689 actives)))) | 689 actives)))) |
690 | 690 |
691 ;; Build the mapping table. | 691 ;; Build the mapping table. |
692 (setq nnvirtual-mapping-table nil) | 692 (setq nnvirtual-mapping-table nil) |
693 (setq actives (mapcar (lambda (entry) (nth 1 entry)) actives)) | 693 (setq actives (mapcar (lambda (entry) (nth 1 entry)) actives)) |
694 (while actives | 694 (while actives |
695 (setq size (car actives)) | 695 (setq size (car actives)) |