annotate lisp/gnus/nnvirtual.el @ 30:ec9a17fef872 r19-15b98

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