1 |
;;; nndoc.el --- single file access for Gnus |
;;; nndoc.el --- single file access for Gnus |
2 |
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 |
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
3 |
;; Free Software Foundation, Inc. |
;; Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
6 |
;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
7 |
;; Keywords: news |
;; Keywords: news |
8 |
|
|
9 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
25 |
|
|
26 |
;;; Commentary: |
;;; Commentary: |
27 |
|
|
28 |
|
;; For Outlook mail boxes format, see http://mbx2mbox.sourceforge.net/ |
29 |
|
|
30 |
;;; Code: |
;;; Code: |
31 |
|
|
32 |
(require 'nnheader) |
(require 'nnheader) |
43 |
"*Type of the file. |
"*Type of the file. |
44 |
One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward', |
One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward', |
45 |
`rfc934', `rfc822-forward', `mime-parts', `standard-digest', |
`rfc934', `rfc822-forward', `mime-parts', `standard-digest', |
46 |
`slack-digest', `clari-briefs', `nsmail' or `guess'.") |
`slack-digest', `clari-briefs', `nsmail', `outlook', `oe-dbx', |
47 |
|
`mailman', `exim-bounce', or `guess'.") |
48 |
|
|
49 |
(defvoo nndoc-post-type 'mail |
(defvoo nndoc-post-type 'mail |
50 |
"*Whether the nndoc group is `mail' or `post'.") |
"*Whether the nndoc group is `mail' or `post'.") |
58 |
`((mmdf |
`((mmdf |
59 |
(article-begin . "^\^A\^A\^A\^A\n") |
(article-begin . "^\^A\^A\^A\^A\n") |
60 |
(body-end . "^\^A\^A\^A\^A\n")) |
(body-end . "^\^A\^A\^A\^A\n")) |
61 |
|
(exim-bounce |
62 |
|
(article-begin . "^------ This is a copy of the message, including all the headers. ------\n\n") |
63 |
|
(body-end-function . nndoc-exim-bounce-body-end-function)) |
64 |
(nsmail |
(nsmail |
65 |
(article-begin . "^From - ")) |
(article-begin . "^From - ")) |
66 |
(news |
(news |
76 |
(body-end . "\^_") |
(body-end . "\^_") |
77 |
(body-begin-function . nndoc-babyl-body-begin) |
(body-begin-function . nndoc-babyl-body-begin) |
78 |
(head-begin-function . nndoc-babyl-head-begin)) |
(head-begin-function . nndoc-babyl-head-begin)) |
|
(forward |
|
|
(article-begin . "^-+ \\(Start of \\)?forwarded message.*\n+") |
|
|
(body-end . "^-+ End \\(of \\)?forwarded message.*$") |
|
|
(prepare-body-function . nndoc-unquote-dashes)) |
|
79 |
(rfc934 |
(rfc934 |
80 |
(article-begin . "^--.*\n+") |
(article-begin . "^--.*\n+") |
81 |
(body-end . "^--.*$") |
(body-end . "^--.*$") |
82 |
(prepare-body-function . nndoc-unquote-dashes)) |
(prepare-body-function . nndoc-unquote-dashes)) |
83 |
|
(mailman |
84 |
|
(article-begin . "^--__--__--\n\nMessage:") |
85 |
|
(body-end . "^--__--__--$") |
86 |
|
(prepare-body-function . nndoc-unquote-dashes)) |
87 |
(clari-briefs |
(clari-briefs |
88 |
(article-begin . "^ \\*") |
(article-begin . "^ \\*") |
89 |
(body-end . "^\t------*[ \t]^*\n^ \\*") |
(body-end . "^\t------*[ \t]^*\n^ \\*") |
123 |
(head-begin . "^Paper.*:") |
(head-begin . "^Paper.*:") |
124 |
(head-end . "\\(^\\\\\\\\.*\n\\|-----------------\\)") |
(head-end . "\\(^\\\\\\\\.*\n\\|-----------------\\)") |
125 |
(body-begin . "") |
(body-begin . "") |
126 |
(body-end . "-------------------------------------------------") |
(body-end . "\\(-------------------------------------------------\\|%-%-%-%-%-%-%-%-%-%-%-%-%-%-\\|%%--%%--%%--%%--%%--%%--%%--%%--\\|%%%---%%%---%%%---%%%---\\)") |
127 |
(file-end . "^Title: Recent Seminal") |
(file-end . "\\(^Title: Recent Seminal\\|%%%---%%%---%%%---%%%---\\)") |
128 |
(generate-head-function . nndoc-generate-lanl-gov-head) |
(generate-head-function . nndoc-generate-lanl-gov-head) |
129 |
(article-transform-function . nndoc-transform-lanl-gov-announce) |
(article-transform-function . nndoc-transform-lanl-gov-announce) |
130 |
(subtype preprints guess)) |
(subtype preprints guess)) |
134 |
(outlook |
(outlook |
135 |
(article-begin-function . nndoc-outlook-article-begin) |
(article-begin-function . nndoc-outlook-article-begin) |
136 |
(body-end . "\0")) |
(body-end . "\0")) |
137 |
|
(oe-dbx ;; Outlook Express DBX format |
138 |
|
(dissection-function . nndoc-oe-dbx-dissection) |
139 |
|
(generate-head-function . nndoc-oe-dbx-generate-head) |
140 |
|
(generate-article-function . nndoc-oe-dbx-generate-article)) |
141 |
|
(forward |
142 |
|
(article-begin . "^-+ \\(Start of \\)?forwarded message.*\n+") |
143 |
|
(body-end . "^-+ End \\(of \\)?forwarded message.*$") |
144 |
|
(prepare-body-function . nndoc-unquote-dashes)) |
145 |
|
(mail-in-mail ;; Wild guess on mailer daemon's messages or others |
146 |
|
(article-begin-function . nndoc-mail-in-mail-article-begin)) |
147 |
(guess |
(guess |
148 |
(guess . t) |
(guess . t) |
149 |
(subtype nil)) |
(subtype nil)) |
154 |
(guess . t) |
(guess . t) |
155 |
(subtype nil)))) |
(subtype nil)))) |
156 |
|
|
157 |
|
(defvar nndoc-binary-file-names ".[Dd][Bb][Xx]$" |
158 |
|
"Regexp for binary nndoc file names.") |
159 |
|
|
160 |
|
|
161 |
(defvoo nndoc-file-begin nil) |
(defvoo nndoc-file-begin nil) |
162 |
(defvoo nndoc-first-article nil) |
(defvoo nndoc-first-article nil) |
182 |
(defvoo nndoc-generate-head-function nil) |
(defvoo nndoc-generate-head-function nil) |
183 |
(defvoo nndoc-article-transform-function nil) |
(defvoo nndoc-article-transform-function nil) |
184 |
(defvoo nndoc-article-begin-function nil) |
(defvoo nndoc-article-begin-function nil) |
185 |
|
(defvoo nndoc-generate-article-function nil) |
186 |
|
(defvoo nndoc-dissection-function nil) |
187 |
|
|
188 |
(defvoo nndoc-status-string "") |
(defvoo nndoc-status-string "") |
189 |
(defvoo nndoc-group-alist nil) |
(defvoo nndoc-group-alist nil) |
234 |
(set-buffer buffer) |
(set-buffer buffer) |
235 |
(erase-buffer) |
(erase-buffer) |
236 |
(when entry |
(when entry |
237 |
(if (stringp article) |
(cond |
238 |
nil |
((stringp article) nil) |
239 |
|
(nndoc-generate-article-function |
240 |
|
(funcall nndoc-generate-article-function article)) |
241 |
|
(t |
242 |
(insert-buffer-substring |
(insert-buffer-substring |
243 |
nndoc-current-buffer (car entry) (nth 1 entry)) |
nndoc-current-buffer (car entry) (nth 1 entry)) |
244 |
(insert "\n") |
(insert "\n") |
250 |
(funcall nndoc-prepare-body-function)) |
(funcall nndoc-prepare-body-function)) |
251 |
(when nndoc-article-transform-function |
(when nndoc-article-transform-function |
252 |
(funcall nndoc-article-transform-function article)) |
(funcall nndoc-article-transform-function article)) |
253 |
t))))) |
t)))))) |
254 |
|
|
255 |
(deffoo nndoc-request-group (group &optional server dont-check) |
(deffoo nndoc-request-group (group &optional server dont-check) |
256 |
"Select news GROUP." |
"Select news GROUP." |
270 |
|
|
271 |
(deffoo nndoc-request-type (group &optional article) |
(deffoo nndoc-request-type (group &optional article) |
272 |
(cond ((not article) 'unknown) |
(cond ((not article) 'unknown) |
273 |
(nndoc-post-type nndoc-post-type) |
(nndoc-post-type nndoc-post-type) |
274 |
(t 'unknown))) |
(t 'unknown))) |
275 |
|
|
276 |
(deffoo nndoc-close-group (group &optional server) |
(deffoo nndoc-close-group (group &optional server) |
277 |
(nndoc-possibly-change-buffer group server) |
(nndoc-possibly-change-buffer group server) |
323 |
(save-excursion |
(save-excursion |
324 |
(set-buffer nndoc-current-buffer) |
(set-buffer nndoc-current-buffer) |
325 |
(erase-buffer) |
(erase-buffer) |
326 |
(if (stringp nndoc-address) |
(if (and (stringp nndoc-address) |
327 |
(nnheader-insert-file-contents nndoc-address) |
(string-match nndoc-binary-file-names nndoc-address)) |
328 |
(insert-buffer-substring nndoc-address)) |
(let ((coding-system-for-read 'binary)) |
329 |
(run-hooks 'nndoc-open-document-hook)))) |
(mm-insert-file-contents nndoc-address)) |
330 |
|
(if (stringp nndoc-address) |
331 |
|
(nnheader-insert-file-contents nndoc-address) |
332 |
|
(insert-buffer-substring nndoc-address)) |
333 |
|
(run-hooks 'nndoc-open-document-hook))))) |
334 |
;; Initialize the nndoc structures according to this new document. |
;; Initialize the nndoc structures according to this new document. |
335 |
(when (and nndoc-current-buffer |
(when (and nndoc-current-buffer |
336 |
(not nndoc-dissection-alist)) |
(not nndoc-dissection-alist)) |
359 |
nndoc-body-begin nndoc-body-end-function nndoc-body-end |
nndoc-body-begin nndoc-body-end-function nndoc-body-end |
360 |
nndoc-prepare-body-function nndoc-article-transform-function |
nndoc-prepare-body-function nndoc-article-transform-function |
361 |
nndoc-generate-head-function nndoc-body-begin-function |
nndoc-generate-head-function nndoc-body-begin-function |
362 |
nndoc-head-begin-function))) |
nndoc-head-begin-function |
363 |
|
nndoc-generate-article-function |
364 |
|
nndoc-dissection-function))) |
365 |
(while vars |
(while vars |
366 |
(set (pop vars) nil))) |
(set (pop vars) nil))) |
367 |
(let (defs) |
(let (defs) |
466 |
t)) |
t)) |
467 |
|
|
468 |
(defun nndoc-forward-type-p () |
(defun nndoc-forward-type-p () |
469 |
(when (and (re-search-forward "^-+ \\(Start of \\)?forwarded message.*\n+" |
(when (and (re-search-forward "^-+ \\(Start of \\)?forwarded message.*\n+" |
470 |
nil t) |
nil t) |
471 |
(not (re-search-forward "^Subject:.*digest" nil t)) |
(looking-at "[\r\n]*[a-zA-Z][a-zA-Z0-9-]*:")) |
|
(not (re-search-backward "^From:" nil t 2)) |
|
|
(not (re-search-forward "^From:" nil t 2))) |
|
472 |
t)) |
t)) |
473 |
|
|
474 |
(defun nndoc-rfc934-type-p () |
(defun nndoc-rfc934-type-p () |
478 |
(not (re-search-forward "^From:" nil t 2))) |
(not (re-search-forward "^From:" nil t 2))) |
479 |
t)) |
t)) |
480 |
|
|
481 |
|
(defun nndoc-mailman-type-p () |
482 |
|
(when (re-search-forward "^--__--__--\n+" nil t) |
483 |
|
t)) |
484 |
|
|
485 |
(defun nndoc-rfc822-forward-type-p () |
(defun nndoc-rfc822-forward-type-p () |
486 |
(save-restriction |
(save-restriction |
487 |
(message-narrow-to-head) |
(message-narrow-to-head) |
552 |
(insert "From: " "clari@clari.net (" (or from "unknown") ")" |
(insert "From: " "clari@clari.net (" (or from "unknown") ")" |
553 |
"\nSubject: " (or subject "(no subject)") "\n"))) |
"\nSubject: " (or subject "(no subject)") "\n"))) |
554 |
|
|
555 |
|
(defun nndoc-exim-bounce-type-p () |
556 |
|
(and (re-search-forward "^------ This is a copy of the message, including all the headers. ------" nil t) |
557 |
|
t)) |
558 |
|
|
559 |
|
(defun nndoc-exim-bounce-body-end-function () |
560 |
|
(goto-char (point-max))) |
561 |
|
|
562 |
|
|
563 |
(defun nndoc-mime-digest-type-p () |
(defun nndoc-mime-digest-type-p () |
564 |
(let ((case-fold-search t) |
(let ((case-fold-search t) |
579 |
(cons 'body-begin "^ ?\n") |
(cons 'body-begin "^ ?\n") |
580 |
(cons 'article-begin b-delimiter) |
(cons 'article-begin b-delimiter) |
581 |
(cons 'body-end-function 'nndoc-digest-body-end) |
(cons 'body-end-function 'nndoc-digest-body-end) |
582 |
(cons 'file-end (concat "\n--" boundary-id "--[ \t]*$")))) |
(cons 'file-end (concat "^--" boundary-id "--[ \t]*$")))) |
583 |
t))) |
t))) |
584 |
|
|
585 |
(defun nndoc-standard-digest-type-p () |
(defun nndoc-standard-digest-type-p () |
597 |
|
|
598 |
(defun nndoc-lanl-gov-announce-type-p () |
(defun nndoc-lanl-gov-announce-type-p () |
599 |
(when (let ((case-fold-search nil)) |
(when (let ((case-fold-search nil)) |
600 |
(re-search-forward "^\\\\\\\\\nPaper: [a-z-]+/[0-9]+" nil t)) |
(re-search-forward "^\\\\\\\\\nPaper\\( (\\*cross-listing\\*)\\)?: [a-zA-Z-\\.]+/[0-9]+" nil t)) |
601 |
t)) |
t)) |
602 |
|
|
603 |
(defun nndoc-transform-lanl-gov-announce (article) |
(defun nndoc-transform-lanl-gov-announce (article) |
604 |
(goto-char (point-max)) |
(goto-char (point-max)) |
605 |
(when (re-search-backward "^\\\\\\\\ +(\\([^ ]*\\) , *\\([^ ]*\\))" nil t) |
(when (re-search-backward "^\\\\\\\\ +( *\\([^ ]*\\) , *\\([^ ]*\\))" nil t) |
606 |
(replace-match "\n\nGet it at \\1 (\\2)" t nil))) |
(replace-match "\n\nGet it at \\1 (\\2)" t nil)) |
607 |
|
(goto-char (point-min)) |
608 |
|
(while (re-search-forward "^\\\\\\\\$" nil t) |
609 |
|
(replace-match "" t nil)) |
610 |
|
(goto-char (point-min)) |
611 |
|
(when (re-search-forward "^replaced with revised version +\\(.*[^ ]\\) +" nil t) |
612 |
|
(replace-match "Date: \\1 (revised) " t nil)) |
613 |
|
(goto-char (point-min)) |
614 |
|
(unless (re-search-forward "^From" nil t) |
615 |
|
(goto-char (point-min)) |
616 |
|
(when (re-search-forward "^Authors?: \\(.*\\)" nil t) |
617 |
|
(goto-char (point-min)) |
618 |
|
(insert "From: " (match-string 1) "\n")))) |
619 |
|
|
620 |
(defun nndoc-generate-lanl-gov-head (article) |
(defun nndoc-generate-lanl-gov-head (article) |
621 |
(let ((entry (cdr (assq article nndoc-dissection-alist))) |
(let ((entry (cdr (assq article nndoc-dissection-alist))) |
622 |
(e-mail "no address given") |
(from "<no address given>") |
623 |
subject from) |
subject date) |
624 |
(save-excursion |
(save-excursion |
625 |
(set-buffer nndoc-current-buffer) |
(set-buffer nndoc-current-buffer) |
626 |
(save-restriction |
(save-restriction |
627 |
(narrow-to-region (car entry) (nth 1 entry)) |
(narrow-to-region (car entry) (nth 1 entry)) |
628 |
(goto-char (point-min)) |
(goto-char (point-min)) |
629 |
(when (looking-at "^Paper.*: \\([a-z-]+/[0-9]+\\)") |
(when (looking-at "^Paper.*: \\([a-zA-Z-\\.]+/[0-9]+\\)") |
630 |
(setq subject (concat " (" (match-string 1) ")")) |
(setq subject (concat " (" (match-string 1) ")")) |
631 |
(when (re-search-forward "^From: \\([^ ]+\\)" nil t) |
(when (re-search-forward "^From: \\(.*\\)" nil t) |
632 |
(setq e-mail (match-string 1))) |
(setq from (concat "<" |
633 |
(when (re-search-forward "^Title: \\([^\f]*\\)\nAuthors?: \\(.*\\)" |
(cadr (funcall gnus-extract-address-components |
634 |
nil t) |
(match-string 1))) ">"))) |
635 |
(setq subject (concat (match-string 1) subject)) |
(if (re-search-forward "^Date: +\\([^(]*\\)" nil t) |
636 |
(setq from (concat (match-string 2) " <" e-mail ">")))))) |
(setq date (match-string 1)) |
637 |
|
(when (re-search-forward "^replaced with revised version +\\([^(]*\\)" nil t) |
638 |
|
(setq date (match-string 1)))) |
639 |
|
(when (re-search-forward "^Title: \\([^\f]*\\)\nAuthors?: \\(.*\\)" |
640 |
|
nil t) |
641 |
|
(setq subject (concat (match-string 1) subject)) |
642 |
|
(setq from (concat (match-string 2) " " from)))))) |
643 |
(while (and from (string-match "(\[^)\]*)" from)) |
(while (and from (string-match "(\[^)\]*)" from)) |
644 |
(setq from (replace-match "" t t from))) |
(setq from (replace-match "" t t from))) |
645 |
(insert "From: " (or from "unknown") |
(insert "From: " (or from "unknown") |
646 |
"\nSubject: " (or subject "(no subject)") "\n"))) |
"\nSubject: " (or subject "(no subject)") "\n") |
647 |
|
(if date (insert "Date: " date)))) |
648 |
|
|
649 |
(defun nndoc-nsmail-type-p () |
(defun nndoc-nsmail-type-p () |
650 |
(when (looking-at "From - ") |
(when (looking-at "From - ") |
658 |
;; FIXME: Is JMF the magic of outlook mailbox? -- ShengHuo. |
;; FIXME: Is JMF the magic of outlook mailbox? -- ShengHuo. |
659 |
(looking-at "JMF")) |
(looking-at "JMF")) |
660 |
|
|
661 |
|
(defun nndoc-oe-dbx-type-p () |
662 |
|
(looking-at (mm-string-as-multibyte "\317\255\022\376"))) |
663 |
|
|
664 |
|
(defun nndoc-read-little-endian () |
665 |
|
(+ (prog1 (char-after) (forward-char 1)) |
666 |
|
(lsh (prog1 (char-after) (forward-char 1)) 8) |
667 |
|
(lsh (prog1 (char-after) (forward-char 1)) 16) |
668 |
|
(lsh (prog1 (char-after) (forward-char 1)) 24))) |
669 |
|
|
670 |
|
(defun nndoc-oe-dbx-decode-block () |
671 |
|
(list |
672 |
|
(nndoc-read-little-endian) ;; this address |
673 |
|
(nndoc-read-little-endian) ;; next address offset |
674 |
|
(nndoc-read-little-endian) ;; blocksize |
675 |
|
(nndoc-read-little-endian))) ;; next address |
676 |
|
|
677 |
|
(defun nndoc-oe-dbx-dissection () |
678 |
|
(let ((i 0) blk p tp) |
679 |
|
(goto-char 60117) ;; 0x0000EAD4+1 |
680 |
|
(setq p (point)) |
681 |
|
(unless (eobp) |
682 |
|
(setq blk (nndoc-oe-dbx-decode-block))) |
683 |
|
(while (and blk (> (car blk) 0) (or (zerop (nth 3 blk)) |
684 |
|
(> (nth 3 blk) p))) |
685 |
|
(push (list (incf i) p nil nil nil 0) nndoc-dissection-alist) |
686 |
|
(while (and (> (car blk) 0) (> (nth 3 blk) p)) |
687 |
|
(goto-char (1+ (nth 3 blk))) |
688 |
|
(setq blk (nndoc-oe-dbx-decode-block))) |
689 |
|
(if (or (<= (car blk) p) |
690 |
|
(<= (nth 1 blk) 0) |
691 |
|
(not (zerop (nth 3 blk)))) |
692 |
|
(setq blk nil) |
693 |
|
(setq tp (+ (car blk) (nth 1 blk) 17)) |
694 |
|
(if (or (<= tp p) (>= tp (point-max))) |
695 |
|
(setq blk nil) |
696 |
|
(goto-char tp) |
697 |
|
(setq p tp |
698 |
|
blk (nndoc-oe-dbx-decode-block))))))) |
699 |
|
|
700 |
|
(defun nndoc-oe-dbx-generate-article (article &optional head) |
701 |
|
(let ((entry (cdr (assq article nndoc-dissection-alist))) |
702 |
|
(cur (current-buffer)) |
703 |
|
(begin (point)) |
704 |
|
blk p) |
705 |
|
(with-current-buffer nndoc-current-buffer |
706 |
|
(setq p (car entry)) |
707 |
|
(while (> p (point-min)) |
708 |
|
(goto-char p) |
709 |
|
(setq blk (nndoc-oe-dbx-decode-block)) |
710 |
|
(setq p (point)) |
711 |
|
(with-current-buffer cur |
712 |
|
(insert-buffer-substring nndoc-current-buffer p (+ p (nth 2 blk)))) |
713 |
|
(setq p (1+ (nth 3 blk))))) |
714 |
|
(goto-char begin) |
715 |
|
(while (re-search-forward "\r$" nil t) |
716 |
|
(delete-backward-char 1)) |
717 |
|
(when head |
718 |
|
(goto-char begin) |
719 |
|
(when (search-forward "\n\n" nil t) |
720 |
|
(setcar (cddddr entry) (count-lines (point) (point-max))) |
721 |
|
(delete-region (1- (point)) (point-max)))) |
722 |
|
t)) |
723 |
|
|
724 |
|
(defun nndoc-oe-dbx-generate-head (article) |
725 |
|
(nndoc-oe-dbx-generate-article article 'head)) |
726 |
|
|
727 |
|
(defun nndoc-mail-in-mail-type-p () |
728 |
|
(let (found) |
729 |
|
(save-excursion |
730 |
|
(catch 'done |
731 |
|
(while (re-search-forward "\n\n[-A-Za-z0-9]+:" nil t) |
732 |
|
(setq found 0) |
733 |
|
(forward-line) |
734 |
|
(while (looking-at "[ \t]\\|[-A-Za-z0-9]+:") |
735 |
|
(if (looking-at "[-A-Za-z0-9]+:") |
736 |
|
(setq found (1+ found))) |
737 |
|
(forward-line)) |
738 |
|
(if (and (> found 0) (looking-at "\n")) |
739 |
|
(throw 'done 9999))) |
740 |
|
nil)))) |
741 |
|
|
742 |
|
(defun nndoc-mail-in-mail-article-begin () |
743 |
|
(let (point found) |
744 |
|
(if (catch 'done |
745 |
|
(while (re-search-forward "\n\n\\([-A-Za-z0-9]+:\\)" nil t) |
746 |
|
(setq found 0) |
747 |
|
(setq point (match-beginning 1)) |
748 |
|
(forward-line) |
749 |
|
(while (looking-at "[ \t]\\|[-A-Za-z0-9]+:") |
750 |
|
(if (looking-at "[-A-Za-z0-9]+:") |
751 |
|
(setq found (1+ found))) |
752 |
|
(forward-line)) |
753 |
|
(if (and (> found 0) (looking-at "\n")) |
754 |
|
(throw 'done t))) |
755 |
|
nil) |
756 |
|
(goto-char point)))) |
757 |
|
|
758 |
(deffoo nndoc-request-accept-article (group &optional server last) |
(deffoo nndoc-request-accept-article (group &optional server last) |
759 |
nil) |
nil) |
760 |
|
|
|
|
|
761 |
;;; |
;;; |
762 |
;;; Functions for dissecting the documents |
;;; Functions for dissecting the documents |
763 |
;;; |
;;; |
779 |
;; Remove blank lines. |
;; Remove blank lines. |
780 |
(while (eq (following-char) ?\n) |
(while (eq (following-char) ?\n) |
781 |
(delete-char 1)) |
(delete-char 1)) |
782 |
;; Find the beginning of the file. |
(if nndoc-dissection-function |
783 |
(when nndoc-file-begin |
(funcall nndoc-dissection-function) |
784 |
(nndoc-search nndoc-file-begin)) |
;; Find the beginning of the file. |
785 |
;; Go through the file. |
(when nndoc-file-begin |
786 |
(while (if (and first nndoc-first-article) |
(nndoc-search nndoc-file-begin)) |
787 |
(nndoc-search nndoc-first-article) |
;; Go through the file. |
788 |
(nndoc-article-begin)) |
(while (if (and first nndoc-first-article) |
789 |
(setq first nil) |
(nndoc-search nndoc-first-article) |
790 |
(cond (nndoc-head-begin-function |
(nndoc-article-begin)) |
791 |
(funcall nndoc-head-begin-function)) |
(setq first nil) |
792 |
(nndoc-head-begin |
(cond (nndoc-head-begin-function |
793 |
(nndoc-search nndoc-head-begin))) |
(funcall nndoc-head-begin-function)) |
794 |
(if (or (eobp) |
(nndoc-head-begin |
795 |
(and nndoc-file-end |
(nndoc-search nndoc-head-begin))) |
796 |
(looking-at nndoc-file-end))) |
(if (or (eobp) |
797 |
(goto-char (point-max)) |
(and nndoc-file-end |
798 |
(setq head-begin (point)) |
(looking-at nndoc-file-end))) |
799 |
(nndoc-search (or nndoc-head-end "^$")) |
(goto-char (point-max)) |
800 |
(setq head-end (point)) |
(setq head-begin (point)) |
801 |
(if nndoc-body-begin-function |
(nndoc-search (or nndoc-head-end "^$")) |
802 |
(funcall nndoc-body-begin-function) |
(setq head-end (point)) |
803 |
(nndoc-search (or nndoc-body-begin "^\n"))) |
(if nndoc-body-begin-function |
804 |
(setq body-begin (point)) |
(funcall nndoc-body-begin-function) |
805 |
(or (and nndoc-body-end-function |
(nndoc-search (or nndoc-body-begin "^\n"))) |
806 |
(funcall nndoc-body-end-function)) |
(setq body-begin (point)) |
807 |
(and nndoc-body-end |
(or (and nndoc-body-end-function |
808 |
(nndoc-search nndoc-body-end)) |
(funcall nndoc-body-end-function)) |
809 |
(nndoc-article-begin) |
(and nndoc-body-end |
810 |
(progn |
(nndoc-search nndoc-body-end)) |
811 |
(goto-char (point-max)) |
(nndoc-article-begin) |
812 |
(when nndoc-file-end |
(progn |
813 |
(and (re-search-backward nndoc-file-end nil t) |
(goto-char (point-max)) |
814 |
(beginning-of-line))))) |
(when nndoc-file-end |
815 |
(setq body-end (point)) |
(and (re-search-backward nndoc-file-end nil t) |
816 |
(push (list (incf i) head-begin head-end body-begin body-end |
(beginning-of-line))))) |
817 |
(count-lines body-begin body-end)) |
(setq body-end (point)) |
818 |
nndoc-dissection-alist)))))) |
(push (list (incf i) head-begin head-end body-begin body-end |
819 |
|
(count-lines body-begin body-end)) |
820 |
|
nndoc-dissection-alist))))))) |
821 |
|
|
822 |
(defun nndoc-article-begin () |
(defun nndoc-article-begin () |
823 |
(if nndoc-article-begin-function |
(if nndoc-article-begin-function |
892 |
(unless article-insert |
(unless article-insert |
893 |
(setq article-insert (buffer-substring (point-min) (point-max)) |
(setq article-insert (buffer-substring (point-min) (point-max)) |
894 |
head-end head-begin)) |
head-end head-begin)) |
895 |
|
;; Fix MIME-Version |
896 |
|
(unless (string-match "MIME-Version:" article-insert) |
897 |
|
(setq article-insert |
898 |
|
(concat article-insert "MIME-Version: 1.0\n"))) |
899 |
(setq summary-insert article-insert) |
(setq summary-insert article-insert) |
900 |
;; - summary Subject. |
;; - summary Subject. |
901 |
(setq summary-insert |
(setq summary-insert |