Importing pgnus-0.79
[elisp/gnus.git-] / lisp / nnheader.el
index 9d64793..3b662a5 100644 (file)
@@ -1,5 +1,6 @@
+
 ;;; nnheader.el --- header access macros for Gnus and its backends
-;; Copyright (C) 1987,88,89,90,93,94,95,96,97,98 Free Software Foundation, Inc.
+;; Copyright (C) 1987-1990,1993-1999 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
 ;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -50,7 +51,7 @@
 
 (defvar nnheader-file-name-translation-alist nil
   "*Alist that says how to translate characters in file names.
-For instance, if \":\" is illegal as a file character in file names
+For instance, if \":\" is invalid as a file character in file names
 on your system, you could say something like:
 
 \(setq nnheader-file-name-translation-alist '((?: . ?_)))")
@@ -267,7 +268,7 @@ on your system, you could say something like:
             (goto-char p)
             (and (search-forward "\nxref: " nil t)
                  (nnheader-header-value)))
-          
+
           ;; Extra.
           (when nnmail-extra-headers
             (let ((extra nnmail-extra-headers)
@@ -298,6 +299,22 @@ on your system, you could say something like:
           (if (numberp num) num 0)))
      (or (eobp) (forward-char 1))))
 
+(defmacro nnheader-nov-parse-extra ()
+  '(let (out string)
+     (while (not (memq (char-after) '(?\n nil)))
+       (setq string (nnheader-nov-field))
+       (when (string-match "^\\([^ :]+\\): " string)
+        (push (cons (intern (match-string 1 string))
+                    (substring string (match-end 0)))
+              out)))
+     out))
+
+(defmacro nnheader-nov-read-message-id ()
+  '(let ((id (nnheader-nov-field)))
+     (if (string-match "^<[^>]+>$" id)
+        id
+       (nnheader-generate-fake-message-id))))
+
 (defun nnheader-parse-nov ()
   (let ((eol (gnus-point-at-eol)))
     (vector
@@ -305,15 +322,14 @@ on your system, you could say something like:
      (nnheader-nov-field)              ; subject
      (nnheader-nov-field)              ; from
      (nnheader-nov-field)              ; date
-     (or (nnheader-nov-field)
-        (nnheader-generate-fake-message-id)) ; id
+     (nnheader-nov-read-message-id)    ; id
      (nnheader-nov-field)              ; refs
      (nnheader-nov-read-integer)       ; chars
      (nnheader-nov-read-integer)       ; lines
      (if (eq (char-after) ?\n)
         nil
        (nnheader-nov-field))           ; misc
-     )))
+     (nnheader-nov-parse-extra))))     ; extra
 
 (defun nnheader-insert-nov (header)
   (princ (mail-header-number header) (current-buffer))
@@ -330,9 +346,11 @@ on your system, you could say something like:
   (insert "\t")
   (princ (or (mail-header-lines header) 0) (current-buffer))
   (insert "\t")
+  (when (mail-header-xref header)
+    (insert "Xref: " (mail-header-xref header)))
   (when (or (mail-header-xref header)
            (mail-header-extra header))
-    (insert "Xref: " (mail-header-xref header) "\t"))
+    (insert "\t"))
   (when (mail-header-extra header)
     (let ((extra (mail-header-extra header)))
       (while extra
@@ -482,7 +500,8 @@ the line could be found."
 (defun nnheader-insert-references (references message-id)
   "Insert a References header based on REFERENCES and MESSAGE-ID."
   (if (and (not references) (not message-id))
-      ()                               ; This is illegal, but not all articles have Message-IDs.
+      ;; This is invalid, but not all articles have Message-IDs.
+      ()
     (mail-position-on-field "References")
     (let ((begin (save-excursion (beginning-of-line) (point)))
          (fill-column 78)
@@ -742,7 +761,7 @@ If FILE, find the \".../etc/PACKAGE\" file instead."
       (when (string-match (car ange-ftp-path-format) path)
        (ange-ftp-re-read-dir path)))))
 
-(defvar nnheader-file-coding-system 'no-conversion
+(defvar nnheader-file-coding-system 'binary
   "Coding system used in file backends of Gnus.")
 
 (defun nnheader-insert-file-contents (filename &optional visit beg end replace)