Mercurial > emacs
comparison lisp/gnus/nndoc.el @ 82951:0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Thu, 22 Jul 2004 16:45:51 +0000 |
parents | 695cf19ef79e |
children | 590114f9753d |
comparison
equal
deleted
inserted
replaced
56503:8bbd2323fbf2 | 82951:0fde48feb604 |
---|---|
1 ;;; nndoc.el --- single file access for Gnus | 1 ;;; nndoc.el --- single file access for Gnus |
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 | 2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
3 ;; Free Software Foundation, Inc. | 3 ;; Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | 5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
6 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | 6 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
7 ;; Keywords: news | 7 ;; Keywords: news |
56 | 56 |
57 (defvar nndoc-type-alist | 57 (defvar nndoc-type-alist |
58 `((mmdf | 58 `((mmdf |
59 (article-begin . "^\^A\^A\^A\^A\n") | 59 (article-begin . "^\^A\^A\^A\^A\n") |
60 (body-end . "^\^A\^A\^A\^A\n")) | 60 (body-end . "^\^A\^A\^A\^A\n")) |
61 (exim-bounce | 61 (mime-digest |
62 (article-begin . "^------ This is a copy of the message, including all the headers. ------\n\n") | 62 (article-begin . "") |
63 (body-end-function . nndoc-exim-bounce-body-end-function)) | 63 (head-begin . "^ ?\n") |
64 (head-end . "^ ?$") | |
65 (body-end . "") | |
66 (file-end . "") | |
67 (subtype digest guess)) | |
68 (mime-parts | |
69 (generate-head-function . nndoc-generate-mime-parts-head) | |
70 (article-transform-function . nndoc-transform-mime-parts)) | |
64 (nsmail | 71 (nsmail |
65 (article-begin . "^From - ")) | 72 (article-begin . "^From - ")) |
66 (news | 73 (news |
67 (article-begin . "^Path:")) | 74 (article-begin . "^Path:")) |
68 (rnews | 75 (rnews |
74 (babyl | 81 (babyl |
75 (article-begin . "\^_\^L *\n") | 82 (article-begin . "\^_\^L *\n") |
76 (body-end . "\^_") | 83 (body-end . "\^_") |
77 (body-begin-function . nndoc-babyl-body-begin) | 84 (body-begin-function . nndoc-babyl-body-begin) |
78 (head-begin-function . nndoc-babyl-head-begin)) | 85 (head-begin-function . nndoc-babyl-head-begin)) |
86 (exim-bounce | |
87 (article-begin . "^------ This is a copy of the message, including all the headers. ------\n\n") | |
88 (body-end-function . nndoc-exim-bounce-body-end-function)) | |
79 (rfc934 | 89 (rfc934 |
80 (article-begin . "^--.*\n+") | 90 (article-begin . "^--.*\n+") |
81 (body-end . "^--.*$") | 91 (body-end . "^--.*$") |
82 (prepare-body-function . nndoc-unquote-dashes)) | 92 (prepare-body-function . nndoc-unquote-dashes)) |
83 (mailman | 93 (mailman |
89 (body-end . "^\t------*[ \t]^*\n^ \\*") | 99 (body-end . "^\t------*[ \t]^*\n^ \\*") |
90 (body-begin . "^\t") | 100 (body-begin . "^\t") |
91 (head-end . "^\t") | 101 (head-end . "^\t") |
92 (generate-head-function . nndoc-generate-clari-briefs-head) | 102 (generate-head-function . nndoc-generate-clari-briefs-head) |
93 (article-transform-function . nndoc-transform-clari-briefs)) | 103 (article-transform-function . nndoc-transform-clari-briefs)) |
94 (mime-digest | 104 |
95 (article-begin . "") | |
96 (head-begin . "^ ?\n") | |
97 (head-end . "^ ?$") | |
98 (body-end . "") | |
99 (file-end . "") | |
100 (subtype digest guess)) | |
101 (mime-parts | |
102 (generate-head-function . nndoc-generate-mime-parts-head) | |
103 (article-transform-function . nndoc-transform-mime-parts)) | |
104 (standard-digest | 105 (standard-digest |
105 (first-article . ,(concat "^" (make-string 70 ?-) "\n *\n+")) | 106 (first-article . ,(concat "^" (make-string 70 ?-) "\n *\n+")) |
106 (article-begin . ,(concat "^\n" (make-string 30 ?-) "\n *\n+")) | 107 (article-begin . ,(concat "^\n" (make-string 30 ?-) "\n *\n+")) |
107 (prepare-body-function . nndoc-unquote-dashes) | 108 (prepare-body-function . nndoc-unquote-dashes) |
108 (body-end-function . nndoc-digest-body-end) | 109 (body-end-function . nndoc-digest-body-end) |
391 (setq result nil)))) | 392 (setq result nil)))) |
392 (unless (or result results) | 393 (unless (or result results) |
393 (error "Document is not of any recognized type")) | 394 (error "Document is not of any recognized type")) |
394 (if result | 395 (if result |
395 (car entry) | 396 (car entry) |
396 (cadar (sort results 'car-less-than-car))))) | 397 (cadar (last (sort results 'car-less-than-car)))))) |
397 | 398 |
398 ;;; | 399 ;;; |
399 ;;; Built-in type predicates and functions | 400 ;;; Built-in type predicates and functions |
400 ;;; | 401 ;;; |
401 | 402 |
769 | 770 |
770 (defun nndoc-dissect-buffer () | 771 (defun nndoc-dissect-buffer () |
771 "Go through the document and partition it into heads/bodies/articles." | 772 "Go through the document and partition it into heads/bodies/articles." |
772 (let ((i 0) | 773 (let ((i 0) |
773 (first t) | 774 (first t) |
774 head-begin head-end body-begin body-end) | 775 art-begin head-begin head-end body-begin body-end) |
775 (setq nndoc-dissection-alist nil) | 776 (setq nndoc-dissection-alist nil) |
776 (save-excursion | 777 (save-excursion |
777 (set-buffer nndoc-current-buffer) | 778 (set-buffer nndoc-current-buffer) |
778 (goto-char (point-min)) | 779 (goto-char (point-min)) |
779 ;; Remove blank lines. | 780 ;; Remove blank lines. |
785 (when nndoc-file-begin | 786 (when nndoc-file-begin |
786 (nndoc-search nndoc-file-begin)) | 787 (nndoc-search nndoc-file-begin)) |
787 ;; Go through the file. | 788 ;; Go through the file. |
788 (while (if (and first nndoc-first-article) | 789 (while (if (and first nndoc-first-article) |
789 (nndoc-search nndoc-first-article) | 790 (nndoc-search nndoc-first-article) |
790 (nndoc-article-begin)) | 791 (if art-begin |
791 (setq first nil) | 792 (goto-char art-begin) |
793 (nndoc-article-begin))) | |
794 (setq first nil | |
795 art-begin nil) | |
792 (cond (nndoc-head-begin-function | 796 (cond (nndoc-head-begin-function |
793 (funcall nndoc-head-begin-function)) | 797 (funcall nndoc-head-begin-function)) |
794 (nndoc-head-begin | 798 (nndoc-head-begin |
795 (nndoc-search nndoc-head-begin))) | 799 (nndoc-search nndoc-head-begin))) |
796 (if (or (eobp) | 800 (if (or (eobp) |
806 (setq body-begin (point)) | 810 (setq body-begin (point)) |
807 (or (and nndoc-body-end-function | 811 (or (and nndoc-body-end-function |
808 (funcall nndoc-body-end-function)) | 812 (funcall nndoc-body-end-function)) |
809 (and nndoc-body-end | 813 (and nndoc-body-end |
810 (nndoc-search nndoc-body-end)) | 814 (nndoc-search nndoc-body-end)) |
811 (nndoc-article-begin) | 815 (and (nndoc-article-begin) |
816 (setq art-begin (point))) | |
812 (progn | 817 (progn |
813 (goto-char (point-max)) | 818 (goto-char (point-max)) |
814 (when nndoc-file-end | 819 (when nndoc-file-end |
815 (and (re-search-backward nndoc-file-end nil t) | 820 (and (re-search-backward nndoc-file-end nil t) |
816 (beginning-of-line))))) | 821 (beginning-of-line))))) |
888 (unless type | 893 (unless type |
889 (setq type "text" | 894 (setq type "text" |
890 subtype "plain")) | 895 subtype "plain")) |
891 ;; Prepare the article and summary inserts. | 896 ;; Prepare the article and summary inserts. |
892 (unless article-insert | 897 (unless article-insert |
893 (setq article-insert (buffer-substring (point-min) (point-max)) | 898 (setq article-insert (buffer-string) |
894 head-end head-begin)) | 899 head-end head-begin)) |
895 ;; Fix MIME-Version | 900 ;; Fix MIME-Version |
896 (unless (string-match "MIME-Version:" article-insert) | 901 (unless (string-match "MIME-Version:" article-insert) |
897 (setq article-insert | 902 (setq article-insert |
898 (concat article-insert "MIME-Version: 1.0\n"))) | 903 (concat article-insert "MIME-Version: 1.0\n"))) |