annotate lisp/nnbabyl.el @ 16241:3c84b8d28902

(rmail-insert-inbox-text): Detect locked RMAIL files at the outset, before copying any files. (rmail-find-all-files): Eliminate recursive scan. Rely on directory-files to do the filtering. (rmail-convert-to-babyl-format): Increase sit-for timeout to 3 seconds. (rmail-get-new-mail): Handle files in multiple batches, in case two inboxes have the same last name component. (rmail-show-message): Bind `end' after clearing the "unseen" attribute. (rmail-show-message): Clear `unseen' even if header is already reformatted--but don't do it if rmail-not-really-seen. (rmail-not-really-seen): New variable.
author Richard M. Stallman <rms@gnu.org>
date Thu, 19 Sep 1996 03:21:11 +0000
parents 8d8bf85d356a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
1 ;;; nnbabyl.el --- rmail mbox access for Gnus
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
3
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
6 ;; Keywords: news, mail
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
7
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
9
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
13 ;; any later version.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
14
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
19
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
23 ;; Boston, MA 02111-1307, USA.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
24
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
25 ;;; Commentary:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
26
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
27 ;; For an overview of what the interface functions do, please see the
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
28 ;; Gnus sources.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
29
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
30 ;;; Code:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
31
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
32 (require 'nnheader)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
33 (require 'rmail)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
34 (require 'nnmail)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
35 (require 'nnoo)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
36 (eval-when-compile (require 'cl))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
37
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
38 (nnoo-declare nnbabyl)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
39
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
40 (defvoo nnbabyl-mbox-file (expand-file-name "~/RMAIL")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
41 "The name of the rmail box file in the users home directory.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
42
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
43 (defvoo nnbabyl-active-file (expand-file-name "~/.rmail-active")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
44 "The name of the active file for the rmail box.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
45
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
46 (defvoo nnbabyl-get-new-mail t
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
47 "If non-nil, nnbabyl will check the incoming mail file and split the mail.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
48
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
49 (defvoo nnbabyl-prepare-save-mail-hook nil
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
50 "Hook run narrowed to an article before saving.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
51
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
52
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
53
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
54 (defvar nnbabyl-mail-delimiter "\^_")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
55
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
56 (defconst nnbabyl-version "nnbabyl 1.0"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
57 "nnbabyl version.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
58
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
59 (defvoo nnbabyl-mbox-buffer nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
60 (defvoo nnbabyl-current-group nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
61 (defvoo nnbabyl-status-string "")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
62 (defvoo nnbabyl-group-alist nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
63 (defvoo nnbabyl-active-timestamp nil)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
64
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
65 (defvoo nnbabyl-previous-buffer-mode nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
66
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
67 (eval-and-compile
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
68 (autoload 'gnus-set-text-properties "gnus-ems"))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
69
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
70
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
71
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
72 ;;; Interface functions
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
73
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
74 (nnoo-define-basics nnbabyl)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
75
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
76 (deffoo nnbabyl-retrieve-headers (articles &optional group server fetch-old)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
77 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
78 (set-buffer nntp-server-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
79 (erase-buffer)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
80 (let ((number (length articles))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
81 (count 0)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
82 (delim (concat "^" nnbabyl-mail-delimiter))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
83 article art-string start stop)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
84 (nnbabyl-possibly-change-newsgroup group server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
85 (while (setq article (pop articles))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
86 (setq art-string (nnbabyl-article-string article))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
87 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
88 (beginning-of-line)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
89 (when (or (search-forward art-string nil t)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
90 (search-backward art-string nil t))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
91 (re-search-backward delim nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
92 (while (and (not (looking-at ".+:"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
93 (zerop (forward-line 1))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
94 (setq start (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
95 (search-forward "\n\n" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
96 (setq stop (1- (point)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
97 (set-buffer nntp-server-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
98 (insert "221 ")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
99 (princ article (current-buffer))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
100 (insert " Article retrieved.\n")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
101 (insert-buffer-substring nnbabyl-mbox-buffer start stop)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
102 (goto-char (point-max))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
103 (insert ".\n"))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
104 (and (numberp nnmail-large-newsgroup)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
105 (> number nnmail-large-newsgroup)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
106 (zerop (% (incf count) 20))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
107 (nnheader-message 5 "nnbabyl: Receiving headers... %d%%"
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
108 (/ (* count 100) number))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
109
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
110 (and (numberp nnmail-large-newsgroup)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
111 (> number nnmail-large-newsgroup)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
112 (nnheader-message 5 "nnbabyl: Receiving headers...done"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
113
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
114 (set-buffer nntp-server-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
115 (nnheader-fold-continuation-lines)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
116 'headers)))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
117
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
118 (deffoo nnbabyl-open-server (server &optional defs)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
119 (nnoo-change-server 'nnbabyl server defs)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
120 (cond
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
121 ((not (file-exists-p nnbabyl-mbox-file))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
122 (nnbabyl-close-server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
123 (nnheader-report 'nnbabyl "No such file: %s" nnbabyl-mbox-file))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
124 ((file-directory-p nnbabyl-mbox-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
125 (nnbabyl-close-server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
126 (nnheader-report 'nnbabyl "Not a regular file: %s" nnbabyl-mbox-file))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
127 (t
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
128 (nnheader-report 'nnbabyl "Opened server %s using mbox %s" server
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
129 nnbabyl-mbox-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
130 t)))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
131
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
132 (deffoo nnbabyl-close-server (&optional server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
133 ;; Restore buffer mode.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
134 (when (and (nnbabyl-server-opened)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
135 nnbabyl-previous-buffer-mode)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
136 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
137 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
138 (narrow-to-region
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
139 (caar nnbabyl-previous-buffer-mode)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
140 (cdar nnbabyl-previous-buffer-mode))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
141 (funcall (cdr nnbabyl-previous-buffer-mode))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
142 (nnoo-close-server 'nnbabyl server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
143 (setq nnbabyl-mbox-buffer nil)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
144 t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
145
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
146 (deffoo nnbabyl-server-opened (&optional server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
147 (and (nnoo-current-server-p 'nnbabyl server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
148 nnbabyl-mbox-buffer
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
149 (buffer-name nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
150 nntp-server-buffer
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
151 (buffer-name nntp-server-buffer)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
152
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
153 (deffoo nnbabyl-request-article (article &optional newsgroup server buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
154 (nnbabyl-possibly-change-newsgroup newsgroup server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
155 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
156 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
157 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
158 (when (search-forward (nnbabyl-article-string article) nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
159 (let (start stop summary-line)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
160 (re-search-backward (concat "^" nnbabyl-mail-delimiter) nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
161 (while (and (not (looking-at ".+:"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
162 (zerop (forward-line 1))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
163 (setq start (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
164 (or (and (re-search-forward
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
165 (concat "^" nnbabyl-mail-delimiter) nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
166 (forward-line -1))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
167 (goto-char (point-max)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
168 (setq stop (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
169 (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
170 (set-buffer nntp-server-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
171 (erase-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
172 (insert-buffer-substring nnbabyl-mbox-buffer start stop)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
173 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
174 ;; If there is an EOOH header, then we have to remove some
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
175 ;; duplicated headers.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
176 (setq summary-line (looking-at "Summary-line:"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
177 (when (search-forward "\n*** EOOH ***" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
178 (if summary-line
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
179 ;; The headers to be deleted are located before the
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
180 ;; EOOH line...
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
181 (delete-region (point-min) (progn (forward-line 1)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
182 (point)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
183 ;; ...or after.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
184 (delete-region (progn (beginning-of-line) (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
185 (or (search-forward "\n\n" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
186 (point)))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
187 (if (numberp article)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
188 (cons nnbabyl-current-group article)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
189 (nnbabyl-article-group-number)))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
190
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
191 (deffoo nnbabyl-request-group (group &optional server dont-check)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
192 (let ((active (cadr (assoc group nnbabyl-group-alist))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
193 (save-excursion
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
194 (cond
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
195 ((or (null active)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
196 (null (nnbabyl-possibly-change-newsgroup group server)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
197 (nnheader-report 'nnbabyl "No such group: %s" group))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
198 (dont-check
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
199 (nnheader-report 'nnbabyl "Selected group %s" group)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
200 (nnheader-insert ""))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
201 (t
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
202 (nnheader-report 'nnbabyl "Selected group %s" group)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
203 (nnheader-insert "211 %d %d %d %s\n"
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
204 (1+ (- (cdr active) (car active)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
205 (car active) (cdr active) group))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
206
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
207 (deffoo nnbabyl-request-scan (&optional group server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
208 (nnbabyl-read-mbox)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
209 (nnmail-get-new-mail
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
210 'nnbabyl
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
211 (lambda ()
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
212 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
213 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
214 (save-buffer)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
215 nnbabyl-mbox-file group
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
216 (lambda ()
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
217 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
218 (let ((in-buf (current-buffer)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
219 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
220 (while (search-forward "\n\^_\n" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
221 (delete-char -1))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
222 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
223 (goto-char (point-max))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
224 (search-backward "\n\^_" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
225 (goto-char (match-end 0))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
226 (insert-buffer-substring in-buf)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
227 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
228
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
229 (deffoo nnbabyl-close-group (group &optional server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
230 t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
231
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
232 (deffoo nnbabyl-request-create-group (group &optional server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
233 (nnmail-activate 'nnbabyl)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
234 (unless (assoc group nnbabyl-group-alist)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
235 (setq nnbabyl-group-alist (cons (list group (cons 1 0))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
236 nnbabyl-group-alist))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
237 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
238 t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
239
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
240 (deffoo nnbabyl-request-list (&optional server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
241 (save-excursion
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
242 (nnmail-find-file nnbabyl-active-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
243 (setq nnbabyl-group-alist (nnmail-get-active))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
244
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
245 (deffoo nnbabyl-request-newgroups (date &optional server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
246 (nnbabyl-request-list server))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
247
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
248 (deffoo nnbabyl-request-list-newsgroups (&optional server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
249 (nnheader-report 'nnbabyl "nnbabyl: LIST NEWSGROUPS is not implemented."))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
250
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
251 (deffoo nnbabyl-request-expire-articles
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
252 (articles newsgroup &optional server force)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
253 (nnbabyl-possibly-change-newsgroup newsgroup server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
254 (let* ((is-old t)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
255 rest)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
256 (nnmail-activate 'nnbabyl)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
257
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
258 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
259 (set-buffer nnbabyl-mbox-buffer)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
260 (gnus-set-text-properties (point-min) (point-max) nil)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
261 (while (and articles is-old)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
262 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
263 (if (search-forward (nnbabyl-article-string (car articles)) nil t)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
264 (if (setq is-old
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
265 (nnmail-expired-article-p
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
266 newsgroup
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
267 (buffer-substring
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
268 (point) (progn (end-of-line) (point))) force))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
269 (progn
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
270 (nnheader-message 5 "Deleting article %d in %s..."
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
271 (car articles) newsgroup)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
272 (nnbabyl-delete-mail))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
273 (setq rest (cons (car articles) rest))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
274 (setq articles (cdr articles)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
275 (save-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
276 ;; Find the lowest active article in this group.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
277 (let ((active (nth 1 (assoc newsgroup nnbabyl-group-alist))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
278 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
279 (while (and (not (search-forward
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
280 (nnbabyl-article-string (car active)) nil t))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
281 (<= (car active) (cdr active)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
282 (setcar active (1+ (car active)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
283 (goto-char (point-min))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
284 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
285 (nconc rest articles))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
286
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
287 (deffoo nnbabyl-request-move-article
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
288 (article group server accept-form &optional last)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
289 (nnbabyl-possibly-change-newsgroup group server)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
290 (let ((buf (get-buffer-create " *nnbabyl move*"))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
291 result)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
292 (and
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
293 (nnbabyl-request-article article group server)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
294 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
295 (set-buffer buf)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
296 (insert-buffer-substring nntp-server-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
297 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
298 (if (re-search-forward
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
299 "^X-Gnus-Newsgroup:"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
300 (save-excursion (search-forward "\n\n" nil t) (point)) t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
301 (delete-region (progn (beginning-of-line) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
302 (progn (forward-line 1) (point))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
303 (setq result (eval accept-form))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
304 (kill-buffer (current-buffer))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
305 result)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
306 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
307 (set-buffer nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
308 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
309 (if (search-forward (nnbabyl-article-string article) nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
310 (nnbabyl-delete-mail))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
311 (and last (save-buffer))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
312 result))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
313
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
314 (deffoo nnbabyl-request-accept-article (group &optional server last)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
315 (nnbabyl-possibly-change-newsgroup group server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
316 (nnmail-check-syntax)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
317 (let ((buf (current-buffer))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
318 result beg)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
319 (and
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
320 (nnmail-activate 'nnbabyl)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
321 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
322 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
323 (search-forward "\n\n" nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
324 (forward-line -1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
325 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
326 (while (re-search-backward "^X-Gnus-Newsgroup: " beg t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
327 (delete-region (point) (progn (forward-line 1) (point)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
328 (let ((nnmail-split-methods
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
329 (if (stringp group) (list (list group ""))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
330 nnmail-split-methods)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
331 (setq result (car (nnbabyl-save-mail))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
332 (set-buffer nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
333 (goto-char (point-max))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
334 (search-backward "\n\^_")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
335 (goto-char (match-end 0))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
336 (insert-buffer-substring buf)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
337 (when last
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
338 (save-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
339 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
340 result))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
341
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
342 (deffoo nnbabyl-request-replace-article (article group buffer)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
343 (nnbabyl-possibly-change-newsgroup group)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
344 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
345 (set-buffer nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
346 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
347 (if (not (search-forward (nnbabyl-article-string article) nil t))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
348 nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
349 (nnbabyl-delete-mail t t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
350 (insert-buffer-substring buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
351 (save-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
352 t)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
353
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
354 (deffoo nnbabyl-request-delete-group (group &optional force server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
355 (nnbabyl-possibly-change-newsgroup group server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
356 ;; Delete all articles in GROUP.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
357 (if (not force)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
358 () ; Don't delete the articles.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
359 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
360 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
361 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
362 ;; Delete all articles in this group.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
363 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
364 found)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
365 (while (search-forward ident nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
366 (setq found t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
367 (nnbabyl-delete-mail))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
368 (and found (save-buffer)))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
369 ;; Remove the group from all structures.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
370 (setq nnbabyl-group-alist
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
371 (delq (assoc group nnbabyl-group-alist) nnbabyl-group-alist)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
372 nnbabyl-current-group nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
373 ;; Save the active file.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
374 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
375 t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
376
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
377 (deffoo nnbabyl-request-rename-group (group new-name &optional server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
378 (nnbabyl-possibly-change-newsgroup group server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
379 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
380 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
381 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
382 (let ((ident (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
383 (new-ident (concat "\nX-Gnus-Newsgroup: " new-name ":"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
384 found)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
385 (while (search-forward ident nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
386 (replace-match new-ident t t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
387 (setq found t))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
388 (and found (save-buffer))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
389 (let ((entry (assoc group nnbabyl-group-alist)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
390 (and entry (setcar entry new-name))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
391 (setq nnbabyl-current-group nil)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
392 ;; Save the new group alist.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
393 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
394 t))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
395
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
396
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
397 ;;; Internal functions.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
398
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
399 ;; If FORCE, delete article no matter how many X-Gnus-Newsgroup
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
400 ;; headers there are. If LEAVE-DELIM, don't delete the Unix mbox
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13401
diff changeset
401 ;; delimiter line.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
402 (defun nnbabyl-delete-mail (&optional force leave-delim)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
403 ;; Delete the current X-Gnus-Newsgroup line.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
404 (or force
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
405 (delete-region
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
406 (progn (beginning-of-line) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
407 (progn (forward-line 1) (point))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
408 ;; Beginning of the article.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
409 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
410 (save-restriction
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
411 (widen)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
412 (narrow-to-region
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
413 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
414 (re-search-backward (concat "^" nnbabyl-mail-delimiter) nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
415 (if leave-delim (progn (forward-line 1) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
416 (match-beginning 0)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
417 (progn
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
418 (forward-line 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
419 (or (and (re-search-forward (concat "^" nnbabyl-mail-delimiter)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
420 nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
421 (if (and (not (bobp)) leave-delim)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
422 (progn (forward-line -2) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
423 (match-beginning 0)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
424 (point-max))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
425 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
426 ;; Only delete the article if no other groups owns it as well.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
427 (if (or force (not (re-search-forward "^X-Gnus-Newsgroup: " nil t)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
428 (delete-region (point-min) (point-max))))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
429
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
430 (defun nnbabyl-possibly-change-newsgroup (newsgroup &optional server)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
431 (when (and server
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
432 (not (nnbabyl-server-opened server)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
433 (nnbabyl-open-server server))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
434 (if (or (not nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
435 (not (buffer-name nnbabyl-mbox-buffer)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
436 (save-excursion (nnbabyl-read-mbox)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
437 (or nnbabyl-group-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
438 (nnmail-activate 'nnbabyl))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
439 (if newsgroup
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
440 (if (assoc newsgroup nnbabyl-group-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
441 (setq nnbabyl-current-group newsgroup)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
442 (nnheader-report 'nnbabyl "No such group in file"))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
443 t))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
444
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
445 (defun nnbabyl-article-string (article)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
446 (if (numberp article)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
447 (concat "\nX-Gnus-Newsgroup: " nnbabyl-current-group ":"
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
448 (int-to-string article) " ")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
449 (concat "\nMessage-ID: " article)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
450
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
451 (defun nnbabyl-article-group-number ()
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
452 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
453 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
454 (and (re-search-forward "^X-Gnus-Newsgroup: +\\([^:]+\\):\\([0-9]+\\) "
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
455 nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
456 (cons (buffer-substring (match-beginning 1) (match-end 1))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
457 (string-to-int
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
458 (buffer-substring (match-beginning 2) (match-end 2)))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
459
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
460 (defun nnbabyl-insert-lines ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
461 "Insert how many lines and chars there are in the body of the mail."
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
462 (let (lines chars)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
463 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
464 (goto-char (point-min))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
465 (when (search-forward "\n\n" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
466 ;; There may be an EOOH line here...
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
467 (when (looking-at "\\*\\*\\* EOOH \\*\\*\\*")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
468 (search-forward "\n\n" nil t))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
469 (setq chars (- (point-max) (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
470 lines (max (- (count-lines (point) (point-max)) 1) 0))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
471 ;; Move back to the end of the headers.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
472 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
473 (search-forward "\n\n" nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
474 (forward-char -1)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
475 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
476 (when (re-search-backward "^Lines: " nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
477 (delete-region (point) (progn (forward-line 1) (point)))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
478 (insert (format "Lines: %d\n" lines))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
479 chars))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
480
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
481 (defun nnbabyl-save-mail ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
482 ;; Called narrowed to an article.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
483 (let ((group-art (nreverse (nnmail-article-group 'nnbabyl-active-number))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
484 (nnbabyl-insert-lines)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
485 (nnmail-insert-xref group-art)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
486 (nnbabyl-insert-newsgroup-line group-art)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
487 (run-hooks 'nnbabyl-prepare-save-mail-hook)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
488 group-art))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
489
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
490 (defun nnbabyl-insert-newsgroup-line (group-art)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
491 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
492 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
493 (while (looking-at "From ")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
494 (replace-match "Mail-from: From " t t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
495 (forward-line 1))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
496 ;; If there is a C-l at the beginning of the narrowed region, this
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
497 ;; isn't really a "save", but rather a "scan".
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
498 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
499 (or (looking-at "\^L")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
500 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
501 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
502 (goto-char (point-max))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
503 (insert "\^_\n")))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
504 (if (search-forward "\n\n" nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
505 (progn
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
506 (forward-char -1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
507 (while group-art
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
508 (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
509 (caar group-art) (cdar group-art)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
510 (current-time-string)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
511 (setq group-art (cdr group-art)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
512 t))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
513
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
514 (defun nnbabyl-active-number (group)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
515 ;; Find the next article number in GROUP.
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
516 (let ((active (cadr (assoc group nnbabyl-group-alist))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
517 (if active
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
518 (setcdr active (1+ (cdr active)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
519 ;; This group is new, so we create a new entry for it.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
520 ;; This might be a bit naughty... creating groups on the drop of
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
521 ;; a hat, but I don't know...
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
522 (setq nnbabyl-group-alist (cons (list group (setq active (cons 1 1)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
523 nnbabyl-group-alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
524 (cdr active)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
525
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
526 (defun nnbabyl-read-mbox ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
527 (nnmail-activate 'nnbabyl)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
528 (unless (file-exists-p nnbabyl-mbox-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
529 ;; Create a new, empty RMAIL mbox file.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
530 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
531 (set-buffer (setq nnbabyl-mbox-buffer
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
532 (create-file-buffer nnbabyl-mbox-file)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
533 (setq buffer-file-name nnbabyl-mbox-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
534 (insert "BABYL OPTIONS:\n\n\^_")
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
535 (write-region (point-min) (point-max) nnbabyl-mbox-file t 'nomesg)))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
536
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
537 (if (and nnbabyl-mbox-buffer
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
538 (buffer-name nnbabyl-mbox-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
539 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
540 (set-buffer nnbabyl-mbox-buffer)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
541 (= (buffer-size) (nnheader-file-size nnbabyl-mbox-file))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
542 () ; This buffer hasn't changed since we read it last. Possibly.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
543 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
544 (let ((delim (concat "^" nnbabyl-mail-delimiter))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
545 (alist nnbabyl-group-alist)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
546 start end number)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
547 (set-buffer (setq nnbabyl-mbox-buffer
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
548 (nnheader-find-file-noselect
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
549 nnbabyl-mbox-file nil 'raw)))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
550 ;; Save previous buffer mode.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
551 (setq nnbabyl-previous-buffer-mode
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
552 (cons (cons (point-min) (point-max))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
553 major-mode))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
554
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
555 (buffer-disable-undo (current-buffer))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
556 (widen)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
557 (setq buffer-read-only nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
558 (fundamental-mode)
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
560 ;; Go through the group alist and compare against
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
561 ;; the rmail file.
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
562 (while alist
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
563 (goto-char (point-max))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
564 (when (and (re-search-backward
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
565 (format "^X-Gnus-Newsgroup: %s:\\([0-9]+\\) "
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
566 (caar alist)) nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
567 (> (setq number
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
568 (string-to-number
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
569 (buffer-substring
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
570 (match-beginning 1) (match-end 1))))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
571 (cdadar alist)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
572 (setcdr (cadar alist) (1+ number)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
573 (setq alist (cdr alist)))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
574
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
575 ;; We go through the mbox and make sure that each and
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
576 ;; every mail belongs to some group or other.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
577 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
578 (re-search-forward delim nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
579 (setq start (match-end 0))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
580 (while (re-search-forward delim nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
581 (setq end (match-end 0))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
582 (unless (search-backward "\nX-Gnus-Newsgroup: " start t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
583 (goto-char end)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
584 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
585 (save-restriction
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
586 (narrow-to-region (goto-char start) end)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
587 (nnbabyl-save-mail)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
588 (setq end (point-max)))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
589 (goto-char (setq start end)))
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
590 (when (buffer-modified-p (current-buffer))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
591 (save-buffer))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
592 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
593
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
594 (defun nnbabyl-remove-incoming-delims ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
595 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
596 (while (search-forward "\^_" nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
597 (replace-match "?" t t)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
598
15559
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
599 (defun nnbabyl-check-mbox ()
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
600 "Go through the nnbabyl mbox and make sure that no article numbers are reused."
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
601 (interactive)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
602 (let ((idents (make-vector 1000 0))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
603 id)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
604 (save-excursion
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
605 (when (or (not nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
606 (not (buffer-name nnbabyl-mbox-buffer)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
607 (nnbabyl-read-mbox))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
608 (set-buffer nnbabyl-mbox-buffer)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
609 (goto-char (point-min))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
610 (while (re-search-forward "^X-Gnus-Newsgroup: \\([^ ]+\\) " nil t)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
611 (if (intern-soft (setq id (match-string 1)) idents)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
612 (progn
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
613 (delete-region (progn (beginning-of-line) (point))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
614 (progn (forward-line 1) (point)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
615 (nnheader-message 7 "Moving %s..." id)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
616 (nnbabyl-save-mail))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
617 (intern id idents)))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
618 (when (buffer-modified-p (current-buffer))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
619 (save-buffer))
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
620 (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
8d8bf85d356a Synched with Gnus 5.2.31.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14040
diff changeset
621 (message ""))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
622
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
623 (provide 'nnbabyl)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
624
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
625 ;;; nnbabyl.el ends here