annotate lisp/gnus/nnmh.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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 ;;; nnmh.el --- mhspool access for Gnus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
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 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; For an overview of what the interface functions do, please see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; Gnus sources.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'nnheader)
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 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (require 'nnoo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (eval-and-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (nnoo-declare nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvoo nnmh-directory message-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*Mail spool directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvoo nnmh-get-new-mail t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "*If non-nil, nnmh will check the incoming mail file and split the mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvoo nnmh-prepare-save-mail-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "*Hook run narrowed to an article before saving.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvoo nnmh-be-safe nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "*If non-nil, nnmh will check all articles to make sure whether they are new or not.")
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defconst nnmh-version "nnmh 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "nnmh version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvoo nnmh-current-directory nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Current news group directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvoo nnmh-status-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvoo nnmh-group-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Interface functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (nnoo-define-basics nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (deffoo nnmh-retrieve-headers (articles &optional newsgroup server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let* ((file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (number (length articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (large (and (numberp nnmail-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (> number nnmail-large-newsgroup)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 beg article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (nnmh-possibly-change-directory newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; We don't support fetching by Message-ID.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (stringp (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 'headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (when (and (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq file (concat (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 nnmh-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq article (pop articles))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (not (file-directory-p file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (insert (format "221 %d Article retrieved.\n" article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (nnheader-insert-head file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (insert "\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (insert ".\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (delete-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq count (1+ count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (and large
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (zerop (% count 20))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (message "nnmh: Receiving headers... %d%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (/ (* count 100) number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (and large (message "nnmh: Receiving headers...done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 'headers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (deffoo nnmh-open-server (server &optional defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (nnoo-change-server 'nnmh server defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (when (not (file-exists-p nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (make-directory nnmh-directory t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ((not (file-exists-p nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (nnmh-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (nnheader-report 'nnmh "Couldn't create directory: %s" nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((not (file-directory-p (file-truename nnmh-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (nnmh-close-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (nnheader-report 'nnmh "Not a directory: %s" nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (nnheader-report 'nnmh "Opened server %s using directory %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 server nnmh-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (deffoo nnmh-request-article (id &optional newsgroup server buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (nnmh-possibly-change-directory newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let ((file (if (stringp id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (concat nnmh-current-directory (int-to-string id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (nntp-server-buffer (or buffer nntp-server-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (and (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (not (file-directory-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (save-excursion (nnmail-find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (string-to-int (file-name-nondirectory file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (deffoo nnmh-request-group (group &optional server dont-check)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (let ((pathname (nnmail-group-pathname group nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((not (file-directory-p pathname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (nnheader-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 'nnmh "Can't select group (no such directory): %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq nnmh-current-directory pathname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (and nnmh-get-new-mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 nnmh-be-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (nnmh-update-gnus-unreads group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (dont-check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (nnheader-report 'nnmh "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (mapcar (lambda (name) (string-to-int name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (directory-files pathname nil "^[0-9]+$" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (nnheader-report 'nnmh "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (nnheader-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "211 %d %d %d %s\n" (length dir) (car dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (progn (while (cdr dir) (setq dir (cdr dir))) (car dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (nnheader-report 'nnmh "Empty group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (nnheader-insert (format "211 0 1 0 %s\n" group))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (deffoo nnmh-request-scan (&optional group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (nnmail-get-new-mail 'nnmh nil nnmh-directory group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (deffoo nnmh-request-list (&optional server dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (nnheader-insert "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (let ((nnmh-toplev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (or dir (file-truename (file-name-as-directory nnmh-directory)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (nnmh-request-list-1 nnmh-toplev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq nnmh-group-alist (nnmail-get-active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defvar nnmh-toplev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun nnmh-request-list-1 (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (setq dir (expand-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; Recurse down all directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (let ((dirs (and (file-readable-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (> (nth 1 (file-attributes (file-chase-links dir))) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (directory-files dir t nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; Recurse down directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (while (setq dir (pop dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (when (and (not (member (file-name-nondirectory dir) '("." "..")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (file-directory-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (file-readable-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (nnmh-request-list-1 dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; For each directory, generate an active file line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (unless (string= (expand-file-name nnmh-toplev) dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let ((files (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (lambda (name) (string-to-int name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (directory-files dir nil "^[0-9]+$" t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (when files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "%s %d %d y\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (file-truename (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (expand-file-name nnmh-toplev)))) dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (nnheader-replace-chars-in-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (substring dir (match-end 0)) ?/ ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (apply 'max files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (apply 'min files)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (deffoo nnmh-request-newgroups (date &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (nnmh-request-list server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (deffoo nnmh-request-expire-articles (articles newsgroup &optional server force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (nnmh-possibly-change-directory newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let* ((active-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (lambda (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (string-to-int name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (directory-files nnmh-current-directory nil "^[0-9]+$" t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (is-old t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 article rest mod-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (nnmail-activate 'nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (while (and articles is-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq article (concat nnmh-current-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (int-to-string (car articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if (setq mod-time (nth 5 (file-attributes article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (if (and (nnmh-deletable-article-p newsgroup (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq is-old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (nnmail-expired-article-p newsgroup mod-time force)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (nnheader-message 5 "Deleting article %s in %s..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 article newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (funcall nnmail-delete-file-function article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (nnheader-message 1 "Couldn't delete article %s in %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 article newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq rest (cons (car articles) rest)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq rest (cons (car articles) rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq articles (cdr articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (nconc rest articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (deffoo nnmh-close-group (group &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (deffoo nnmh-request-move-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (article group server accept-form &optional last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (let ((buf (get-buffer-create " *nnmh move*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (nnmh-deletable-article-p group article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (nnmh-request-article article group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (insert-buffer-substring nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (setq result (eval accept-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (nnmh-possibly-change-directory group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (funcall nnmail-delete-file-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (concat nnmh-current-directory (int-to-string article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (file-error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (deffoo nnmh-request-accept-article (group &optional server last noinsert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (nnmh-possibly-change-directory group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (nnmail-check-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if (stringp group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (nnmail-activate 'nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; We trick the choosing function into believing that only one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; group is available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (let ((nnmail-split-methods (list (list group ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (car (nnmh-save-mail noinsert))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (nnmail-activate 'nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (car (nnmh-save-mail noinsert)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (deffoo nnmh-request-replace-article (article group buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (nnmh-possibly-change-directory group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (nnmh-possibly-create-directory group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (concat nnmh-current-directory (int-to-string article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 nil (if (nnheader-be-verbose 5) nil 'nomesg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (deffoo nnmh-request-create-group (group &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (nnmail-activate 'nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (or (assoc group nnmh-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (let (active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setq nnmh-group-alist (cons (list group (setq active (cons 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 nnmh-group-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (nnmh-possibly-create-directory group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (nnmh-possibly-change-directory group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (let ((articles (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (lambda (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (string-to-int file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (directory-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 nnmh-current-directory nil "^[0-9]+$"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (and articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setcar active (apply 'min articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setcdr active (apply 'max articles)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (deffoo nnmh-request-delete-group (group &optional force server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (nnmh-possibly-change-directory group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; Delete all articles in GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 () ; Don't delete the articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (let ((articles (directory-files nnmh-current-directory t "^[0-9]+$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (and (file-writable-p (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (nnheader-message 5 "Deleting article %s in %s..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (car articles) group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (funcall nnmail-delete-file-function (car articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (setq articles (cdr articles))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; Try to delete the directory itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (delete-directory nnmh-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; Remove the group from all structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq nnmh-group-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (delq (assoc group nnmh-group-alist) nnmh-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 nnmh-current-directory nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (deffoo nnmh-request-rename-group (group new-name &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (nnmh-possibly-change-directory group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Rename directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (and (file-writable-p nnmh-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (rename-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (directory-file-name nnmh-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (directory-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (nnmail-group-pathname new-name nnmh-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; That went ok, so we change the internal structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let ((entry (assoc group nnmh-group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (and entry (setcar entry new-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq nnmh-current-directory nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun nnmh-possibly-change-directory (newsgroup &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (when (and server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (not (nnmh-server-opened server)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (nnmh-open-server server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if newsgroup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (let ((pathname (nnmail-group-pathname newsgroup nnmh-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (if (file-directory-p pathname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (setq nnmh-current-directory pathname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (error "No such newsgroup: %s" newsgroup)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defun nnmh-possibly-create-directory (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (let (dir dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq dir (nnmail-group-pathname group nnmh-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (while (not (file-directory-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setq dirs (cons dir dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (setq dir (file-name-directory (directory-file-name dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (while dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (if (make-directory (directory-file-name (car dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (error "Could not create directory %s" (car dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (nnheader-message 5 "Creating mail directory %s" (car dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (setq dirs (cdr dirs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defun nnmh-save-mail (&optional noinsert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "Called narrowed to an article."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (let ((group-art (nreverse (nnmail-article-group 'nnmh-active-number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (unless noinsert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (nnmail-insert-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (nnmail-insert-xref group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (run-hooks 'nnmail-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (run-hooks 'nnmh-prepare-save-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (while (looking-at "From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (replace-match "X-From-Line: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; We save the article in all the newsgroups it belongs in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (let ((ga group-art)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (while ga
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (nnmh-possibly-create-directory (caar ga))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (let ((file (concat (nnmail-group-pathname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (caar ga) nnmh-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (int-to-string (cdar ga)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (if first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; It was already saved, so we just make a hard link.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (funcall nnmail-crosspost-link-function first file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; Save the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (write-region (point-min) (point-max) file nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq first file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq ga (cdr ga))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (defun nnmh-active-number (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 "Compute the next article number in GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (let ((active (cadr (assoc group nnmh-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; The group wasn't known to nnmh, so we just create an active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; entry for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (or active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (setq active (cons 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (setq nnmh-group-alist (cons (list group active) nnmh-group-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (setcdr active (1+ (cdr active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (while (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (concat (nnmail-group-pathname group nnmh-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (int-to-string (cdr active))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setcdr active (1+ (cdr active))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (cdr active)))
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 nnmh-update-gnus-unreads (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; Go through the .nnmh-articles file and compare with the actual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; articles in this folder. The articles that are "new" will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; marked as unread by Gnus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let* ((dir nnmh-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (files (sort (mapcar (function (lambda (name) (string-to-int name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (directory-files nnmh-current-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 nil "^[0-9]+$" t)) '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (nnmh-file (concat dir ".nnmh-articles"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 new articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; Load the .nnmh-articles file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (file-exists-p nnmh-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (let (nnmh-newsgroup-articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (condition-case nil (load nnmh-file nil t t) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 nnmh-newsgroup-articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; Add all new articles to the `new' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (let ((art files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (while art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if (not (assq (car art) articles)) (setq new (cons (car art) new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq art (cdr art))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;; Remove all deleted articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let ((art articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (while art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (if (not (memq (caar art) files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (setq articles (delq (car art) articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (setq art (cdr art))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;; Check whether the highest-numbered articles really are the ones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; that Gnus thinks they are by looking at the time-stamps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (let ((art articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (while (and art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (not (equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (nth 5 (file-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (concat dir (int-to-string (caar art)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (cdar art))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq articles (delq (car art) articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (setq new (cons (caar art) new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setq art (cdr art))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; Go through all the new articles and add them, and their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; time-stamps to the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (let ((n new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (while n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (setq articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cons (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (car n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (nth 5 (file-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (concat dir (int-to-string (car n))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq n (cdr n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; Make Gnus mark all new articles as unread.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (or (zerop (length new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (gnus-make-articles-unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (gnus-group-prefixed-name group (list 'nnmh ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (setq new (sort new '<))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; Sort the article list with highest numbers first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (setq articles (sort articles (lambda (art1 art2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (> (car art1) (car art2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; Finally write this list back to the .nnmh-articles file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (set-buffer (get-buffer-create "*nnmh out*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (insert ";; Gnus article active file for " group "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (insert "(setq nnmh-newsgroup-articles '")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (insert (prin1-to-string articles) ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (write-region (point-min) (point-max) nnmh-file nil 'nomesg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun nnmh-deletable-article-p (group article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "Say whether ARTICLE in GROUP can be deleted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (let ((path (concat nnmh-current-directory (int-to-string article))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (and (file-writable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (or (not nnmail-keep-last-article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (not (eq (cdr (nth 1 (assoc group nnmh-group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 article))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (provide 'nnmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;;; nnmh.el ends here