Mercurial > emacs
annotate lisp/gnus/nnml.el @ 57974:be8ba6e58a49
(hide-body): Don't hide lines at the top of the file
that precede the first header line.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 06 Nov 2004 12:10:38 +0000 |
parents | cee5a9d8ee71 |
children | dd462aabc959 e23928ac5a97 |
rev | line source |
---|---|
17493 | 1 ;;; nnml.el --- mail spool access for Gnus |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
17493 | 4 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
5 ;; Author: Simon Josefsson <simon@josefsson.org> (adding MARKS) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org> |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
7 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
17493 | 8 ;; Keywords: news, mail |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>. | |
30 ;; For an overview of what the interface functions do, please see the | |
31 ;; Gnus sources. | |
32 | |
33 ;;; Code: | |
34 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
35 (require 'gnus) |
17493 | 36 (require 'nnheader) |
37 (require 'nnmail) | |
38 (require 'nnoo) | |
19494
4280cff25537
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
39 (eval-when-compile (require 'cl)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
40 |
33302
c47be4412cfd
(gnus-sorted-intersection): Autoload.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
41 (eval-and-compile |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
42 (autoload 'gnus-article-unpropagatable-p "gnus-sum")) |
17493 | 43 |
44 (nnoo-declare nnml) | |
45 | |
46 (defvoo nnml-directory message-directory | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19601
diff
changeset
|
47 "Spool directory for the nnml mail backend.") |
17493 | 48 |
49 (defvoo nnml-active-file | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
50 (expand-file-name "active" nnml-directory) |
17493 | 51 "Mail active file.") |
52 | |
53 (defvoo nnml-newsgroups-file | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 (expand-file-name "newsgroups" nnml-directory) |
17493 | 55 "Mail newsgroups description file.") |
56 | |
57 (defvoo nnml-get-new-mail t | |
58 "If non-nil, nnml will check the incoming mail file and split the mail.") | |
59 | |
60 (defvoo nnml-nov-is-evil nil | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
61 "If non-nil, Gnus will never generate and use nov databases for mail spools. |
17493 | 62 Using nov databases will speed up header fetching considerably. |
63 This variable shouldn't be flipped much. If you have, for some reason, | |
64 set this to t, and want to set it to nil again, you should always run | |
65 the `nnml-generate-nov-databases' command. The function will go | |
66 through all nnml directories and generate nov databases for them | |
67 all. This may very well take some time.") | |
68 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
69 (defvoo nnml-marks-is-evil nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
70 "If non-nil, Gnus will never generate and use marks file for mail spools. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
71 Using marks files makes it possible to backup and restore mail groups |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
72 separately from `.newsrc.eld'. If you have, for some reason, set this |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
73 to t, and want to set it to nil again, you should always remove the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
74 corresponding marks file (usually named `.marks' in the nnml group |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
75 directory, but see `nnml-marks-file-name') for the group. Then the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
76 marks file will be regenerated properly by Gnus.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
77 |
17493 | 78 (defvoo nnml-prepare-save-mail-hook nil |
79 "Hook run narrowed to an article before saving.") | |
80 | |
81 (defvoo nnml-inhibit-expiry nil | |
82 "If non-nil, inhibit expiry.") | |
83 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
84 (defvoo nnml-use-compressed-files nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
85 "If non-nil, allow using compressed message files.") |
17493 | 86 |
87 | |
88 | |
89 (defconst nnml-version "nnml 1.0" | |
90 "nnml version.") | |
91 | |
92 (defvoo nnml-nov-file-name ".overview") | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
93 (defvoo nnml-marks-file-name ".marks") |
17493 | 94 |
95 (defvoo nnml-current-directory nil) | |
96 (defvoo nnml-current-group nil) | |
97 (defvoo nnml-status-string "") | |
98 (defvoo nnml-nov-buffer-alist nil) | |
99 (defvoo nnml-group-alist nil) | |
100 (defvoo nnml-active-timestamp nil) | |
101 (defvoo nnml-article-file-alist nil) | |
102 | |
103 (defvoo nnml-generate-active-function 'nnml-generate-active-info) | |
104 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
105 (defvar nnml-nov-buffer-file-name nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
106 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
107 (defvoo nnml-file-coding-system nnmail-file-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
108 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
109 (defvoo nnml-marks nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
110 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
111 (defvar nnml-marks-modtime (gnus-make-hashtable)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
112 |
17493 | 113 |
114 ;;; Interface functions. | |
115 | |
116 (nnoo-define-basics nnml) | |
117 | |
118 (deffoo nnml-retrieve-headers (sequence &optional group server fetch-old) | |
119 (when (nnml-possibly-change-directory group server) | |
120 (save-excursion | |
121 (set-buffer nntp-server-buffer) | |
122 (erase-buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
123 (let* ((file nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
124 (number (length sequence)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
125 (count 0) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
126 (file-name-coding-system nnmail-pathname-coding-system) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
127 beg article) |
17493 | 128 (if (stringp (car sequence)) |
129 'headers | |
130 (if (nnml-retrieve-headers-with-nov sequence fetch-old) | |
131 'nov | |
132 (while sequence | |
133 (setq article (car sequence)) | |
134 (setq file (nnml-article-to-file article)) | |
135 (when (and file | |
136 (file-exists-p file) | |
137 (not (file-directory-p file))) | |
138 (insert (format "221 %d Article retrieved.\n" article)) | |
139 (setq beg (point)) | |
140 (nnheader-insert-head file) | |
141 (goto-char beg) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
142 (if (re-search-forward "\n\r?\n" nil t) |
17493 | 143 (forward-char -1) |
144 (goto-char (point-max)) | |
145 (insert "\n\n")) | |
146 (insert ".\n") | |
147 (delete-region (point) (point-max))) | |
148 (setq sequence (cdr sequence)) | |
149 (setq count (1+ count)) | |
150 (and (numberp nnmail-large-newsgroup) | |
151 (> number nnmail-large-newsgroup) | |
152 (zerop (% count 20)) | |
153 (nnheader-message 6 "nnml: Receiving headers... %d%%" | |
154 (/ (* count 100) number)))) | |
155 | |
156 (and (numberp nnmail-large-newsgroup) | |
157 (> number nnmail-large-newsgroup) | |
158 (nnheader-message 6 "nnml: Receiving headers...done")) | |
159 | |
160 (nnheader-fold-continuation-lines) | |
161 'headers)))))) | |
162 | |
163 (deffoo nnml-open-server (server &optional defs) | |
164 (nnoo-change-server 'nnml server defs) | |
165 (when (not (file-exists-p nnml-directory)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
166 (ignore-errors (make-directory nnml-directory t))) |
17493 | 167 (cond |
168 ((not (file-exists-p nnml-directory)) | |
169 (nnml-close-server) | |
170 (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory)) | |
171 ((not (file-directory-p (file-truename nnml-directory))) | |
172 (nnml-close-server) | |
173 (nnheader-report 'nnml "Not a directory: %s" nnml-directory)) | |
174 (t | |
175 (nnheader-report 'nnml "Opened server %s using directory %s" | |
176 server nnml-directory) | |
177 t))) | |
178 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
179 (deffoo nnml-request-regenerate (server) |
17493 | 180 (nnml-possibly-change-directory nil server) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
181 (nnml-generate-nov-databases server) |
17493 | 182 t) |
183 | |
184 (deffoo nnml-request-article (id &optional group server buffer) | |
185 (nnml-possibly-change-directory group server) | |
186 (let* ((nntp-server-buffer (or buffer nntp-server-buffer)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
187 (file-name-coding-system nnmail-pathname-coding-system) |
17493 | 188 path gpath group-num) |
189 (if (stringp id) | |
190 (when (and (setq group-num (nnml-find-group-number id)) | |
191 (cdr | |
192 (assq (cdr group-num) | |
193 (nnheader-article-to-file-alist | |
194 (setq gpath | |
195 (nnmail-group-pathname | |
196 (car group-num) | |
197 nnml-directory)))))) | |
198 (setq path (concat gpath (int-to-string (cdr group-num))))) | |
199 (setq path (nnml-article-to-file id))) | |
200 (cond | |
201 ((not path) | |
202 (nnheader-report 'nnml "No such article: %s" id)) | |
203 ((not (file-exists-p path)) | |
204 (nnheader-report 'nnml "No such file: %s" path)) | |
205 ((file-directory-p path) | |
206 (nnheader-report 'nnml "File is a directory: %s" path)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
207 ((not (save-excursion (let ((nnmail-file-coding-system |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
208 nnml-file-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
209 (nnmail-find-file path)))) |
17493 | 210 (nnheader-report 'nnml "Couldn't read file: %s" path)) |
211 (t | |
212 (nnheader-report 'nnml "Article %s retrieved" id) | |
213 ;; We return the article number. | |
214 (cons (if group-num (car group-num) group) | |
215 (string-to-int (file-name-nondirectory path))))))) | |
216 | |
217 (deffoo nnml-request-group (group &optional server dont-check) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
218 (let ((file-name-coding-system nnmail-pathname-coding-system)) |
19601
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
219 (cond |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
220 ((not (nnml-possibly-change-directory group server)) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
221 (nnheader-report 'nnml "Invalid group (no such directory)")) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
222 ((not (file-exists-p nnml-current-directory)) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
223 (nnheader-report 'nnml "Directory %s does not exist" |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
224 nnml-current-directory)) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
225 ((not (file-directory-p nnml-current-directory)) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
226 (nnheader-report 'nnml "%s is not a directory" nnml-current-directory)) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
227 (dont-check |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
228 (nnheader-report 'nnml "Group %s selected" group) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
229 t) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
230 (t |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
231 (nnheader-re-read-dir nnml-current-directory) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
232 (nnmail-activate 'nnml) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
233 (let ((active (nth 1 (assoc group nnml-group-alist)))) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
234 (if (not active) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
235 (nnheader-report 'nnml "No such group: %s" group) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
236 (nnheader-report 'nnml "Selected group %s" group) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
237 (nnheader-insert "211 %d %d %d %s\n" |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
238 (max (1+ (- (cdr active) (car active))) 0) |
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
239 (car active) (cdr active) group))))))) |
17493 | 240 |
241 (deffoo nnml-request-scan (&optional group server) | |
242 (setq nnml-article-file-alist nil) | |
243 (nnml-possibly-change-directory group server) | |
244 (nnmail-get-new-mail 'nnml 'nnml-save-nov nnml-directory group)) | |
245 | |
246 (deffoo nnml-close-group (group &optional server) | |
247 (setq nnml-article-file-alist nil) | |
248 t) | |
249 | |
250 (deffoo nnml-request-create-group (group &optional server args) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
251 (nnml-possibly-change-directory nil server) |
17493 | 252 (nnmail-activate 'nnml) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
253 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
254 ((assoc group nnml-group-alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
255 t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
256 ((and (file-exists-p (nnmail-group-pathname group nnml-directory)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
257 (not (file-directory-p (nnmail-group-pathname group nnml-directory)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
258 (nnheader-report 'nnml "%s is a file" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
259 (nnmail-group-pathname group nnml-directory))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
260 (t |
17493 | 261 (let (active) |
262 (push (list group (setq active (cons 1 0))) | |
263 nnml-group-alist) | |
264 (nnml-possibly-create-directory group) | |
265 (nnml-possibly-change-directory group server) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
266 (let ((articles (nnml-directory-articles nnml-current-directory))) |
17493 | 267 (when articles |
268 (setcar active (apply 'min articles)) | |
269 (setcdr active (apply 'max articles)))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
270 (nnmail-save-active nnml-group-alist nnml-active-file) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
271 t)))) |
17493 | 272 |
273 (deffoo nnml-request-list (&optional server) | |
274 (save-excursion | |
19601
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
275 (let ((nnmail-file-coding-system nnmail-active-file-coding-system) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
276 (file-name-coding-system nnmail-pathname-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
277 (nnmail-find-file nnml-active-file)) |
17493 | 278 (setq nnml-group-alist (nnmail-get-active)) |
279 t)) | |
280 | |
281 (deffoo nnml-request-newgroups (date &optional server) | |
282 (nnml-request-list server)) | |
283 | |
284 (deffoo nnml-request-list-newsgroups (&optional server) | |
285 (save-excursion | |
286 (nnmail-find-file nnml-newsgroups-file))) | |
287 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
288 (deffoo nnml-request-expire-articles (articles group &optional server force) |
17493 | 289 (nnml-possibly-change-directory group server) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
290 (let ((active-articles |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
291 (nnml-directory-articles nnml-current-directory)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
292 (is-old t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
293 article rest mod-time number) |
17493 | 294 (nnmail-activate 'nnml) |
295 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
296 (setq active-articles (sort active-articles '<)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
297 ;; Articles not listed in active-articles are already gone, |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
298 ;; so don't try to expire them. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
299 (setq articles (gnus-sorted-intersection articles active-articles)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
300 |
17493 | 301 (while (and articles is-old) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
302 (if (and (setq article (nnml-article-to-file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
303 (setq number (pop articles)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
304 (setq mod-time (nth 5 (file-attributes article))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
305 (nnml-deletable-article-p group number) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
306 (setq is-old (nnmail-expired-article-p group mod-time force |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
307 nnml-inhibit-expiry))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
308 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
309 ;; Allow a special target group. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
310 (unless (eq nnmail-expiry-target 'delete) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
311 (with-temp-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
312 (nnml-request-article number group server (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
313 (let (nnml-current-directory |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
314 nnml-current-group |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
315 nnml-article-file-alist) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
316 (nnmail-expiry-target-group nnmail-expiry-target group))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
317 ;; Maybe directory is changed during nnmail-expiry-target-group. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
318 (nnml-possibly-change-directory group server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
319 (nnheader-message 5 "Deleting article %s in %s" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
320 number group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
321 (condition-case () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
322 (funcall nnmail-delete-file-function article) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
323 (file-error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
324 (push number rest))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
325 (setq active-articles (delq number active-articles)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
326 (nnml-nov-delete-article group number)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
327 (push number rest))) |
17493 | 328 (let ((active (nth 1 (assoc group nnml-group-alist)))) |
329 (when active | |
330 (setcar active (or (and active-articles | |
331 (apply 'min active-articles)) | |
332 (1+ (cdr active))))) | |
333 (nnmail-save-active nnml-group-alist nnml-active-file)) | |
334 (nnml-save-nov) | |
335 (nconc rest articles))) | |
336 | |
337 (deffoo nnml-request-move-article | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
338 (article group server accept-form &optional last) |
17493 | 339 (let ((buf (get-buffer-create " *nnml move*")) |
340 result) | |
341 (nnml-possibly-change-directory group server) | |
342 (nnml-update-file-alist) | |
343 (and | |
344 (nnml-deletable-article-p group article) | |
345 (nnml-request-article article group server) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44453
diff
changeset
|
346 (let (nnml-current-directory |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44453
diff
changeset
|
347 nnml-current-group |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
348 nnml-article-file-alist) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
349 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
350 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
351 (insert-buffer-substring nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
352 (setq result (eval accept-form)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
353 (kill-buffer (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
354 result)) |
17493 | 355 (progn |
356 (nnml-possibly-change-directory group server) | |
357 (condition-case () | |
358 (funcall nnmail-delete-file-function | |
359 (nnml-article-to-file article)) | |
360 (file-error nil)) | |
361 (nnml-nov-delete-article group article) | |
362 (when last | |
363 (nnml-save-nov) | |
364 (nnmail-save-active nnml-group-alist nnml-active-file)))) | |
365 result)) | |
366 | |
367 (deffoo nnml-request-accept-article (group &optional server last) | |
368 (nnml-possibly-change-directory group server) | |
369 (nnmail-check-syntax) | |
370 (let (result) | |
371 (when nnmail-cache-accepted-message-ids | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
372 (nnmail-cache-insert (nnmail-fetch-field "message-id") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
373 group |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
374 (nnmail-fetch-field "subject") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
375 (nnmail-fetch-field "from"))) |
17493 | 376 (if (stringp group) |
377 (and | |
378 (nnmail-activate 'nnml) | |
379 (setq result (car (nnml-save-mail | |
380 (list (cons group (nnml-active-number group)))))) | |
381 (progn | |
382 (nnmail-save-active nnml-group-alist nnml-active-file) | |
383 (and last (nnml-save-nov)))) | |
384 (and | |
385 (nnmail-activate 'nnml) | |
386 (if (and (not (setq result (nnmail-article-group 'nnml-active-number))) | |
387 (yes-or-no-p "Moved to `junk' group; delete article? ")) | |
388 (setq result 'junk) | |
389 (setq result (car (nnml-save-mail result)))) | |
390 (when last | |
391 (nnmail-save-active nnml-group-alist nnml-active-file) | |
392 (when nnmail-cache-accepted-message-ids | |
393 (nnmail-cache-close)) | |
394 (nnml-save-nov)))) | |
395 result)) | |
396 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
397 (deffoo nnml-request-post (&optional server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
398 (nnmail-do-request-post 'nnml-request-accept-article server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
399 |
17493 | 400 (deffoo nnml-request-replace-article (article group buffer) |
401 (nnml-possibly-change-directory group) | |
402 (save-excursion | |
403 (set-buffer buffer) | |
404 (nnml-possibly-create-directory group) | |
405 (let ((chars (nnmail-insert-lines)) | |
406 (art (concat (int-to-string article) "\t")) | |
407 headers) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
408 (when (ignore-errors |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
409 (nnmail-write-region |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
410 (point-min) (point-max) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
411 (or (nnml-article-to-file article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
412 (expand-file-name (int-to-string article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
413 nnml-current-directory)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
414 nil (if (nnheader-be-verbose 5) nil 'nomesg)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
415 t) |
17493 | 416 (setq headers (nnml-parse-head chars article)) |
417 ;; Replace the NOV line in the NOV file. | |
418 (save-excursion | |
419 (set-buffer (nnml-open-nov group)) | |
420 (goto-char (point-min)) | |
421 (if (or (looking-at art) | |
422 (search-forward (concat "\n" art) nil t)) | |
423 ;; Delete the old NOV line. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
424 (gnus-delete-line) |
17493 | 425 ;; The line isn't here, so we have to find out where |
426 ;; we should insert it. (This situation should never | |
427 ;; occur, but one likes to make sure...) | |
428 (while (and (looking-at "[0-9]+\t") | |
429 (< (string-to-int | |
430 (buffer-substring | |
431 (match-beginning 0) (match-end 0))) | |
432 article) | |
433 (zerop (forward-line 1))))) | |
434 (beginning-of-line) | |
435 (nnheader-insert-nov headers) | |
436 (nnml-save-nov) | |
437 t))))) | |
438 | |
439 (deffoo nnml-request-delete-group (group &optional force server) | |
440 (nnml-possibly-change-directory group server) | |
441 (when force | |
442 ;; Delete all articles in GROUP. | |
443 (let ((articles | |
444 (directory-files | |
445 nnml-current-directory t | |
446 (concat nnheader-numerical-short-files | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
447 "\\|" (regexp-quote nnml-nov-file-name) "$" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
448 "\\|" (regexp-quote nnml-marks-file-name) "$"))) |
17493 | 449 article) |
450 (while articles | |
451 (setq article (pop articles)) | |
452 (when (file-writable-p article) | |
453 (nnheader-message 5 "Deleting article %s in %s..." article group) | |
454 (funcall nnmail-delete-file-function article)))) | |
455 ;; Try to delete the directory itself. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
456 (ignore-errors (delete-directory nnml-current-directory))) |
17493 | 457 ;; Remove the group from all structures. |
458 (setq nnml-group-alist | |
459 (delq (assoc group nnml-group-alist) nnml-group-alist) | |
460 nnml-current-group nil | |
461 nnml-current-directory nil) | |
462 ;; Save the active file. | |
463 (nnmail-save-active nnml-group-alist nnml-active-file) | |
464 t) | |
465 | |
466 (deffoo nnml-request-rename-group (group new-name &optional server) | |
467 (nnml-possibly-change-directory group server) | |
468 (let ((new-dir (nnmail-group-pathname new-name nnml-directory)) | |
469 (old-dir (nnmail-group-pathname group nnml-directory))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
470 (when (ignore-errors |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
471 (make-directory new-dir t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
472 t) |
17493 | 473 ;; We move the articles file by file instead of renaming |
474 ;; the directory -- there may be subgroups in this group. | |
475 ;; One might be more clever, I guess. | |
476 (let ((files (nnheader-article-to-file-alist old-dir))) | |
477 (while files | |
478 (rename-file | |
479 (concat old-dir (cdar files)) | |
480 (concat new-dir (cdar files))) | |
481 (pop files))) | |
482 ;; Move .overview file. | |
483 (let ((overview (concat old-dir nnml-nov-file-name))) | |
484 (when (file-exists-p overview) | |
485 (rename-file overview (concat new-dir nnml-nov-file-name)))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
486 ;; Move .marks file. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
487 (let ((marks (concat old-dir nnml-marks-file-name))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
488 (when (file-exists-p marks) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
489 (rename-file marks (concat new-dir nnml-marks-file-name)))) |
17493 | 490 (when (<= (length (directory-files old-dir)) 2) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
491 (ignore-errors (delete-directory old-dir))) |
17493 | 492 ;; That went ok, so we change the internal structures. |
493 (let ((entry (assoc group nnml-group-alist))) | |
494 (when entry | |
495 (setcar entry new-name)) | |
496 (setq nnml-current-directory nil | |
497 nnml-current-group nil) | |
498 ;; Save the new group alist. | |
499 (nnmail-save-active nnml-group-alist nnml-active-file) | |
500 t)))) | |
501 | |
502 (deffoo nnml-set-status (article name value &optional group server) | |
503 (nnml-possibly-change-directory group server) | |
504 (let ((file (nnml-article-to-file article))) | |
505 (cond | |
506 ((not (file-exists-p file)) | |
507 (nnheader-report 'nnml "File %s does not exist" file)) | |
508 (t | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
509 (with-temp-file file |
17493 | 510 (nnheader-insert-file-contents file) |
511 (nnmail-replace-status name value)) | |
512 t)))) | |
513 | |
514 | |
515 ;;; Internal functions. | |
516 | |
517 (defun nnml-article-to-file (article) | |
518 (nnml-update-file-alist) | |
519 (let (file) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
520 (if (setq file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
521 (if nnml-use-compressed-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
522 (cdr (assq article nnml-article-file-alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
523 (number-to-string article))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
524 (expand-file-name file nnml-current-directory) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
525 (when (not nnheader-directory-files-is-safe) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
526 ;; Just to make sure nothing went wrong when reading over NFS -- |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
527 ;; check once more. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
528 (when (file-exists-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
529 (setq file (expand-file-name (number-to-string article) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
530 nnml-current-directory))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
531 (nnml-update-file-alist t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
532 file))))) |
17493 | 533 |
534 (defun nnml-deletable-article-p (group article) | |
535 "Say whether ARTICLE in GROUP can be deleted." | |
536 (let (path) | |
537 (when (setq path (nnml-article-to-file article)) | |
538 (when (file-writable-p path) | |
539 (or (not nnmail-keep-last-article) | |
540 (not (eq (cdr (nth 1 (assoc group nnml-group-alist))) | |
541 article))))))) | |
542 | |
543 ;; Find an article number in the current group given the Message-ID. | |
544 (defun nnml-find-group-number (id) | |
545 (save-excursion | |
546 (set-buffer (get-buffer-create " *nnml id*")) | |
547 (let ((alist nnml-group-alist) | |
548 number) | |
549 ;; We want to look through all .overview files, but we want to | |
550 ;; start with the one in the current directory. It seems most | |
551 ;; likely that the article we are looking for is in that group. | |
552 (if (setq number (nnml-find-id nnml-current-group id)) | |
553 (cons nnml-current-group number) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
554 ;; It wasn't there, so we look through the other groups as well. |
17493 | 555 (while (and (not number) |
556 alist) | |
557 (or (string= (caar alist) nnml-current-group) | |
558 (setq number (nnml-find-id (caar alist) id))) | |
559 (or number | |
560 (setq alist (cdr alist)))) | |
561 (and number | |
562 (cons (caar alist) number)))))) | |
563 | |
564 (defun nnml-find-id (group id) | |
565 (erase-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
566 (let ((nov (expand-file-name nnml-nov-file-name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
567 (nnmail-group-pathname group nnml-directory))) |
17493 | 568 number found) |
569 (when (file-exists-p nov) | |
570 (nnheader-insert-file-contents nov) | |
571 (while (and (not found) | |
572 (search-forward id nil t)) ; We find the ID. | |
573 ;; And the id is in the fourth field. | |
574 (if (not (and (search-backward "\t" nil t 4) | |
575 (not (search-backward"\t" (gnus-point-at-bol) t)))) | |
576 (forward-line 1) | |
577 (beginning-of-line) | |
578 (setq found t) | |
579 ;; We return the article number. | |
580 (setq number | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
581 (ignore-errors (read (current-buffer)))))) |
17493 | 582 number))) |
583 | |
584 (defun nnml-retrieve-headers-with-nov (articles &optional fetch-old) | |
585 (if (or gnus-nov-is-evil nnml-nov-is-evil) | |
586 nil | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
587 (let ((nov (expand-file-name nnml-nov-file-name nnml-current-directory))) |
17493 | 588 (when (file-exists-p nov) |
589 (save-excursion | |
590 (set-buffer nntp-server-buffer) | |
591 (erase-buffer) | |
592 (nnheader-insert-file-contents nov) | |
593 (if (and fetch-old | |
594 (not (numberp fetch-old))) | |
595 t ; Don't remove anything. | |
596 (nnheader-nov-delete-outside-range | |
597 (if fetch-old (max 1 (- (car articles) fetch-old)) | |
598 (car articles)) | |
599 (car (last articles))) | |
600 t)))))) | |
601 | |
602 (defun nnml-possibly-change-directory (group &optional server) | |
603 (when (and server | |
604 (not (nnml-server-opened server))) | |
605 (nnml-open-server server)) | |
606 (if (not group) | |
607 t | |
19601
f929cdcccb60
(nnml-possibly-change-directory): Likewise
Kenichi Handa <handa@m17n.org>
parents:
19494
diff
changeset
|
608 (let ((pathname (nnmail-group-pathname group nnml-directory)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
609 (file-name-coding-system nnmail-pathname-coding-system)) |
17493 | 610 (when (not (equal pathname nnml-current-directory)) |
611 (setq nnml-current-directory pathname | |
612 nnml-current-group group | |
613 nnml-article-file-alist nil)) | |
614 (file-exists-p nnml-current-directory)))) | |
615 | |
616 (defun nnml-possibly-create-directory (group) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
617 (let ((dir (nnmail-group-pathname group nnml-directory))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
618 (unless (file-exists-p dir) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
619 (make-directory (directory-file-name dir) t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
620 (nnheader-message 5 "Creating mail directory %s" dir)))) |
17493 | 621 |
622 (defun nnml-save-mail (group-art) | |
623 "Called narrowed to an article." | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
624 (let (chars headers extension) |
17493 | 625 (setq chars (nnmail-insert-lines)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
626 (setq extension |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
627 (and nnml-use-compressed-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
628 (> chars 1000) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
629 ".gz")) |
17493 | 630 (nnmail-insert-xref group-art) |
631 (run-hooks 'nnmail-prepare-save-mail-hook) | |
632 (run-hooks 'nnml-prepare-save-mail-hook) | |
633 (goto-char (point-min)) | |
634 (while (looking-at "From ") | |
635 (replace-match "X-From-Line: ") | |
636 (forward-line 1)) | |
637 ;; We save the article in all the groups it belongs in. | |
638 (let ((ga group-art) | |
639 first) | |
640 (while ga | |
641 (nnml-possibly-create-directory (caar ga)) | |
642 (let ((file (concat (nnmail-group-pathname | |
643 (caar ga) nnml-directory) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
644 (int-to-string (cdar ga)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
645 extension))) |
17493 | 646 (if first |
647 ;; It was already saved, so we just make a hard link. | |
648 (funcall nnmail-crosspost-link-function first file t) | |
649 ;; Save the article. | |
650 (nnmail-write-region (point-min) (point-max) file nil | |
651 (if (nnheader-be-verbose 5) nil 'nomesg)) | |
652 (setq first file))) | |
653 (setq ga (cdr ga)))) | |
654 ;; Generate a nov line for this article. We generate the nov | |
655 ;; line after saving, because nov generation destroys the | |
656 ;; header. | |
657 (setq headers (nnml-parse-head chars)) | |
658 ;; Output the nov line to all nov databases that should have it. | |
659 (let ((ga group-art)) | |
660 (while ga | |
661 (nnml-add-nov (caar ga) (cdar ga) headers) | |
662 (setq ga (cdr ga)))) | |
663 group-art)) | |
664 | |
665 (defun nnml-active-number (group) | |
666 "Compute the next article number in GROUP." | |
667 (let ((active (cadr (assoc group nnml-group-alist)))) | |
668 ;; The group wasn't known to nnml, so we just create an active | |
669 ;; entry for it. | |
670 (unless active | |
671 ;; Perhaps the active file was corrupt? See whether | |
672 ;; there are any articles in this group. | |
673 (nnml-possibly-create-directory group) | |
674 (nnml-possibly-change-directory group) | |
675 (unless nnml-article-file-alist | |
676 (setq nnml-article-file-alist | |
677 (sort | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
678 (nnml-current-group-article-to-file-alist) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
679 'car-less-than-car))) |
17493 | 680 (setq active |
681 (if nnml-article-file-alist | |
682 (cons (caar nnml-article-file-alist) | |
683 (caar (last nnml-article-file-alist))) | |
684 (cons 1 0))) | |
685 (push (list group active) nnml-group-alist)) | |
686 (setcdr active (1+ (cdr active))) | |
687 (while (file-exists-p | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
688 (expand-file-name (int-to-string (cdr active)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
689 (nnmail-group-pathname group nnml-directory))) |
17493 | 690 (setcdr active (1+ (cdr active)))) |
691 (cdr active))) | |
692 | |
693 (defun nnml-add-nov (group article headers) | |
694 "Add a nov line for the GROUP base." | |
695 (save-excursion | |
696 (set-buffer (nnml-open-nov group)) | |
697 (goto-char (point-max)) | |
698 (mail-header-set-number headers article) | |
699 (nnheader-insert-nov headers))) | |
700 | |
701 (defsubst nnml-header-value () | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
702 (buffer-substring (match-end 0) (gnus-point-at-eol))) |
17493 | 703 |
704 (defun nnml-parse-head (chars &optional number) | |
705 "Parse the head of the current buffer." | |
706 (save-excursion | |
707 (save-restriction | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
708 (unless (zerop (buffer-size)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
709 (narrow-to-region |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
710 (goto-char (point-min)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
711 (if (re-search-forward "\n\r?\n" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
712 (1- (point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
713 (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
714 (let ((headers (nnheader-parse-naked-head))) |
17493 | 715 (mail-header-set-chars headers chars) |
716 (mail-header-set-number headers number) | |
717 headers)))) | |
718 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
719 (defun nnml-get-nov-buffer (group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
720 (let ((buffer (get-buffer-create (format " *nnml overview %s*" group)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
721 (save-excursion |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
722 (set-buffer buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
723 (set (make-local-variable 'nnml-nov-buffer-file-name) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
724 (expand-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
725 nnml-nov-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
726 (nnmail-group-pathname group nnml-directory))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
727 (erase-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
728 (when (file-exists-p nnml-nov-buffer-file-name) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
729 (nnheader-insert-file-contents nnml-nov-buffer-file-name))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
730 buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
731 |
17493 | 732 (defun nnml-open-nov (group) |
733 (or (cdr (assoc group nnml-nov-buffer-alist)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
734 (let ((buffer (nnml-get-nov-buffer group))) |
17493 | 735 (push (cons group buffer) nnml-nov-buffer-alist) |
736 buffer))) | |
737 | |
738 (defun nnml-save-nov () | |
739 (save-excursion | |
740 (while nnml-nov-buffer-alist | |
741 (when (buffer-name (cdar nnml-nov-buffer-alist)) | |
742 (set-buffer (cdar nnml-nov-buffer-alist)) | |
743 (when (buffer-modified-p) | |
44453
b62714db7e04
(nnml-save-nov, nnml-generate-nov-file): Don't hardcode point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33302
diff
changeset
|
744 (nnmail-write-region (point-min) (point-max) |
b62714db7e04
(nnml-save-nov, nnml-generate-nov-file): Don't hardcode point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33302
diff
changeset
|
745 nnml-nov-buffer-file-name nil 'nomesg)) |
17493 | 746 (set-buffer-modified-p nil) |
747 (kill-buffer (current-buffer))) | |
748 (setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist))))) | |
749 | |
750 ;;;###autoload | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
751 (defun nnml-generate-nov-databases (&optional server) |
17493 | 752 "Generate NOV databases in all nnml directories." |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
753 (interactive (list (or (nnoo-current-server 'nnml) ""))) |
17493 | 754 ;; Read the active file to make sure we don't re-use articles |
755 ;; numbers in empty groups. | |
756 (nnmail-activate 'nnml) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
757 (unless (nnml-server-opened server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
758 (nnml-open-server server)) |
17493 | 759 (setq nnml-directory (expand-file-name nnml-directory)) |
760 ;; Recurse down the directories. | |
761 (nnml-generate-nov-databases-1 nnml-directory nil t) | |
762 ;; Save the active file. | |
763 (nnmail-save-active nnml-group-alist nnml-active-file)) | |
764 | |
765 (defun nnml-generate-nov-databases-1 (dir &optional seen no-active) | |
766 "Regenerate the NOV database in DIR." | |
767 (interactive "DRegenerate NOV in: ") | |
768 (setq dir (file-name-as-directory dir)) | |
769 ;; Only scan this sub-tree if we haven't been here yet. | |
770 (unless (member (file-truename dir) seen) | |
771 (push (file-truename dir) seen) | |
772 ;; We descend recursively | |
773 (let ((dirs (directory-files dir t nil t)) | |
774 dir) | |
775 (while (setq dir (pop dirs)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
776 (when (and (not (string-match "^\\." (file-name-nondirectory dir))) |
17493 | 777 (file-directory-p dir)) |
778 (nnml-generate-nov-databases-1 dir seen)))) | |
779 ;; Do this directory. | |
780 (let ((files (sort (nnheader-article-to-file-alist dir) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
781 'car-less-than-car))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
782 (if (not files) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
783 (let* ((group (nnheader-file-to-group |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
784 (directory-file-name dir) nnml-directory)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
785 (info (cadr (assoc group nnml-group-alist)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
786 (when info |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19994
diff
changeset
|
787 (setcar info (1+ (cdr info))))) |
17493 | 788 (funcall nnml-generate-active-function dir) |
789 ;; Generate the nov file. | |
790 (nnml-generate-nov-file dir files) | |
791 (unless no-active | |
792 (nnmail-save-active nnml-group-alist nnml-active-file)))))) | |
793 | |
33302
c47be4412cfd
(gnus-sorted-intersection): Autoload.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
794 (eval-when-compile (defvar files)) |
17493 | 795 (defun nnml-generate-active-info (dir) |
796 ;; Update the active info for this group. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
797 (let* ((group (nnheader-file-to-group |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
798 (directory-file-name dir) nnml-directory)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
799 (entry (assoc group nnml-group-alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
800 (last (or (caadr entry) 0))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
801 (setq nnml-group-alist (delq entry nnml-group-alist)) |
17493 | 802 (push (list group |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
803 (cons (or (caar files) (1+ last)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
804 (max last |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
805 (or (let ((f files)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
806 (while (cdr f) (setq f (cdr f))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
807 (caar f)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
808 0)))) |
17493 | 809 nnml-group-alist))) |
810 | |
811 (defun nnml-generate-nov-file (dir files) | |
812 (let* ((dir (file-name-as-directory dir)) | |
813 (nov (concat dir nnml-nov-file-name)) | |
814 (nov-buffer (get-buffer-create " *nov*")) | |
815 chars file headers) | |
816 (save-excursion | |
817 ;; Init the nov buffer. | |
818 (set-buffer nov-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
819 (buffer-disable-undo) |
17493 | 820 (erase-buffer) |
821 (set-buffer nntp-server-buffer) | |
822 ;; Delete the old NOV file. | |
823 (when (file-exists-p nov) | |
824 (funcall nnmail-delete-file-function nov)) | |
825 (while files | |
826 (unless (file-directory-p (setq file (concat dir (cdar files)))) | |
827 (erase-buffer) | |
828 (nnheader-insert-file-contents file) | |
829 (narrow-to-region | |
830 (goto-char (point-min)) | |
831 (progn | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
832 (re-search-forward "\n\r?\n" nil t) |
17493 | 833 (setq chars (- (point-max) (point))) |
44453
b62714db7e04
(nnml-save-nov, nnml-generate-nov-file): Don't hardcode point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33302
diff
changeset
|
834 (max (point-min) (1- (point))))) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19601
diff
changeset
|
835 (unless (zerop (buffer-size)) |
17493 | 836 (goto-char (point-min)) |
837 (setq headers (nnml-parse-head chars (caar files))) | |
838 (save-excursion | |
839 (set-buffer nov-buffer) | |
840 (goto-char (point-max)) | |
841 (nnheader-insert-nov headers))) | |
842 (widen)) | |
843 (setq files (cdr files))) | |
844 (save-excursion | |
845 (set-buffer nov-buffer) | |
44453
b62714db7e04
(nnml-save-nov, nnml-generate-nov-file): Don't hardcode point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33302
diff
changeset
|
846 (nnmail-write-region (point-min) (point-max) nov nil 'nomesg) |
17493 | 847 (kill-buffer (current-buffer)))))) |
848 | |
849 (defun nnml-nov-delete-article (group article) | |
850 (save-excursion | |
851 (set-buffer (nnml-open-nov group)) | |
852 (when (nnheader-find-nov-line article) | |
853 (delete-region (point) (progn (forward-line 1) (point))) | |
854 (when (bobp) | |
855 (let ((active (cadr (assoc group nnml-group-alist))) | |
856 num) | |
857 (when active | |
858 (if (eobp) | |
859 (setf (car active) (1+ (cdr active))) | |
860 (when (and (setq num (ignore-errors (read (current-buffer)))) | |
861 (numberp num)) | |
862 (setf (car active) num))))))) | |
863 t)) | |
864 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19601
diff
changeset
|
865 (defun nnml-update-file-alist (&optional force) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
866 (when nnml-use-compressed-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
867 (when (or (not nnml-article-file-alist) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
868 force) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
869 (setq nnml-article-file-alist |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
870 (nnml-current-group-article-to-file-alist))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
871 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
872 (defun nnml-directory-articles (dir) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
873 "Return a list of all article files in a directory. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
874 Use the nov database for that directory if available." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
875 (if (or gnus-nov-is-evil nnml-nov-is-evil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
876 (not (file-exists-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
877 (expand-file-name nnml-nov-file-name dir)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
878 (nnheader-directory-articles dir) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
879 ;; build list from .overview if available |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
880 ;; We would use nnml-open-nov, except that nnml-nov-buffer-alist is |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
881 ;; defvoo'd, and we might get called when it hasn't been swapped in. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
882 (save-excursion |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
883 (let ((list nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
884 art |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
885 (buffer (nnml-get-nov-buffer nnml-current-group))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
886 (set-buffer buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
887 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
888 (while (not (eobp)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
889 (setq art (read (current-buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
890 (push art list) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
891 (forward-line 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
892 list)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
893 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
894 (defun nnml-current-group-article-to-file-alist () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
895 "Return an alist of article/file pairs in the current group. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
896 Use the nov database for the current group if available." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
897 (if (or nnml-use-compressed-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
898 gnus-nov-is-evil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
899 nnml-nov-is-evil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
900 (not (file-exists-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
901 (expand-file-name nnml-nov-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
902 nnml-current-directory)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
903 (nnheader-article-to-file-alist nnml-current-directory) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
904 ;; build list from .overview if available |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
905 (save-excursion |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
906 (let ((alist nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
907 (buffer (nnml-get-nov-buffer nnml-current-group)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
908 art) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
909 (set-buffer buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
910 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
911 (while (not (eobp)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
912 (setq art (read (current-buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
913 ;; assume file name is unadorned (ie. not compressed etc) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
914 (push (cons art (int-to-string art)) alist) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
915 (forward-line 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
916 alist)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
917 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
918 (deffoo nnml-request-set-mark (group actions &optional server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
919 (nnml-possibly-change-directory group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
920 (unless nnml-marks-is-evil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
921 (nnml-open-marks group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
922 (dolist (action actions) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
923 (let ((range (nth 0 action)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
924 (what (nth 1 action)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
925 (marks (nth 2 action))) |
57265
cee5a9d8ee71
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-580
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
926 (assert (or (eq what 'add) (eq what 'del)) nil |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
927 "Unknown request-set-mark action: %s" what) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
928 (dolist (mark marks) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
929 (setq nnml-marks (gnus-update-alist-soft |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
930 mark |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
931 (funcall (if (eq what 'add) 'gnus-range-add |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
932 'gnus-remove-from-range) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
933 (cdr (assoc mark nnml-marks)) range) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
934 nnml-marks))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
935 (nnml-save-marks group server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
936 nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
937 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
938 (deffoo nnml-request-update-info (group info &optional server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
939 (nnml-possibly-change-directory group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
940 (when (and (not nnml-marks-is-evil) (nnml-marks-changed-p group)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
941 (nnheader-message 8 "Updating marks for %s..." group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
942 (nnml-open-marks group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
943 ;; Update info using `nnml-marks'. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
944 (mapcar (lambda (pred) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
945 (unless (memq (cdr pred) gnus-article-unpropagated-mark-lists) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
946 (gnus-info-set-marks |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
947 info |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
948 (gnus-update-alist-soft |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
949 (cdr pred) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
950 (cdr (assq (cdr pred) nnml-marks)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
951 (gnus-info-marks info)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
952 t))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
953 gnus-article-mark-lists) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
954 (let ((seen (cdr (assq 'read nnml-marks)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
955 (gnus-info-set-read info |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
956 (if (and (integerp (car seen)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
957 (null (cdr seen))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
958 (list (cons (car seen) (car seen))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
959 seen))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
960 (nnheader-message 8 "Updating marks for %s...done" group)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
961 info) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
962 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
963 (defun nnml-marks-changed-p (group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
964 (let ((file (expand-file-name nnml-marks-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
965 (nnmail-group-pathname group nnml-directory)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
966 (if (null (gnus-gethash file nnml-marks-modtime)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
967 t ;; never looked at marks file, assume it has changed |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
968 (not (equal (gnus-gethash file nnml-marks-modtime) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
969 (nth 5 (file-attributes file))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
970 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
971 (defun nnml-save-marks (group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
972 (let ((file-name-coding-system nnmail-pathname-coding-system) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
973 (file (expand-file-name nnml-marks-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
974 (nnmail-group-pathname group nnml-directory)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
975 (condition-case err |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
976 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
977 (nnml-possibly-create-directory group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
978 (with-temp-file file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
979 (erase-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
980 (gnus-prin1 nnml-marks) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
981 (insert "\n")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
982 (gnus-sethash file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
983 (nth 5 (file-attributes file)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
984 nnml-marks-modtime)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
985 (error (or (gnus-yes-or-no-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
986 (format "Could not write to %s (%s). Continue? " file err)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
987 (error "Cannot write to %s (%s)" err)))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
988 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
989 (defun nnml-open-marks (group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
990 (let ((file (expand-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
991 nnml-marks-file-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
992 (nnmail-group-pathname group nnml-directory)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
993 (if (file-exists-p file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
994 (condition-case err |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
995 (with-temp-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
996 (gnus-sethash file (nth 5 (file-attributes file)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
997 nnml-marks-modtime) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
998 (nnheader-insert-file-contents file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
999 (setq nnml-marks (read (current-buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1000 (dolist (el gnus-article-unpropagated-mark-lists) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1001 (setq nnml-marks (gnus-remassoc el nnml-marks)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1002 (error (or (gnus-yes-or-no-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1003 (format "Error reading nnml marks file %s (%s). Continuing will use marks from .newsrc.eld. Continue? " file err)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1004 (error "Cannot read nnml marks file %s (%s)" file err)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1005 ;; User didn't have a .marks file. Probably first time |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1006 ;; user of the .marks stuff. Bootstrap it from .newsrc.eld. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1007 (let ((info (gnus-get-info |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1008 (gnus-group-prefixed-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1009 group |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1010 (gnus-server-to-method (format "nnml:%s" server)))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1011 (nnheader-message 7 "Bootstrapping marks for %s..." group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1012 (setq nnml-marks (gnus-info-marks info)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1013 (push (cons 'read (gnus-info-read info)) nnml-marks) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1014 (dolist (el gnus-article-unpropagated-mark-lists) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1015 (setq nnml-marks (gnus-remassoc el nnml-marks))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1016 (nnml-save-marks group server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1017 (nnheader-message 7 "Bootstrapping marks for %s...done" group))))) |
17493 | 1018 |
1019 (provide 'nnml) | |
1020 | |
52401 | 1021 ;;; arch-tag: 52c97dc3-9735-45de-b439-9e4d23b52004 |
17493 | 1022 ;;; nnml.el ends here |