annotate lisp/gnus/nnfolder.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents ac2d302a0011
children 441bb1e64a06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nnfolder.el --- mail folder access for Gnus
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Scott Byer <byer@mv.us.adobe.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (require 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (require 'nnmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'nnoo)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
34 (require 'cl)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
35 (require 'gnus-util)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (nnoo-declare nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defvoo nnfolder-directory (expand-file-name message-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "The name of the nnfolder directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvoo nnfolder-active-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (nnheader-concat nnfolder-directory "active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "The name of the active file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; I renamed this variable to something more in keeping with the general GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; style. -SLB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvoo nnfolder-ignore-active-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "If non-nil, causes nnfolder to do some extra work in order to determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 the true active ranges of an mbox file. Note that the active file is still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 saved, but it's values are not used. This costs some extra time when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 scanning an mbox when opening it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvoo nnfolder-distrust-mbox nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "If non-nil, causes nnfolder to not trust the user with respect to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 inserting unaccounted for mail in the middle of an mbox file. This can greatly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 slow down scans, which now must scan the entire file for unmarked messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 When nil, scans occur forward from the last marked message, a huge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 time saver for large mailboxes.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvoo nnfolder-newsgroups-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (concat (file-name-as-directory nnfolder-directory) "newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Mail newsgroups description file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvoo nnfolder-get-new-mail t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "If non-nil, nnfolder will check the incoming mail file and split the mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvoo nnfolder-prepare-save-mail-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "Hook run narrowed to an article before saving.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defvoo nnfolder-save-buffer-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 "Hook run before saving the nnfolder mbox buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvoo nnfolder-inhibit-expiry nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "If non-nil, inhibit expiry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defconst nnfolder-version "nnfolder 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "nnfolder version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defconst nnfolder-article-marker "X-Gnus-Article-Number: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "String used to demarcate what the article number for a message is.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defvoo nnfolder-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvoo nnfolder-current-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defvoo nnfolder-status-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defvoo nnfolder-group-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defvoo nnfolder-buffer-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvoo nnfolder-scantime-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; Interface functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (nnoo-define-basics nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (deffoo nnfolder-retrieve-headers (articles &optional group server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (erase-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
103 (let (article art-string start stop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (when nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (stringp (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 'headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq article (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (setq art-string (nnfolder-article-string article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (set-buffer nnfolder-current-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
114 (when (or (search-forward art-string nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
115 ;; Don't search the whole file twice! Also, articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
116 ;; probably have some locality by number, so searching
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
117 ;; backwards will be faster. Especially if we're at the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
118 ;; beginning of the buffer :-). -SLB
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
119 (search-backward art-string nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
120 (nnmail-search-unix-mail-delim-backward)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
121 (setq start (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
122 (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
123 (setq stop (1- (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
124 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
125 (insert (format "221 %d Article retrieved.\n" article))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
126 (insert-buffer-substring nnfolder-current-buffer start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
127 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
128 (insert ".\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq articles (cdr articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 'headers)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (deffoo nnfolder-open-server (server &optional defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (nnoo-change-server 'nnfolder server defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (when (not (file-exists-p nnfolder-directory))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
138 (gnus-make-directory nnfolder-directory))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ((not (file-exists-p nnfolder-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (nnfolder-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (nnheader-report 'nnfolder "Couldn't create directory: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 nnfolder-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ((not (file-directory-p (file-truename nnfolder-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (nnfolder-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (nnheader-report 'nnfolder "Not a directory: %s" nnfolder-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (nnheader-report 'nnfolder "Opened server %s using directory %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 server nnfolder-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (deffoo nnfolder-request-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (let ((alist nnfolder-buffer-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (nnfolder-close-group (caar alist) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (nnoo-close-server 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq nnfolder-buffer-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 nnfolder-group-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (deffoo nnfolder-request-article (article &optional group server buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
166 (when (search-forward (nnfolder-article-string article) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
167 (let (start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
168 (nnmail-search-unix-mail-delim-backward)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
169 (setq start (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
170 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
171 (unless (and (nnmail-search-unix-mail-delim)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
172 (forward-line -1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
173 (goto-char (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
174 (setq stop (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
175 (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
176 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
177 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
178 (insert-buffer-substring nnfolder-current-buffer start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
179 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
180 (while (looking-at "From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
181 (delete-char 5)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
182 (insert "X-From-Line: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
183 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
184 (if (numberp article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
185 (cons nnfolder-current-group article)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
187 (search-forward (concat "\n" nnfolder-article-marker))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
188 (cons nnfolder-current-group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
189 (string-to-int
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
190 (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
191 (point) (progn (end-of-line) (point)))))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (deffoo nnfolder-request-group (group &optional server dont-check)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (nnmail-activate 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (not (assoc group nnfolder-group-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (nnheader-report 'nnfolder "No such group: %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if dont-check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (nnheader-report 'nnfolder "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let* ((active (assoc group nnfolder-group-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (group (car active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (range (cadr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ((null active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (nnheader-report 'nnfolder "No such group: %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((null nnfolder-current-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (nnheader-report 'nnfolder "Empty group: %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (nnheader-report 'nnfolder "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (nnheader-insert "211 %d %d %d %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (1+ (- (cdr range) (car range)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (car range) (cdr range) group))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (deffoo nnfolder-request-scan (&optional group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (nnfolder-possibly-change-group group server t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (nnmail-get-new-mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 'nnfolder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (let ((bufs nnfolder-buffer-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (while bufs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (not (buffer-name (nth 1 (car bufs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq nnfolder-buffer-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (delq (car bufs) nnfolder-buffer-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (set-buffer (nth 1 (car bufs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (nnfolder-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq bufs (cdr bufs))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 nnfolder-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; Don't close the buffer if we're not shutting down the server. This way,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; we can keep the buffer in the group buffer cache, and not have to grovel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; over the buffer again unless we add new mail to it or modify it in some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (deffoo nnfolder-close-group (group &optional server force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; Make sure we _had_ the group open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (when (or (assoc group nnfolder-buffer-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (equal group nnfolder-current-group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (let ((inf (assoc group nnfolder-buffer-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (when inf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (when nnfolder-current-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (push (list nnfolder-current-group nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 nnfolder-buffer-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq nnfolder-buffer-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (delq inf nnfolder-buffer-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq nnfolder-current-buffer (cadr inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 nnfolder-current-group (car inf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (when (and nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (buffer-name nnfolder-current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; If the buffer was modified, write the file out now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (nnfolder-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; If we're shutting the server down, we need to kill the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; buffer and remove it from the open buffer list. Or, of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; course, if we're trying to minimize our space impact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq nnfolder-buffer-alist (delq (assoc group nnfolder-buffer-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 nnfolder-buffer-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq nnfolder-current-group nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 nnfolder-current-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
269 (deffoo nnfolder-request-create-group (group &optional server args)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (nnfolder-possibly-change-group nil server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (nnmail-activate 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (when group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (unless (assoc group nnfolder-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (push (list group (cons 1 0)) nnfolder-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (deffoo nnfolder-request-list (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (nnfolder-possibly-change-group nil server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (nnmail-find-file nnfolder-active-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
282 (setq nnfolder-group-alist (nnmail-get-active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
283 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (deffoo nnfolder-request-newgroups (date &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (nnfolder-possibly-change-group nil server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (nnfolder-request-list server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (deffoo nnfolder-request-list-newsgroups (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (nnfolder-possibly-change-group nil server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (nnmail-find-file nnfolder-newsgroups-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (deffoo nnfolder-request-expire-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (articles newsgroup &optional server force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (nnfolder-possibly-change-group newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let* ((is-old t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (nnmail-activate 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (while (and articles is-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
305 (when (search-forward (nnfolder-article-string (car articles)) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
306 (if (setq is-old
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
307 (nnmail-expired-article-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
308 newsgroup
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
309 (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
310 (point) (progn (end-of-line) (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
311 force nnfolder-inhibit-expiry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
312 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
313 (nnheader-message 5 "Deleting article %d..."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
314 (car articles) newsgroup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
315 (nnfolder-delete-mail))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
316 (push (car articles) rest)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq articles (cdr articles)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
318 (unless nnfolder-inhibit-expiry
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
319 (nnheader-message 5 "Deleting articles...done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (nnfolder-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; Find the lowest active article in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let* ((active (cadr (assoc newsgroup nnfolder-group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (marker (concat "\n" nnfolder-article-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (number "[0-9]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (activemin (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (while (and (search-forward marker nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (re-search-forward number nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq activemin (min activemin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (string-to-number (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setcar active activemin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (nconc rest articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (deffoo nnfolder-request-move-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (article group server accept-form &optional last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (let ((buf (get-buffer-create " *nnfolder move*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (nnfolder-request-article article group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (insert-buffer-substring nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (concat "^" nnfolder-article-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (save-excursion (search-forward "\n\n" nil t) (point)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (setq result (eval accept-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
361 (when (search-forward (nnfolder-article-string article) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
362 (nnfolder-delete-mail))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (and last (nnfolder-save-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (deffoo nnfolder-request-accept-article (group &optional server last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (nnmail-check-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (let ((buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (when (looking-at "X-From-Line: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (replace-match "From "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (nnfolder-request-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (while (re-search-backward (concat "^" nnfolder-article-marker) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (delete-region (point) (progn (forward-line 1) (point))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
383 (setq result
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
384 (car (nnfolder-save-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
385 (if (stringp group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
386 (list (cons group (nnfolder-active-number group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
387 (nnmail-article-group 'nnfolder-active-number))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (and last (nnfolder-save-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (unless result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (nnheader-report 'nnfolder "Couldn't store article"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (deffoo nnfolder-request-replace-article (article group buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (nnfolder-possibly-change-group group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if (not (search-forward (nnfolder-article-string article) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (nnfolder-delete-mail t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (nnfolder-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (deffoo nnfolder-request-delete-group (group &optional force server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (nnfolder-close-group group server t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; Delete all articles in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 () ; Don't delete the articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; Delete the file that holds the group.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
414 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
415 (delete-file (nnfolder-group-pathname group))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; Remove the group from all structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq nnfolder-group-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (delq (assoc group nnfolder-group-alist) nnfolder-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 nnfolder-current-group nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 nnfolder-current-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; Save the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (deffoo nnfolder-request-rename-group (group new-name &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (nnfolder-possibly-change-group group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (and (file-writable-p buffer-file-name)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
430 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
431 (rename-file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
432 buffer-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
433 (nnfolder-group-pathname new-name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
434 t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; That went ok, so we change the internal structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (let ((entry (assoc group nnfolder-group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (and entry (setcar entry new-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq nnfolder-current-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 nnfolder-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;; Save the new group alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; We kill the buffer instead of renaming it and stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun nnfolder-article-string (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if (numberp article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (concat "\n" nnfolder-article-marker (int-to-string article) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (concat "\nMessage-ID: " article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun nnfolder-delete-mail (&optional force leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Delete the message that point is in."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
459 (nnmail-search-unix-mail-delim-backward)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (if leave-delim (progn (forward-line 1) (point))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
461 (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (forward-line 1)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
464 (if (nnmail-search-unix-mail-delim)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if (and (not (bobp)) leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (progn (forward-line -2) (point))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
467 (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; When scanning, we're not looking t immediately switch into the group - if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;; we know our information is up to date, don't even bother reading the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun nnfolder-possibly-change-group (group &optional server scanning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (when (and server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (not (nnfolder-server-opened server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (nnfolder-open-server server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (when (and group (or nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (not (equal group nnfolder-current-group))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
478 (gnus-make-directory (directory-file-name nnfolder-directory))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (nnfolder-possibly-activate-groups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (or (assoc group nnfolder-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (not (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (nnfolder-group-pathname group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
484 (push (list group (cons 1 0)) nnfolder-group-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let (inf file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (if (and (equal group nnfolder-current-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (buffer-name nnfolder-current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (setq nnfolder-current-group group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; If we have to change groups, see if we don't already have the mbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; in memory. If we do, verify the modtime and destroy the mbox if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; needed so we can rescan it.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
496 (when (setq inf (assoc group nnfolder-buffer-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
497 (setq nnfolder-current-buffer (nth 1 inf)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; If the buffer is not live, make sure it isn't in the alist. If it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; is live, verify that nobody else has touched the file since last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; time.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
502 (when (or (not (and nnfolder-current-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
503 (buffer-name nnfolder-current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
504 (not (and (bufferp nnfolder-current-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
505 (verify-visited-file-modtime
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
506 nnfolder-current-buffer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
507 (when (and nnfolder-current-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
508 (buffer-name nnfolder-current-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
509 (bufferp nnfolder-current-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
510 (kill-buffer nnfolder-current-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
511 (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
512 (setq inf nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
514 (unless inf
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq file (nnfolder-group-pathname group))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
517 (unless (file-directory-p (file-truename file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (unless (file-exists-p file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
519 (gnus-make-directory (file-name-directory file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
520 (nnmail-write-region 1 1 file t 'nomesg))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
521 (setq nnfolder-current-group group)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (setq nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (nnfolder-read-folder file scanning))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
524 (when nnfolder-current-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
525 (set-buffer nnfolder-current-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
526 (push (list group nnfolder-current-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
527 nnfolder-buffer-alist)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (setq nnfolder-current-group group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
530 (defun nnfolder-save-mail (group-art-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "Called narrowed to an article."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
532 (let* (save-list group-art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (goto-char (point-min))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
534 ;; The From line may have been quoted by movemail.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
535 (when (looking-at (concat ">" message-unix-mail-delimiter))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
536 (delete-char 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
537 ;; This might come from somewhere else.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
538 (unless (looking-at message-unix-mail-delimiter)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (insert "From nobody " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; Quote all "From " lines in the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (forward-line 1)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
543 (while (re-search-forward "^From " nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (insert "> "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (setq save-list group-art-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (nnmail-insert-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (nnmail-insert-xref group-art-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (run-hooks 'nnmail-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (run-hooks 'nnfolder-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;; Insert the mail into each of the destination groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (while group-art-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (setq group-art (car group-art-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 group-art-list (cdr group-art-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; Kill the previous newsgroup markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (while (search-backward (concat "\n" nnfolder-article-marker) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (delete-region (1+ (point)) (progn (forward-line 2) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (nnfolder-possibly-change-group (car group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; Insert the new newsgroup marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (nnfolder-insert-newsgroup-line group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (unless nnfolder-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (nnfolder-close-group (car group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (nnfolder-request-create-group (car group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (nnfolder-possibly-change-group (car group-art)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((beg (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (end (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (set-buffer nnfolder-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (insert "\n"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
578 (unless (bobp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
579 (insert "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (insert-buffer-substring obuf beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; Did we save it anywhere?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 save-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun nnfolder-insert-newsgroup-line (group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
589 (when (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
590 (forward-char -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
591 (insert (format (concat nnfolder-article-marker "%d %s\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
592 (cdr group-art) (current-time-string))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun nnfolder-possibly-activate-groups (&optional group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; If we're looking for the activation of a specific group, find out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; its real name and switch to it.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
598 (when group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
599 (nnfolder-possibly-change-group group))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; If the group alist isn't active, activate it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (nnmail-activate 'nnfolder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defun nnfolder-active-number (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (when group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; Find the next article number in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (let ((active (cadr (assoc group nnfolder-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setcdr active (1+ (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;; This group is new, so we create a new entry for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; This might be a bit naughty... creating groups on the drop of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; a hat, but I don't know...
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
614 (push (list group (setq active (cons 1 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
615 nnfolder-group-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (cdr active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (nnfolder-possibly-activate-groups group)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; This method has a problem if you've accidentally let the active list get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; out of sync with the files. This could happen, say, if you've
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; accidentally gotten new mail with something other than Gnus (but why
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; would _that_ ever happen? :-). In that case, we will be in the middle of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; processing the file, ready to add new X-Gnus article number markers, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; we'll run across a message with no ID yet - the active list _may_not_ be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; ready for us yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; To handle this, I'm modifying this routine to maintain the maximum ID seen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; so far, and when we hit a message with no ID, we will _manually_ scan the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; rest of the message looking for any more, possibly higher IDs. We'll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; assume the maximum that we find is the highest active. Note that this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; shouldn't cost us much extra time at all, but will be a lot less
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; vulnerable to glitches between the mbox and the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (defun nnfolder-read-folder (file &optional scanning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; This is an attempt at a serious shortcut - don't even read in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;; if we know we've seen it since the last time it was touched.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (let ((scantime (cadr (assoc nnfolder-current-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 nnfolder-scantime-alist)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
641 (modtime (nth 5 (file-attributes file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (if (and scanning scantime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (eq (car scantime) (car modtime))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (eq (cdr scantime) (cadr modtime)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (nnfolder-possibly-activate-groups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; Read in the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (set-buffer (setq nnfolder-current-buffer
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
650 (nnheader-find-file-noselect file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (buffer-disable-undo (current-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
652 (setq buffer-read-only nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; If the file hasn't been touched since the last time we scanned it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; don't bother doing anything with it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((delim (concat "^" message-unix-mail-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (marker (concat "\n" nnfolder-article-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (number "[0-9]+")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
658 (active (or (cadr (assoc nnfolder-current-group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
659 nnfolder-group-alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
660 (cons 1 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (scantime (assoc nnfolder-current-group nnfolder-scantime-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (minid (lsh -1 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 maxid start end newscantime)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (setq maxid (or (cdr active) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; Anytime the active number is 1 or 0, it is suspect. In that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; case, search the file manually to find the active number. Or,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; of course, if we're being paranoid. (This would also be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; place to build other lists from the header markers, such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; expunge lists, etc., if we ever desired to abandon the active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; file entirely for mboxes.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (when (or nnfolder-ignore-active-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (< maxid 2))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
676 (while (and (search-forward marker nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
677 (re-search-forward number nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
678 (let ((newnum (string-to-number (match-string 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
679 (setq maxid (max maxid newnum))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
680 (setq minid (min minid newnum))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
681 (setcar active (max 1 (min minid maxid)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
682 (setcdr active (max maxid (cdr active)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
683 (goto-char (point-min)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ;; As long as we trust that the user will only insert unmarked mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;; at the end, go to the end and search backwards for the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; marker. Find the start of that message, and begin to search for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; unmarked messages from there.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
689 (when (not (or nnfolder-distrust-mbox
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
690 (< maxid 2)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
691 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
692 (if (not (re-search-backward marker nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
693 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
694 (when (not (nnmail-search-unix-mail-delim))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
695 (goto-char (point-min)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ;; Keep track of the active number on our own, and insert it back
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
698 ;; into the active list when we're done. Also, prime the pump to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; cut down on the number of searches we do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (setq end (point-marker))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
701 (set-marker end (or (and (nnmail-search-unix-mail-delim)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
702 (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (while (not (= end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq start (marker-position end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; There may be more than one "From " line, so we skip past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; them.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
709 (while (looking-at delim)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (forward-line 1))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
711 (set-marker end (or (and (nnmail-search-unix-mail-delim)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
712 (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (goto-char start)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
715 (when (not (search-forward marker end t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
716 (narrow-to-region start end)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
717 (nnmail-insert-lines)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
718 (nnfolder-insert-newsgroup-line
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
719 (cons nil (nnfolder-active-number nnfolder-current-group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
720 (widen)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ;; Make absolutely sure that the active list reflects reality!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (nnmail-save-active nnfolder-group-alist nnfolder-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;; Set the scantime for this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (setq newscantime (visited-file-modtime))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (if scantime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setcdr scantime (list newscantime))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
728 (push (list nnfolder-current-group newscantime)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 nnfolder-scantime-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (defun nnfolder-generate-active-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "Look for mbox folders in the nnfolder directory and make them into groups."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (nnmail-activate 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (let ((files (directory-files nnfolder-directory))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
738 file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (while (setq file (pop files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (when (and (not (backup-file-name-p file))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
741 (nnheader-mail-file-mbox-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
742 (concat nnfolder-directory file)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
743 (nnheader-message 5 "Adding group %s..." file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
744 (push (list file (cons 1 0)) nnfolder-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
745 (nnfolder-possibly-change-group file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
746 (nnfolder-close-group file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (message ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun nnfolder-group-pathname (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 "Make pathname for GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (let ((dir (file-name-as-directory (expand-file-name nnfolder-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ;; If this file exists, we use it directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (if (or nnmail-use-long-file-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (file-exists-p (concat dir group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (concat dir group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ;; If not, we translate dots into slashes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (concat dir (nnheader-replace-chars-in-string group ?. ?/)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (defun nnfolder-save-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 "Save the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (when (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (run-hooks 'nnfolder-save-buffer-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (save-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (provide 'nnfolder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;;; nnfolder.el ends here