annotate lisp/gnus/nnmbox.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 0293115a14e9
children ec9a17fef872
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 ;;; nnmbox.el --- mail mbox 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: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: news, mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; For an overview of what the interface functions do, please see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Gnus sources.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'nnmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'nnoo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (nnoo-declare nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvoo nnmbox-mbox-file (expand-file-name "~/mbox")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "The name of the mail box file in the user's home directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvoo nnmbox-active-file (expand-file-name "~/.mbox-active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "The name of the active file for the mail box.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvoo nnmbox-get-new-mail t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "If non-nil, nnmbox will check the incoming mail file and split the mail.")
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 nnmbox-prepare-save-mail-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "Hook run narrowed to an article before saving.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defconst nnmbox-version "nnmbox 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "nnmbox version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvoo nnmbox-current-group nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "Current nnmbox news group directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defconst nnmbox-mbox-buffer nil)
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 nnmbox-status-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvoo nnmbox-group-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvoo nnmbox-active-timestamp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; Interface functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (nnoo-define-basics nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (deffoo nnmbox-retrieve-headers (sequence &optional newsgroup server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (let ((number (length sequence))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 article art-string start stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (nnmbox-possibly-change-newsgroup newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (while sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (setq article (car sequence))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (setq art-string (nnmbox-article-string article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (set-buffer nnmbox-mbox-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
85 (when (or (search-forward art-string nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
86 (progn (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
87 (search-forward art-string nil t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
88 (setq start
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
89 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
90 (re-search-backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
91 (concat "^" message-unix-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
92 (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
93 (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
94 (setq stop (1- (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
95 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
96 (insert (format "221 %d Article retrieved.\n" article))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
97 (insert-buffer-substring nnmbox-mbox-buffer start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
98 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
99 (insert ".\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq sequence (cdr sequence))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq count (1+ count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (and (numberp nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (> number nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (zerop (% count 20))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (nnheader-message 5 "nnmbox: Receiving headers... %d%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (/ (* count 100) number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (and (numberp nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (> number nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (nnheader-message 5 "nnmbox: Receiving headers...done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 'headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (deffoo nnmbox-open-server (server &optional defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (nnoo-change-server 'nnmbox server defs)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
118 (nnmbox-create-mbox)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ((not (file-exists-p nnmbox-mbox-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (nnmbox-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (nnheader-report 'nnmbox "No such file: %s" nnmbox-mbox-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((file-directory-p nnmbox-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (nnmbox-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (nnheader-report 'nnmbox "Not a regular file: %s" nnmbox-mbox-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (nnheader-report 'nnmbox "Opened server %s using mbox %s" server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 nnmbox-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (deffoo nnmbox-close-server (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (when (and nnmbox-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (buffer-name nnmbox-mbox-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (kill-buffer nnmbox-mbox-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (nnoo-close-server 'nnmbox server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (deffoo nnmbox-server-opened (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (and (nnoo-current-server-p 'nnmbox server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 nnmbox-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (buffer-name nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 nntp-server-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (buffer-name nntp-server-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (deffoo nnmbox-request-article (article &optional newsgroup server buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (nnmbox-possibly-change-newsgroup newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
150 (when (search-forward (nnmbox-article-string article) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
151 (let (start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
152 (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
153 (setq start (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
154 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
155 (or (and (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
156 (concat "^" message-unix-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
157 (forward-line -1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
158 (goto-char (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
159 (setq stop (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
160 (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
161 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
162 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
163 (insert-buffer-substring nnmbox-mbox-buffer start stop)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
164 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
165 (while (looking-at "From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
166 (delete-char 5)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
167 (insert "X-From-Line: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
168 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
169 (if (numberp article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
170 (cons nnmbox-current-group article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
171 (nnmbox-article-group-number)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (deffoo nnmbox-request-group (group &optional server dont-check)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (let ((active (cadr (assoc group nnmbox-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ((or (null active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (null (nnmbox-possibly-change-newsgroup group server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (nnheader-report 'nnmbox "No such group: %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (dont-check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (nnheader-report 'nnmbox "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (nnheader-insert ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (nnheader-report 'nnmbox "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (nnheader-insert "211 %d %d %d %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (1+ (- (cdr active) (car active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (car active) (cdr active) group)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (deffoo nnmbox-request-scan (&optional group server)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
189 (nnmbox-possibly-change-newsgroup group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (nnmbox-read-mbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (nnmail-get-new-mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 'nnmbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (lambda ()
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 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (save-buffer)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
197 (file-name-directory nnmbox-mbox-file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
198 group
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((in-buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (insert-buffer-substring in-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (nnmail-save-active nnmbox-group-alist nnmbox-active-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (deffoo nnmbox-close-group (group &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (deffoo nnmbox-request-list (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (nnmail-find-file nnmbox-active-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
213 (setq nnmbox-group-alist (nnmail-get-active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
214 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (deffoo nnmbox-request-newgroups (date &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (nnmbox-request-list server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (deffoo nnmbox-request-list-newsgroups (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (nnheader-report 'nnmbox "LIST NEWSGROUPS is not implemented."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (deffoo nnmbox-request-expire-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (articles newsgroup &optional server force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (nnmbox-possibly-change-newsgroup newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (let* ((is-old t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (nnmail-activate 'nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (while (and articles is-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
233 (when (search-forward (nnmbox-article-string (car articles)) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
234 (if (setq is-old
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
235 (nnmail-expired-article-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
236 newsgroup
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
237 (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
238 (point) (progn (end-of-line) (point))) force))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
239 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
240 (nnheader-message 5 "Deleting article %d in %s..."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
241 (car articles) newsgroup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
242 (nnmbox-delete-mail))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
243 (push (car articles) rest)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq articles (cdr articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; Find the lowest active article in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (let ((active (nth 1 (assoc newsgroup nnmbox-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (while (and (not (search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (nnmbox-article-string (car active)) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (<= (car active) (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (setcar active (1+ (car active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (nconc rest articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (deffoo nnmbox-request-move-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (article group server accept-form &optional last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let ((buf (get-buffer-create " *nnmbox move*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (nnmbox-request-article article group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (insert-buffer-substring nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "^X-Gnus-Newsgroup:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (save-excursion (search-forward "\n\n" nil t) (point)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq result (eval accept-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
278 (nnmbox-possibly-change-newsgroup group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
281 (when (search-forward (nnmbox-article-string article) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
282 (nnmbox-delete-mail))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (and last (save-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (deffoo nnmbox-request-accept-article (group &optional server last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (nnmbox-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (nnmail-check-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (let ((buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (goto-char (point-min))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
292 ;; The From line may have been quoted by movemail.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
293 (when (looking-at (concat ">" message-unix-mail-delimiter))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
294 (delete-char 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (looking-at "X-From-Line: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (replace-match "From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert "From nobody " (current-time-string) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (nnmail-activate 'nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (delete-region (point) (progn (forward-line 1) (point))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
307 (setq result (nnmbox-save-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
308 (if (stringp group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
309 (list (cons group (nnmbox-active-number group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
310 (nnmail-article-group 'nnmbox-active-number)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (insert-buffer-substring buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (and last (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (nnmail-save-active nnmbox-group-alist nnmbox-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (car result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (deffoo nnmbox-request-replace-article (article group buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (nnmbox-possibly-change-newsgroup group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (if (not (search-forward (nnmbox-article-string article) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (nnmbox-delete-mail t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (deffoo nnmbox-request-delete-group (group &optional force server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (nnmbox-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Delete all articles in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (if (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 () ; Don't delete the articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; Delete all articles in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (nnmbox-delete-mail))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
346 (when found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
347 (save-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; Remove the group from all structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq nnmbox-group-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (delq (assoc group nnmbox-group-alist) nnmbox-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 nnmbox-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; Save the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (deffoo nnmbox-request-rename-group (group new-name &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (nnmbox-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (new-ident (concat "\nX-Gnus-Newsgroup: " new-name ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (replace-match new-ident t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq found t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
367 (when found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
368 (save-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (let ((entry (assoc group nnmbox-group-alist)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
370 (when entry
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
371 (setcar entry new-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq nnmbox-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; Save the new group alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; If FORCE, delete article no matter how many X-Gnus-Newsgroup
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
381 ;; headers there are. If LEAVE-DELIM, don't delete the Unix mbox
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; delimiter line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun nnmbox-delete-mail (&optional force leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; Delete the current X-Gnus-Newsgroup line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; Beginning of the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if leave-delim (progn (forward-line 1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (forward-line 1)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
399 (or (and (re-search-forward (concat "^" message-unix-mail-delimiter)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if (and (not (bobp)) leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (progn (forward-line -2) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; Only delete the article if no other groups owns it as well.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
407 (when (or force (not (re-search-forward "^X-Gnus-Newsgroup: " nil t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
408 (delete-region (point-min) (point-max))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defun nnmbox-possibly-change-newsgroup (newsgroup &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (when (and server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (not (nnmbox-server-opened server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (nnmbox-open-server server))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
414 (when (or (not nnmbox-mbox-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
415 (not (buffer-name nnmbox-mbox-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
416 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
417 (set-buffer (setq nnmbox-mbox-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
418 (nnheader-find-file-noselect
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
419 nnmbox-mbox-file nil 'raw)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
420 (buffer-disable-undo (current-buffer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
421 (when (not nnmbox-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
422 (nnmail-activate 'nnmbox))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if newsgroup
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
424 (when (assoc newsgroup nnmbox-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
425 (setq nnmbox-current-group newsgroup))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun nnmbox-article-string (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (if (numberp article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (int-to-string article) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (concat "\nMessage-ID: " article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun nnmbox-article-group-number ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
437 (when (re-search-forward "^X-Gnus-Newsgroup: +\\([^:]+\\):\\([0-9]+\\) "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
438 nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
439 (cons (buffer-substring (match-beginning 1) (match-end 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
440 (string-to-int
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
441 (buffer-substring (match-beginning 2) (match-end 2)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
443 (defun nnmbox-save-mail (group-art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 "Called narrowed to an article."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
445 (let ((delim (concat "^" message-unix-mail-delimiter)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; This might come from somewhere else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (unless (looking-at delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (insert "From nobody " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; Quote all "From " lines in the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (while (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (insert "> "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (nnmail-insert-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (nnmail-insert-xref group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (nnmbox-insert-newsgroup-line group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (run-hooks 'nnmail-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (run-hooks 'nnmbox-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun nnmbox-insert-newsgroup-line (group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
466 (when (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
467 (forward-char -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
468 (while group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
469 (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
470 (caar group-art) (cdar group-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
471 (current-time-string)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
472 (setq group-art (cdr group-art))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun nnmbox-active-number (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; Find the next article number in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (let ((active (cadr (assoc group nnmbox-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setcdr active (1+ (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; This group is new, so we create a new entry for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; This might be a bit naughty... creating groups on the drop of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; a hat, but I don't know...
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
483 (push (list group (setq active (cons 1 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
484 nnmbox-group-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
487 (defun nnmbox-create-mbox ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
488 (when (not (file-exists-p nnmbox-mbox-file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
489 (nnmail-write-region 1 1 nnmbox-mbox-file t 'nomesg)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
490
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun nnmbox-read-mbox ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (nnmail-activate 'nnmbox)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
493 (nnmbox-create-mbox)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (if (and nnmbox-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (buffer-name nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (set-buffer nnmbox-mbox-buffer)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
498 (= (buffer-size) (nnheader-file-size nnmbox-mbox-file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (let ((delim (concat "^" message-unix-mail-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (alist nnmbox-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 start end number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (set-buffer (setq nnmbox-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (nnheader-find-file-noselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 nnmbox-mbox-file nil 'raw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; Go through the group alist and compare against
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; the mbox file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (when (and (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (format "^X-Gnus-Newsgroup: %s:\\([0-9]+\\) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (caar alist)) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (>= (setq number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (string-to-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (cdadar alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (setcdr (cadar alist) (1+ number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (while (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (setq start (match-beginning 0))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
527 (when (not (search-forward "\nX-Gnus-Newsgroup: "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
528 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
529 (setq end
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
530 (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
531 (and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
532 (re-search-forward delim nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
533 (match-beginning 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
534 (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
535 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
536 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
537 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
538 (narrow-to-region start end)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
539 (nnmbox-save-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
540 (nnmail-article-group 'nnmbox-active-number)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (goto-char end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (provide 'nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;;; nnmbox.el ends here