annotate lisp/gnus/nnmbox.el @ 131:869e1851236b xemacs-20-1p4

Import from CVS: tag xemacs-20-1p4
author cvs
date Mon, 13 Aug 2007 09:29:07 +0200
parents 7d55a9ba150c
children
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
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
28 ;; Gnus sources.
0
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)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
85 (when (or (search-forward art-string nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
86 (progn (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
87 (search-forward art-string nil t)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
88 (setq start
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
89 (save-excursion
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
90 (re-search-backward
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
91 (concat "^" message-unix-mail-delimiter) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
92 (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
93 (search-forward "\n\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
94 (setq stop (1- (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
95 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
96 (insert (format "221 %d Article retrieved.\n" article))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
97 (insert-buffer-substring nnmbox-mbox-buffer start stop)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
98 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
118 (nnmbox-create-mbox)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
119 (cond
0
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))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
150 (when (search-forward (nnmbox-article-string article) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
151 (let (start stop)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
152 (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
153 (setq start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
154 (forward-line 1)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
155 (or (and (re-search-forward
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
156 (concat "^" message-unix-mail-delimiter) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
157 (forward-line -1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
158 (goto-char (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 (setq stop (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
163 (insert-buffer-substring nnmbox-mbox-buffer start stop)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
165 (while (looking-at "From ")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (delete-char 5)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
167 (insert "X-From-Line: ")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
168 (forward-line 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
169 (if (numberp article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
170 (cons nnmbox-current-group article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
175 (cond
0
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)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
184 (nnheader-insert "211 %d %d %d %s\n"
0
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)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
191 (nnmail-get-new-mail
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
192 'nnmbox
0
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)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
197 (file-name-directory nnmbox-mbox-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
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)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
213 (setq nnmbox-group-alist (nnmail-get-active))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
222 (deffoo nnmbox-request-expire-articles
0
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
229 (save-excursion
0
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))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
233 (when (search-forward (nnmbox-article-string (car articles)) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
234 (if (setq is-old
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
235 (nnmail-expired-article-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
236 newsgroup
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
237 (buffer-substring
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
238 (point) (progn (end-of-line) (point))) force))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
239 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
240 (nnheader-message 5 "Deleting article %d in %s..."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
241 (car articles) newsgroup)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
242 (nnmbox-delete-mail))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
261 (and
0
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))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
269 (while (re-search-forward
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
270 "^X-Gnus-Newsgroup:"
0
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
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
281 (when (search-forward (nnmbox-article-string article) nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
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"))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
298 (and
0
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))))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
307 (when nnmail-cache-accepted-message-ids
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
308 (nnmail-cache-insert (nnmail-fetch-field "message-id")))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
309 (setq result (if (stringp group)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
310 (list (cons group (nnmbox-active-number group)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
311 (nnmail-article-group 'nnmbox-active-number)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
312 (if (and (null result)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
313 (yes-or-no-p "Moved to `junk' group; delete article? "))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
314 (setq result 'junk)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
315 (setq result (car (nnmbox-save-mail result)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (insert-buffer-substring buf)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
320 (when last
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
321 (when nnmail-cache-accepted-message-ids
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
322 (nnmail-cache-close))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
323 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
324 (save-buffer))))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
325 result))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (deffoo nnmbox-request-replace-article (article group buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (nnmbox-possibly-change-newsgroup group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (if (not (search-forward (nnmbox-article-string article) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (nnmbox-delete-mail t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (deffoo nnmbox-request-delete-group (group &optional force server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (nnmbox-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;; Delete all articles in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 () ; Don't delete the articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; Delete all articles in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (nnmbox-delete-mail))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
353 (when found
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
354 (save-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; Remove the group from all structures.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
356 (setq nnmbox-group-alist
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (delq (assoc group nnmbox-group-alist) nnmbox-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 nnmbox-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; Save the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (deffoo nnmbox-request-rename-group (group new-name &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (nnmbox-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (set-buffer nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (new-ident (concat "\nX-Gnus-Newsgroup: " new-name ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (replace-match new-ident t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq found t))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
374 (when found
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
375 (save-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (let ((entry (assoc group nnmbox-group-alist)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
377 (when entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
378 (setcar entry new-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (setq nnmbox-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; Save the new group alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; If FORCE, delete article no matter how many X-Gnus-Newsgroup
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
388 ;; headers there are. If LEAVE-DELIM, don't delete the Unix mbox
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; delimiter line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun nnmbox-delete-mail (&optional force leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; Delete the current X-Gnus-Newsgroup line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; Beginning of the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if leave-delim (progn (forward-line 1) (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 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (forward-line 1)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
406 (or (and (re-search-forward (concat "^" message-unix-mail-delimiter)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (and (not (bobp)) leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (progn (forward-line -2) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; Only delete the article if no other groups owns it as well.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
414 (when (or force (not (re-search-forward "^X-Gnus-Newsgroup: " nil t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
415 (delete-region (point-min) (point-max))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defun nnmbox-possibly-change-newsgroup (newsgroup &optional server)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
418 (when (and server
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (not (nnmbox-server-opened server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (nnmbox-open-server server))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
421 (when (or (not nnmbox-mbox-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
422 (not (buffer-name nnmbox-mbox-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
423 (save-excursion
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
424 (set-buffer (setq nnmbox-mbox-buffer
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
425 (nnheader-find-file-noselect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
426 nnmbox-mbox-file nil 'raw)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
427 (buffer-disable-undo (current-buffer))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
428 (when (not nnmbox-group-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
429 (nnmail-activate 'nnmbox))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if newsgroup
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
431 (when (assoc newsgroup nnmbox-group-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
432 (setq nnmbox-current-group newsgroup))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (defun nnmbox-article-string (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if (numberp article)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
437 (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (int-to-string article) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (concat "\nMessage-ID: " article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (defun nnmbox-article-group-number ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (goto-char (point-min))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
444 (when (re-search-forward "^X-Gnus-Newsgroup: +\\([^:]+\\):\\([0-9]+\\) "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
445 nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
446 (cons (buffer-substring (match-beginning 1) (match-end 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
447 (string-to-int
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
448 (buffer-substring (match-beginning 2) (match-end 2)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
450 (defun nnmbox-save-mail (group-art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Called narrowed to an article."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
452 (let ((delim (concat "^" message-unix-mail-delimiter)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; This might come from somewhere else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (unless (looking-at delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (insert "From nobody " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; Quote all "From " lines in the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (while (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (insert "> "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (nnmail-insert-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (nnmail-insert-xref group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (nnmbox-insert-newsgroup-line group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (run-hooks 'nnmail-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (run-hooks 'nnmbox-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defun nnmbox-insert-newsgroup-line (group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (goto-char (point-min))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
473 (when (search-forward "\n\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
474 (forward-char -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
475 (while group-art
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
476 (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
477 (caar group-art) (cdar group-art)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
478 (current-time-string)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
479 (setq group-art (cdr group-art))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defun nnmbox-active-number (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; Find the next article number in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (let ((active (cadr (assoc group nnmbox-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setcdr active (1+ (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; This group is new, so we create a new entry for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; This might be a bit naughty... creating groups on the drop of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; a hat, but I don't know...
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
490 (push (list group (setq active (cons 1 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
491 nnmbox-group-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494 (defun nnmbox-create-mbox ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
495 (when (not (file-exists-p nnmbox-mbox-file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
496 (nnmail-write-region 1 1 nnmbox-mbox-file t 'nomesg)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
497
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun nnmbox-read-mbox ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (nnmail-activate 'nnmbox)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
500 (nnmbox-create-mbox)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (if (and nnmbox-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (buffer-name nnmbox-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (set-buffer nnmbox-mbox-buffer)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
505 (= (buffer-size) (nnheader-file-size nnmbox-mbox-file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (let ((delim (concat "^" message-unix-mail-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (alist nnmbox-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 start end number)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
511 (set-buffer (setq nnmbox-mbox-buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (nnheader-find-file-noselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 nnmbox-mbox-file nil 'raw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; Go through the group alist and compare against
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; the mbox file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (when (and (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (format "^X-Gnus-Newsgroup: %s:\\([0-9]+\\) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (caar alist)) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (>= (setq number
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
524 (string-to-number
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (cdadar alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (setcdr (cadar alist) (1+ number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq alist (cdr alist)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
530
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (while (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq start (match-beginning 0))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
534 (when (not (search-forward "\nX-Gnus-Newsgroup: "
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
535 (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
536 (setq end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537 (or
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 (and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539 (re-search-forward delim nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
540 (match-beginning 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 (point-max))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
545 (narrow-to-region start end)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
546 (nnmbox-save-mail
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
547 (nnmail-article-group 'nnmbox-active-number)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (goto-char end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (provide 'nnmbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;; nnmbox.el ends here