annotate lisp/gnus/nnbabyl.el @ 35:279432d5c479

Added tag r19-15b100 for changeset d620409f5eb8
author cvs
date Mon, 13 Aug 2007 08:53:21 +0200
parents ec9a17fef872
children c53a95d3c46d
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 ;;; nnbabyl.el --- rmail 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
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
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 'rmail)
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 nnbabyl)
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 nnbabyl-mbox-file (expand-file-name "~/RMAIL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "The name of the rmail box file in the users 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 nnbabyl-active-file (expand-file-name "~/.rmail-active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "The name of the active file for the rmail 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 nnbabyl-get-new-mail t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "If non-nil, nnbabyl 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 nnbabyl-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 (defvar nnbabyl-mail-delimiter "\^_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defconst nnbabyl-version "nnbabyl 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "nnbabyl version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvoo nnbabyl-mbox-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defvoo nnbabyl-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvoo nnbabyl-status-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvoo nnbabyl-group-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvoo nnbabyl-active-timestamp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvoo nnbabyl-previous-buffer-mode 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 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (autoload 'gnus-set-text-properties "gnus-ems"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; Interface functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (nnoo-define-basics nnbabyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (deffoo nnbabyl-retrieve-headers (articles &optional group server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (let ((number (length articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (delim (concat "^" nnbabyl-mail-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 article art-string start stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (nnbabyl-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (while (setq article (pop articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq art-string (nnbabyl-article-string article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (set-buffer nnbabyl-mbox-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
88 (end-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (when (or (search-forward art-string nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (search-backward art-string nil t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
91 (unless (re-search-backward delim nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
92 (goto-char (point-min)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (while (and (not (looking-at ".+:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (zerop (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (setq stop (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (insert "221 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (princ article (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (insert " Article retrieved.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (insert-buffer-substring nnbabyl-mbox-buffer start stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (insert ".\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (and (numberp nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (> number nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (zerop (% (incf count) 20))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (nnheader-message 5 "nnbabyl: Receiving headers... %d%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (/ (* count 100) number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (and (numberp nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (> number nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (nnheader-message 5 "nnbabyl: Receiving headers...done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 'headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (deffoo nnbabyl-open-server (server &optional defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (nnoo-change-server 'nnbabyl server defs)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
121 (nnbabyl-create-mbox)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
122 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((not (file-exists-p nnbabyl-mbox-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (nnbabyl-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (nnheader-report 'nnbabyl "No such file: %s" nnbabyl-mbox-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ((file-directory-p nnbabyl-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (nnbabyl-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (nnheader-report 'nnbabyl "Not a regular file: %s" nnbabyl-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 (nnheader-report 'nnbabyl "Opened server %s using mbox %s" server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 nnbabyl-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (deffoo nnbabyl-close-server (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; Restore buffer mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (when (and (nnbabyl-server-opened)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 nnbabyl-previous-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (caar nnbabyl-previous-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (cdar nnbabyl-previous-buffer-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (funcall (cdr nnbabyl-previous-buffer-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (nnoo-close-server 'nnbabyl server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq nnbabyl-mbox-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (deffoo nnbabyl-server-opened (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (and (nnoo-current-server-p 'nnbabyl server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 nnbabyl-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (buffer-name nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 nntp-server-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (buffer-name nntp-server-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (deffoo nnbabyl-request-article (article &optional newsgroup server buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (nnbabyl-possibly-change-newsgroup newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (when (search-forward (nnbabyl-article-string article) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (let (start stop summary-line)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
162 (unless (re-search-backward (concat "^" nnbabyl-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
163 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
164 (end-of-line))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (while (and (not (looking-at ".+:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (zerop (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq start (point))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
168 (or (when (re-search-forward
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
169 (concat "^" nnbabyl-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
170 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
171 t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (setq stop (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (insert-buffer-substring nnbabyl-mbox-buffer start stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; If there is an EOOH header, then we have to remove some
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
180 ;; duplicated headers.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq summary-line (looking-at "Summary-line:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (when (search-forward "\n*** EOOH ***" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (if summary-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; The headers to be deleted are located before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; EOOH line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (delete-region (point-min) (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; ...or after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (or (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (point)))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
192 (if (numberp article)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (cons nnbabyl-current-group article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (nnbabyl-article-group-number)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (deffoo nnbabyl-request-group (group &optional server dont-check)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (let ((active (cadr (assoc group nnbabyl-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (save-excursion
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
199 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ((or (null active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (null (nnbabyl-possibly-change-newsgroup group server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (nnheader-report 'nnbabyl "No such group: %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (dont-check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (nnheader-report 'nnbabyl "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (nnheader-insert ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (nnheader-report 'nnbabyl "Selected group %s" group)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
208 (nnheader-insert "211 %d %d %d %s\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (1+ (- (cdr active) (car active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (car active) (cdr active) group))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (deffoo nnbabyl-request-scan (&optional group server)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
213 (nnbabyl-possibly-change-newsgroup group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (nnbabyl-read-mbox)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
215 (nnmail-get-new-mail
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
216 'nnbabyl
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (save-buffer)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
221 (file-name-directory nnbabyl-mbox-file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
222 group
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (let ((in-buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (while (search-forward "\n\^_\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (search-backward "\n\^_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (insert-buffer-substring in-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (deffoo nnbabyl-close-group (group &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
239 (deffoo nnbabyl-request-create-group (group &optional server args)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (nnmail-activate 'nnbabyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (unless (assoc group nnbabyl-group-alist)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
242 (push (list group (cons 1 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
243 nnbabyl-group-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (deffoo nnbabyl-request-list (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (nnmail-find-file nnbabyl-active-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
250 (setq nnbabyl-group-alist (nnmail-get-active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
251 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (deffoo nnbabyl-request-newgroups (date &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (nnbabyl-request-list server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (deffoo nnbabyl-request-list-newsgroups (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (nnheader-report 'nnbabyl "nnbabyl: LIST NEWSGROUPS is not implemented."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (deffoo nnbabyl-request-expire-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (articles newsgroup &optional server force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (nnbabyl-possibly-change-newsgroup newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (let* ((is-old t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (nnmail-activate 'nnbabyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
266 (save-excursion
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (gnus-set-text-properties (point-min) (point-max) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (while (and articles is-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
271 (when (search-forward (nnbabyl-article-string (car articles)) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
272 (if (setq is-old
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
273 (nnmail-expired-article-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
274 newsgroup
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
275 (buffer-substring
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
276 (point) (progn (end-of-line) (point))) force))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
277 (progn
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
278 (nnheader-message 5 "Deleting article %d in %s..."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
279 (car articles) newsgroup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
280 (nnbabyl-delete-mail))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
281 (push (car articles) rest)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq articles (cdr articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; Find the lowest active article in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (let ((active (nth 1 (assoc newsgroup nnbabyl-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while (and (not (search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (nnbabyl-article-string (car active)) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (<= (car active) (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setcar active (1+ (car active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (nconc rest articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
295 (deffoo nnbabyl-request-move-article
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (article group server accept-form &optional last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let ((buf (get-buffer-create " *nnbabyl move*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 result)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
299 (and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (nnbabyl-request-article article group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (insert-buffer-substring nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (goto-char (point-min))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
305 (while (re-search-forward
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
306 "^X-Gnus-Newsgroup:"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
307 (save-excursion (search-forward "\n\n" nil t) (point)) t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
308 (delete-region (progn (beginning-of-line) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
309 (progn (forward-line 1) (point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq result (eval accept-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
314 (nnbabyl-possibly-change-newsgroup group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (if (search-forward (nnbabyl-article-string article) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (nnbabyl-delete-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (and last (save-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (deffoo nnbabyl-request-accept-article (group &optional server last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (nnbabyl-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (nnmail-check-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (let ((buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 result beg)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
327 (and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (nnmail-activate 'nnbabyl)
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 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (while (re-search-backward "^X-Gnus-Newsgroup: " beg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (delete-region (point) (progn (forward-line 1) (point)))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
336 (nnmail-cache-insert (nnmail-fetch-field "message-id"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
337 (setq result (car (nnbabyl-save-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
338 (if (stringp group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
339 (list (cons group (nnbabyl-active-number group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
340 (nnmail-article-group 'nnbabyl-active-number)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (search-backward "\n\^_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (insert-buffer-substring buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (when last
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
347 (nnmail-cache-insert (nnmail-fetch-field "message-id"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (deffoo nnbabyl-request-replace-article (article group buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (nnbabyl-possibly-change-newsgroup group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (if (not (search-forward (nnbabyl-article-string article) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (nnbabyl-delete-mail t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (deffoo nnbabyl-request-delete-group (group &optional force server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (nnbabyl-possibly-change-newsgroup group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; Delete all articles in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (if (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 () ; Don't delete the articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; Delete all articles in this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (nnbabyl-delete-mail))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
378 (when found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
379 (save-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; Remove the group from all structures.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
381 (setq nnbabyl-group-alist
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (delq (assoc group nnbabyl-group-alist) nnbabyl-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 nnbabyl-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; Save the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (deffoo nnbabyl-request-rename-group (group new-name &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (nnbabyl-possibly-change-newsgroup group server)
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 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (new-ident (concat "\nX-Gnus-Newsgroup: " new-name ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (while (search-forward ident nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (replace-match new-ident t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq found t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
399 (when found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
400 (save-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (let ((entry (assoc group nnbabyl-group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (and entry (setcar entry new-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq nnbabyl-current-group nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; Save the new group alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; If FORCE, delete article no matter how many X-Gnus-Newsgroup
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
412 ;; headers there are. If LEAVE-DELIM, don't delete the Unix mbox
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; delimiter line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defun nnbabyl-delete-mail (&optional force leave-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; Delete the current X-Gnus-Newsgroup line.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
416 (unless force
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
417 (delete-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
418 (progn (beginning-of-line) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
419 (progn (forward-line 1) (point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; Beginning of the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
426 (unless (re-search-backward (concat "^" nnbabyl-mail-delimiter) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
427 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
428 (end-of-line))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (if leave-delim (progn (forward-line 1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (forward-line 1)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
433 (or (and (re-search-forward (concat "^" nnbabyl-mail-delimiter)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 nil t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
435 (match-beginning 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; 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
439 (when (or force (not (re-search-forward "^X-Gnus-Newsgroup: " nil t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
440 (delete-region (point-min) (point-max))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun nnbabyl-possibly-change-newsgroup (newsgroup &optional server)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
443 (when (and server
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (not (nnbabyl-server-opened server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (nnbabyl-open-server server))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
446 (when (or (not nnbabyl-mbox-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
447 (not (buffer-name nnbabyl-mbox-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
448 (save-excursion (nnbabyl-read-mbox)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
449 (unless nnbabyl-group-alist
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
450 (nnmail-activate 'nnbabyl))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (if newsgroup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (if (assoc newsgroup nnbabyl-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (setq nnbabyl-current-group newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (nnheader-report 'nnbabyl "No such group in file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun nnbabyl-article-string (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (numberp article)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
459 (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (int-to-string article) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (concat "\nMessage-ID: " article)))
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 nnbabyl-article-group-number ()
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 (re-search-forward "^X-Gnus-Newsgroup: +\\([^:]+\\):\\([0-9]+\\) "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
467 nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
468 (cons (buffer-substring (match-beginning 1) (match-end 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
469 (string-to-int
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
470 (buffer-substring (match-beginning 2) (match-end 2)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun nnbabyl-insert-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 "Insert how many lines and chars there are in the body of the mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let (lines chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
477 (when (search-forward "\n\n" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; There may be an EOOH line here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (when (looking-at "\\*\\*\\* EOOH \\*\\*\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (search-forward "\n\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (setq chars (- (point-max) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 lines (max (- (count-lines (point) (point-max)) 1) 0))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
483 ;; Move back to the end of the headers.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (when (re-search-backward "^Lines: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (delete-region (point) (progn (forward-line 1) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (insert (format "Lines: %d\n" lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 chars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
493 (defun nnbabyl-save-mail (group-art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; Called narrowed to an article.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
495 (nnbabyl-insert-lines)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
496 (nnmail-insert-xref group-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
497 (nnbabyl-insert-newsgroup-line group-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
498 (run-hooks 'nnbabyl-prepare-save-mail-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
499 group-art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (defun nnbabyl-insert-newsgroup-line (group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (while (looking-at "From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (replace-match "Mail-from: From " t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; If there is a C-l at the beginning of the narrowed region, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; isn't really a "save", but rather a "scan".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
510 (unless (looking-at "\^L")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
511 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
512 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
513 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
514 (insert "\^_\n")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
515 (when (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
516 (forward-char -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
517 (while group-art
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
518 (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
519 (caar group-art) (cdar group-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
520 (current-time-string)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
521 (setq group-art (cdr group-art))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun nnbabyl-active-number (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; Find the next article number in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (let ((active (cadr (assoc group nnbabyl-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (setcdr active (1+ (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; This group is new, so we create a new entry for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; This might be a bit naughty... creating groups on the drop of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;; a hat, but I don't know...
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
532 (push (list group (setq active (cons 1 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
533 nnbabyl-group-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
536 (defun nnbabyl-create-mbox ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (unless (file-exists-p nnbabyl-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; Create a new, empty RMAIL mbox file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (set-buffer (setq nnbabyl-mbox-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (create-file-buffer nnbabyl-mbox-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (setq buffer-file-name nnbabyl-mbox-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (insert "BABYL OPTIONS:\n\n\^_")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
544 (nnmail-write-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
545 (point-min) (point-max) nnbabyl-mbox-file t 'nomesg))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
547 (defun nnbabyl-read-mbox ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
548 (nnmail-activate 'nnbabyl)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
549 (nnbabyl-create-mbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
550
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
551 (unless (and nnbabyl-mbox-buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (buffer-name nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (set-buffer nnbabyl-mbox-buffer)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
555 (= (buffer-size) (nnheader-file-size nnbabyl-mbox-file))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
556 ;; This buffer has changed since we read it last. Possibly.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (let ((delim (concat "^" nnbabyl-mail-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (alist nnbabyl-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 start end number)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
561 (set-buffer (setq nnbabyl-mbox-buffer
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
562 (nnheader-find-file-noselect
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 nnbabyl-mbox-file nil 'raw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; Save previous buffer mode.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
565 (setq nnbabyl-previous-buffer-mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (cons (cons (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; Go through the group alist and compare against
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; the rmail file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (when (and (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (format "^X-Gnus-Newsgroup: %s:\\([0-9]+\\) "
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
580 (caar alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
581 nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (> (setq number
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
583 (string-to-number
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (cdadar alist)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
587 (setcdr (cadar alist) number))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (setq alist (cdr alist)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
589
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
590 ;; We go through the mbox and make sure that each and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; every mail belongs to some group or other.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
593 (if (looking-at "\^L")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
594 (setq start (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
595 (re-search-forward delim nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
596 (setq start (match-end 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (while (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (setq end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (unless (search-backward "\nX-Gnus-Newsgroup: " start t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (narrow-to-region (goto-char start) end)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
604 (nnbabyl-save-mail
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
605 (nnmail-article-group 'nnbabyl-active-number))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq end (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (goto-char (setq start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (when (buffer-modified-p (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defun nnbabyl-remove-incoming-delims ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (while (search-forward "\^_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (replace-match "?" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (defun nnbabyl-check-mbox ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 "Go through the nnbabyl mbox and make sure that no article numbers are reused."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (let ((idents (make-vector 1000 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (when (or (not nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (not (buffer-name nnbabyl-mbox-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (nnbabyl-read-mbox))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (set-buffer nnbabyl-mbox-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (while (re-search-forward "^X-Gnus-Newsgroup: \\([^ ]+\\) " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (if (intern-soft (setq id (match-string 1)) idents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (nnheader-message 7 "Moving %s..." id)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
634 (nnbabyl-save-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
635 (nnmail-article-group 'nnbabyl-active-number)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (intern id idents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (when (buffer-modified-p (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (message ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (provide 'nnbabyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;;; nnbabyl.el ends here