annotate lisp/gnus/nndoc.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 131b0175ea99
children 4be1180a9e89
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 ;;; nndoc.el --- single file access for Gnus
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: news
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 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (require 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (require 'nnmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (require 'nnoo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (nnoo-declare nndoc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvoo nndoc-article-type 'guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "*Type of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
40 `mime-digest', `standard-digest', `slack-digest', `clari-briefs' or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
41 `guess'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvoo nndoc-post-type 'mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "*Whether the nndoc group is `mail' or `post'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
46 (defvar nndoc-type-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
47 `((mmdf
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (article-begin . "^\^A\^A\^A\^A\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (body-end . "^\^A\^A\^A\^A\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (article-begin . "^Path:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (rnews
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (article-begin . "^#! *rnews +\\([0-9]+\\) *\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (body-end-function . nndoc-rnews-body-end))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
55 (mbox
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 (article-begin-function . nndoc-mbox-article-begin)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (body-end-function . nndoc-mbox-body-end))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
58 (babyl
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (article-begin . "\^_\^L *\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (body-end . "\^_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (body-begin-function . nndoc-babyl-body-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (head-begin-function . nndoc-babyl-head-begin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (article-begin . "^-+ Start of forwarded message -+\n+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (body-end . "^-+ End of forwarded message -+$")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
66 (prepare-body-function . nndoc-unquote-dashes))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (clari-briefs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (article-begin . "^ \\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (body-end . "^\t------*[ \t]^*\n^ \\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (body-begin . "^\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (head-end . "^\t")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
72 (generate-head-function . nndoc-generate-clari-briefs-head)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 (article-transform-function . nndoc-transform-clari-briefs))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
74 (mime-digest
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
75 (article-begin . "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
76 (head-end . "^ ?$")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
77 (body-end . "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
78 (file-end . "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
79 (subtype digest guess))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
80 (standard-digest
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
81 (first-article . ,(concat "^" (make-string 70 ?-) "\n\n+"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
82 (article-begin . ,(concat "^\n" (make-string 30 ?-) "\n\n+"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
83 (prepare-body-function . nndoc-unquote-dashes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
84 (body-end-function . nndoc-digest-body-end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
85 (head-end . "^ ?$")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
86 (body-begin . "^ ?\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
87 (file-end . "^End of .*digest.*[0-9].*\n\\*\\*\\|^End of.*Digest *$")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
88 (subtype digest guess))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (slack-digest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (article-begin . "^------------------------------*[\n \t]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (head-end . "^ ?$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (body-end-function . nndoc-digest-body-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (body-begin . "^ ?$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (file-end . "^End of")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
95 (prepare-body-function . nndoc-unquote-dashes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
96 (subtype digest guess))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
97 (lanl-gov-announce
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
98 (article-begin . "^\\\\\\\\\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
99 (head-begin . "^Paper.*:")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
100 (head-end . "\\(^\\\\\\\\.*\n\\|-----------------\\)")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
101 (body-begin . "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
102 (body-end . "-------------------------------------------------")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
103 (file-end . "^Title: Recent Seminal")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
104 (generate-head-function . nndoc-generate-lanl-gov-head)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
105 (article-transform-function . nndoc-transform-lanl-gov-announce)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
106 (subtype preprints guess))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
107 (guess
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
108 (guess . t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
109 (subtype nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (digest
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
111 (guess . t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
112 (subtype nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
113 (preprints
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
114 (guess . t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
115 (subtype nil))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
116 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defvoo nndoc-file-begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defvoo nndoc-first-article nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvoo nndoc-article-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defvoo nndoc-article-begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defvoo nndoc-head-begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvoo nndoc-head-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defvoo nndoc-file-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvoo nndoc-body-begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defvoo nndoc-body-end-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvoo nndoc-body-begin-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defvoo nndoc-head-begin-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvoo nndoc-body-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defvoo nndoc-dissection-alist nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 (defvoo nndoc-prepare-body-function nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 (defvoo nndoc-generate-head-function nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
135 (defvoo nndoc-article-transform-function nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 (defvoo nndoc-article-begin-function nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defvoo nndoc-status-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvoo nndoc-group-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defvoo nndoc-current-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "Current nndoc news buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (defvoo nndoc-address nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defconst nndoc-version "nndoc 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "nndoc version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; Interface functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (nnoo-define-basics nndoc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (deffoo nndoc-retrieve-headers (articles &optional newsgroup server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (when (nndoc-possibly-change-buffer newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let (article entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (if (stringp (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 'headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (when (setq entry (cdr (assq (setq article (pop articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 nndoc-dissection-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (insert (format "221 %d Article retrieved.\n" article))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
165 (if nndoc-generate-head-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (funcall nndoc-generate-head-function article)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (insert-buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 nndoc-current-buffer (car entry) (nth 1 entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (goto-char (point-max))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
170 (unless (= (char-after (1- (point))) ?\n)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
171 (insert "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (insert (format "Lines: %d\n" (nth 4 entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (insert ".\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 'headers)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (deffoo nndoc-request-article (article &optional newsgroup server buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (nndoc-possibly-change-buffer newsgroup server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (let ((buffer (or buffer nntp-server-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (entry (cdr (assq article nndoc-dissection-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (erase-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
186 (when entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
187 (if (stringp article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
188 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
189 (insert-buffer-substring
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
190 nndoc-current-buffer (car entry) (nth 1 entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
191 (insert "\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
192 (setq beg (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
193 (insert-buffer-substring
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
194 nndoc-current-buffer (nth 2 entry) (nth 3 entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
195 (goto-char beg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
196 (when nndoc-prepare-body-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
197 (funcall nndoc-prepare-body-function))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
198 (when nndoc-article-transform-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
199 (funcall nndoc-article-transform-function article))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
200 t)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (deffoo nndoc-request-group (group &optional server dont-check)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "Select news GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (let (number)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
205 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ((not (nndoc-possibly-change-buffer group server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (nnheader-report 'nndoc "No such file or buffer: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 nndoc-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (dont-check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (nnheader-report 'nndoc "Selected group %s" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ((zerop (setq number (length nndoc-dissection-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (nndoc-close-group group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (nnheader-report 'nndoc "No articles in group %s" group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (nnheader-insert "211 %d %d %d %s\n" number 1 number group)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (deffoo nndoc-request-type (group &optional article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (cond ((not article) 'unknown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (nndoc-post-type nndoc-post-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (t 'unknown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (deffoo nndoc-close-group (group &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (nndoc-possibly-change-buffer group server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (and nndoc-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (buffer-name nndoc-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (kill-buffer nndoc-current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq nndoc-group-alist (delq (assoc group nndoc-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 nndoc-group-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (setq nndoc-current-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (nnoo-close-server 'nndoc server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq nndoc-dissection-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (deffoo nndoc-request-list (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (deffoo nndoc-request-newgroups (date &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (deffoo nndoc-request-list-newsgroups (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun nndoc-possibly-change-buffer (group source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (let (buf)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
249 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; The current buffer is this group's buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ((and nndoc-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (buffer-name nndoc-current-buffer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
253 (eq nndoc-current-buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq buf (cdr (assoc group nndoc-group-alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; We change buffers by taking an old from the group alist.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
256 ;; `source' is either a string (a file name) or a buffer object.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq nndoc-current-buffer buf))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
259 ;; It's a totally new group.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ((or (and (bufferp nndoc-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (buffer-name nndoc-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (and (stringp nndoc-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (file-exists-p nndoc-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (not (file-directory-p nndoc-address))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
265 (push (cons group (setq nndoc-current-buffer
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
266 (get-buffer-create
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (concat " *nndoc " group "*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 nndoc-group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq nndoc-dissection-alist nil)
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 nndoc-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (stringp nndoc-address)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
275 (nnheader-insert-file-contents nndoc-address)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (insert-buffer-substring nndoc-address)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; Initialize the nndoc structures according to this new document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (when (and nndoc-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (not nndoc-dissection-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (set-buffer nndoc-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (nndoc-set-delims)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (nndoc-dissect-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (unless nndoc-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (nndoc-close-server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; Return whether we managed to select a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 nndoc-current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
289 ;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
290 ;;; Deciding what document type we have
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
291 ;;;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun nndoc-set-delims ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "Set the nndoc delimiter variables according to the type of the document."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
295 (let ((vars '(nndoc-file-begin
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 34
diff changeset
296 nndoc-first-article
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 nndoc-article-end nndoc-head-begin nndoc-head-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 nndoc-file-end nndoc-article-begin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 nndoc-body-begin nndoc-body-end-function nndoc-body-end
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
300 nndoc-prepare-body-function nndoc-article-transform-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
301 nndoc-generate-head-function nndoc-body-begin-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
302 nndoc-head-begin-function)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (while vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (set (pop vars) nil)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
305 (let (defs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; Guess away until we find the real file type.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
307 (while (assq 'guess (setq defs (cdr (assq nndoc-article-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
308 nndoc-type-alist))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
309 (setq nndoc-article-type (nndoc-guess-type nndoc-article-type)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Set the nndoc variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (while defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (set (intern (format "nndoc-%s" (caar defs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (cdr (pop defs))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
315 (defun nndoc-guess-type (subtype)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
316 (let ((alist nndoc-type-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
317 results result entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
318 (while (and (not result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
319 (setq entry (pop alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
320 (when (memq subtype (or (cdr (assq 'subtype entry)) '(guess)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
321 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
322 (when (numberp (setq result (funcall (intern
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
323 (format "nndoc-%s-type-p"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
324 (car entry))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
325 (push (cons result entry) results)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
326 (setq result nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
327 (unless (or result results)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
328 (error "Document is not of any recognized type"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
329 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
330 (car entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
331 (cadar (sort results (lambda (r1 r2) (< (car r1) (car r2))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
333 ;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
334 ;;; Built-in type predicates and functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
335 ;;;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
337 (defun nndoc-mbox-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
338 (when (looking-at message-unix-mail-delimiter)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
339 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
341 (defun nndoc-mbox-article-begin ()
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
342 (when (re-search-forward (concat "^" message-unix-mail-delimiter) nil t)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
343 (goto-char (match-beginning 0))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
344
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun nndoc-mbox-body-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (let ((beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 len end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
350 (and (re-search-backward
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
351 (concat "^" message-unix-mail-delimiter) nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (search-forward "\n\n" beg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "^Content-Length:[ \t]*\\([0-9]+\\) *$" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (setq len (string-to-int (match-string 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (search-forward "\n\n" beg t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
358 (unless (= (setq len (+ (point) len)) (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
359 (and (< len (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
360 (goto-char len)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
361 (looking-at message-unix-mail-delimiter)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (goto-char len))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
364 (defun nndoc-mmdf-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
365 (when (looking-at "\^A\^A\^A\^A$")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
366 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
367
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
368 (defun nndoc-news-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
369 (when (looking-at "^Path:.*\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
370 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
371
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
372 (defun nndoc-rnews-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
373 (when (looking-at "#! *rnews")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
374 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
375
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun nndoc-rnews-body-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (and (re-search-backward nndoc-article-begin nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (goto-char (+ (point) (string-to-int (match-string 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
381 (defun nndoc-babyl-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
382 (when (re-search-forward "\^_\^L *\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
383 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
384
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
385 (defun nndoc-babyl-body-begin ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
386 (re-search-forward "^\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
387 (when (looking-at "\*\*\* EOOH \*\*\*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
388 (let ((next (or (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
389 (re-search-forward nndoc-article-begin nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
390 (point-max))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
391 (unless (re-search-forward "^\n" next t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
392 (goto-char next)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
393 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
394 (insert "\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
395 (forward-line -1)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
396
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
397 (defun nndoc-babyl-head-begin ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
398 (when (re-search-forward "^[0-9].*\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
399 (when (looking-at "\*\*\* EOOH \*\*\*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
400 (forward-line 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
401 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
402
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
403 (defun nndoc-forward-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
404 (when (and (re-search-forward "^-+ Start of forwarded message -+\n+" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
405 (not (re-search-forward "^Subject:.*digest" nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
406 (not (re-search-backward "^From:" nil t 2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
407 (not (re-search-forward "^From:" nil t 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
408 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
409
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
410 (defun nndoc-clari-briefs-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
411 (when (let ((case-fold-search nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
412 (re-search-forward "^\t[^a-z]+ ([^a-z]+) --" nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
413 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
414
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defun nndoc-transform-clari-briefs (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (when (looking-at " *\\*\\(.*\\)\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (replace-match "" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (nndoc-generate-clari-briefs-head article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (defun nndoc-generate-clari-briefs-head (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let ((entry (cdr (assq article nndoc-dissection-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 subject from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (set-buffer nndoc-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (narrow-to-region (car entry) (nth 3 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (when (looking-at " *\\*\\(.*\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq subject (match-string 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (when (string-match "[ \t]+$" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (setq subject (substring subject 0 (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 "^\t\\([^a-z]+\\(,[^(]+\\)? ([^a-z]+)\\) --" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq from (match-string 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (insert "From: " "clari@clari.net (" (or from "unknown") ")"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 "\nSubject: " (or subject "(no subject)") "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
441 (defun nndoc-mime-digest-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
442 (let ((case-fold-search t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
443 boundary-id b-delimiter entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
444 (when (and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
445 (re-search-forward
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
446 (concat "^Content-Type: *multipart/digest;[ \t\n]*[ \t]"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
447 "boundary=\"\\([^\"\n]*[^\" \t\n]\\)\"")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
448 nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
449 (match-beginning 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
450 (setq boundary-id (match-string 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
451 b-delimiter (concat "\n--" boundary-id "[\n \t]+"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
452 (setq entry (assq 'mime-digest nndoc-type-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
453 (setcdr entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
454 (list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
455 (cons 'head-end "^ ?$")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
456 (cons 'body-begin "^ ?\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
457 (cons 'article-begin b-delimiter)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
458 (cons 'body-end-function 'nndoc-digest-body-end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
459 (cons 'file-end (concat "\n--" boundary-id "--[ \t]*$"))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
460 t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
461
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
462 (defun nndoc-standard-digest-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
463 (when (and (re-search-forward (concat "^" (make-string 70 ?-) "\n\n") nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
464 (re-search-forward
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
465 (concat "\n\n" (make-string 30 ?-) "\n\n") nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
466 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
467
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
468 (defun nndoc-digest-body-end ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
469 (and (re-search-forward nndoc-article-begin nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
470 (goto-char (match-beginning 0))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
471
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
472 (defun nndoc-slack-digest-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
473 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
474
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
475 (defun nndoc-lanl-gov-announce-type-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
476 (when (let ((case-fold-search nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
477 (re-search-forward "^\\\\\\\\\nPaper: [a-z-]+/[0-9]+" nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
478 t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
479
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
480 (defun nndoc-transform-lanl-gov-announce (article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
481 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
482 (when (re-search-backward "^\\\\\\\\ +(\\([^ ]*\\) , *\\([^ ]*\\))" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
483 (replace-match "\n\nGet it at \\1 (\\2)" t nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
484 ;; (when (re-search-backward "^\\\\\\\\$" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
485 ;; (replace-match "" t t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
486 )
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
487
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
488 (defun nndoc-generate-lanl-gov-head (article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
489 (let ((entry (cdr (assq article nndoc-dissection-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
490 (e-mail "no address given")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
491 subject from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
492 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
493 (set-buffer nndoc-current-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
495 (narrow-to-region (car entry) (nth 1 entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
496 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
497 (when (looking-at "^Paper.*: \\([a-z-]+/[0-9]+\\)")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
498 (setq subject (concat " (" (match-string 1) ")"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
499 (when (re-search-forward "^From: \\([^ ]+\\)" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
500 (setq e-mail (match-string 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
501 (when (re-search-forward "^Title: \\([^\f]*\\)\nAuthors?: \\(.*\\)"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
502 nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
503 (setq subject (concat (match-string 1) subject))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
504 (setq from (concat (match-string 2) " <" e-mail ">"))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
505 ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
506 (while (and from (string-match "(\[^)\]*)" from))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
507 (setq from (replace-match "" t t from)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
508 (insert "From: " (or from "unknown")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
509 "\nSubject: " (or subject "(no subject)") "\n")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
510
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
511
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
512
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
513 ;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
514 ;;; Functions for dissecting the documents
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
515 ;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
516
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
517 (defun nndoc-search (regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
518 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
519 (re-search-forward regexp nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
520 (beginning-of-line)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
522 (defun nndoc-dissect-buffer ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
523 "Go through the document and partition it into heads/bodies/articles."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
524 (let ((i 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
525 (first t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
526 head-begin head-end body-begin body-end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
527 (setq nndoc-dissection-alist nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
528 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
529 (set-buffer nndoc-current-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
530 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
531 ;; Find the beginning of the file.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
532 (when nndoc-file-begin
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
533 (nndoc-search nndoc-file-begin))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
534 ;; Go through the file.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
535 (while (if (and first nndoc-first-article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
536 (nndoc-search nndoc-first-article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537 (nndoc-article-begin))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 (setq first nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539 (cond (nndoc-head-begin-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
540 (funcall nndoc-head-begin-function))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 (nndoc-head-begin
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 (nndoc-search nndoc-head-begin)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 (if (or (>= (point) (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544 (and nndoc-file-end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
545 (looking-at nndoc-file-end)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
546 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
547 (setq head-begin (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
548 (nndoc-search (or nndoc-head-end "^$"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
549 (setq head-end (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
550 (if nndoc-body-begin-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
551 (funcall nndoc-body-begin-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
552 (nndoc-search (or nndoc-body-begin "^\n")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
553 (setq body-begin (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
554 (or (and nndoc-body-end-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
555 (funcall nndoc-body-end-function))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
556 (and nndoc-body-end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
557 (nndoc-search nndoc-body-end))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
558 (nndoc-article-begin)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
559 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
560 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
561 (when nndoc-file-end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
562 (and (re-search-backward nndoc-file-end nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
563 (beginning-of-line)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
564 (setq body-end (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
565 (push (list (incf i) head-begin head-end body-begin body-end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
566 (count-lines body-begin body-end))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
567 nndoc-dissection-alist))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
568
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
569 (defun nndoc-article-begin ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
570 (if nndoc-article-begin-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
571 (funcall nndoc-article-begin-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
572 (ignore-errors
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
573 (nndoc-search nndoc-article-begin))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
574
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
575 (defun nndoc-unquote-dashes ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
576 "Unquote quoted non-separators in digests."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
577 (while (re-search-forward "^- -"nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
578 (replace-match "-" t t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
579
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
580 ;;;###autoload
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
581 (defun nndoc-add-type (definition &optional position)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
582 "Add document DEFINITION to the list of nndoc document definitions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
583 If POSITION is nil or `last', the definition will be added
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
584 as the last checked definition, if t or `first', add as the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
585 first definition, and if any other symbol, add after that
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
586 symbol in the alist."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
587 ;; First remove any old instances.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
588 (setq nndoc-type-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
589 (delq (assq (car definition) nndoc-type-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
590 nndoc-type-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
591 ;; Then enter the new definition in the proper place.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
592 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
593 ((or (null position) (eq position 'last))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
594 (setq nndoc-type-alist (nconc nndoc-type-alist (list definition))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
595 ((or (eq position t) (eq position 'first))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
596 (push definition nndoc-type-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
597 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
598 (let ((list (memq (assq position nndoc-type-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
599 nndoc-type-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
600 (unless list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
601 (error "No such position: %s" position))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
602 (setcdr list (cons definition (cdr list)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (provide 'nndoc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;;; nndoc.el ends here