annotate lisp/gnus/nndoc.el @ 30:ec9a17fef872 r19-15b98

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