Add nnir-1.68.
[elisp/gnus.git-] / lisp / nnheader.el
index f8b84f5..466d701 100644 (file)
@@ -5,7 +5,7 @@
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
-;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
+;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;     MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;;     Katsumi Yamaoka <yamaoka@jpl.org>
 ;; Keywords: mail, news, MIME
   (autoload 'gnus-sorted-complement "gnus-range"))
 
 (defvar nnheader-max-head-length 4096
-  "*Max length of the head of articles.")
+  "*Max length of the head of articles.
+
+Value is an integer, nil, or t.  Nil means read in chunks of a file
+indefinitely until a complete head is found\; t means always read the
+entire file immediately, disregarding `nnheader-head-chop-length'.
+
+Integer values will in effect be rounded up to the nearest multiple of
+`nnheader-head-chop-length'.")
 
 (defvar nnheader-head-chop-length 2048
   "*Length of each read operation when trying to fetch HEAD headers.")
@@ -204,8 +211,9 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
 
 (defsubst nnheader-header-value ()
   (let ((pt (point)))
-    (prog1
-       (buffer-substring (match-end 0) (std11-field-end))
+    (prog2
+       (skip-chars-forward " \t")
+       (buffer-substring (point) (std11-field-end))
       (goto-char pt))))
 
 (defun nnheader-parse-head (&optional naked)
@@ -243,18 +251,17 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
           ;; Subject.
           (progn
             (goto-char p)
-            (if (search-forward "\nsubject: " nil t)
+            (if (search-forward "\nsubject:" nil t)
                 (nnheader-header-value) "(none)"))
           ;; From.
           (progn
             (goto-char p)
-            (if (or (search-forward "\nfrom: " nil t)
-                    (search-forward "\nfrom:" nil t))
+            (if (search-forward "\nfrom:" nil t)
                 (nnheader-header-value) "(nobody)"))
           ;; Date.
           (progn
             (goto-char p)
-            (if (search-forward "\ndate: " nil t)
+            (if (search-forward "\ndate:" nil t)
                 (nnheader-header-value) ""))
           ;; Message-ID.
           (progn
@@ -270,12 +277,12 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
           ;; References.
           (progn
             (goto-char p)
-            (if (search-forward "\nreferences: " nil t)
+            (if (search-forward "\nreferences:" nil t)
                 (nnheader-header-value)
               ;; Get the references from the in-reply-to header if there
               ;; were no references and the in-reply-to header looks
               ;; promising.
-              (if (and (search-forward "\nin-reply-to: " nil t)
+              (if (and (search-forward "\nin-reply-to:" nil t)
                        (setq in-reply-to (nnheader-header-value))
                        (string-match "<[^\n>]+>" in-reply-to))
                   (let (ref2)
@@ -287,7 +294,7 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
                                             (match-end 0)))
                       (when (> (length ref2) (length ref))
                         (setq ref ref2)))
-                     ref)
+                    ref)
                 nil)))
           ;; Chars.
           0
@@ -301,7 +308,7 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
           ;; Xref.
           (progn
             (goto-char p)
-            (and (search-forward "\nxref: " nil t)
+            (and (search-forward "\nxref:" nil t)
                  (nnheader-header-value)))
 
           ;; Extra.
@@ -311,7 +318,7 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
               (while extra
                 (goto-char p)
                 (when (search-forward
-                       (concat "\n" (symbol-name (car extra)) ": ") nil t)
+                       (concat "\n" (symbol-name (car extra)) ":") nil t)
                   (push (cons (car extra) (nnheader-header-value))
                         out))
                 (pop extra))
@@ -811,7 +818,10 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
     (string-match nnheader-numerical-short-files file)
     (string-to-int (match-string 0 file))))
 
-(defvar nnheader-directory-files-is-safe nil
+(defvar nnheader-directory-files-is-safe
+  (or (eq system-type 'windows-nt)
+      (and (not (featurep 'xemacs))
+          (> emacs-major-version 20)))
   "If non-nil, Gnus believes `directory-files' is safe.
 It has been reported numerous times that `directory-files' fails with
 an alarming frequency on NFS mounted file systems. If it is nil,
@@ -828,7 +838,7 @@ an alarming frequency on NFS mounted file systems. If it is nil,
 (defun nnheader-directory-articles (dir)
   "Return a list of all article files in directory DIR."
   (mapcar 'nnheader-file-to-number
-         (if nnheader-directory-files-is-safe 
+         (if nnheader-directory-files-is-safe
              (directory-files
               dir nil nnheader-numerical-short-files t)
            (nnheader-directory-files-safe
@@ -837,7 +847,7 @@ an alarming frequency on NFS mounted file systems. If it is nil,
 (defun nnheader-article-to-file-alist (dir)
   "Return an alist of article/file pairs in DIR."
   (mapcar (lambda (file) (cons (nnheader-file-to-number file) file))
-         (if nnheader-directory-files-is-safe 
+         (if nnheader-directory-files-is-safe
              (directory-files
               dir nil nnheader-numerical-short-files t)
            (nnheader-directory-files-safe
@@ -864,12 +874,12 @@ If FULL, translate everything."
        ;; We translate -- but only the file name.  We leave the directory
        ;; alone.
        (if (and (featurep 'xemacs)
-                (memq system-type '(win32 w32 mswindows windows-nt)))
+                (memq system-type '(cygwin32 win32 w32 mswindows windows-nt)))
            ;; This is needed on NT and stuff, because
            ;; file-name-nondirectory is not enough to split
            ;; file names, containing ':', e.g.
            ;; "d:\\Work\\News\\nntp+news.fido7.ru:fido7.ru.gnu.SCORE"
-           ;; 
+           ;;
            ;; we are trying to correctly split such names:
            ;; "d:file.name" -> "a:" "file.name"
            ;; "aaa:bbb.ccc" -> "" "aaa:bbb.ccc"
@@ -1062,7 +1072,7 @@ find-file-hooks, etc.
        (auto-mode-alist (nnheader-auto-mode-alist))
        (default-major-mode 'fundamental-mode)
        (enable-local-variables nil)
-        (after-insert-file-functions nil)
+       (after-insert-file-functions nil)
        (enable-local-eval nil)
        (find-file-hooks nil))
     (insert-file-contents-as-coding-system
@@ -1174,6 +1184,14 @@ find-file-hooks, etc.
       (push path result))))
 (defalias 'mm-image-load-path 'nnheader-image-load-path)
 
+(defalias 'mm-read-coding-system
+  (if (or (and (featurep 'xemacs)
+              (<= (string-to-number emacs-version) 21.1))
+         (boundp 'MULE))
+      (lambda (prompt &optional default-coding-system)
+       (read-coding-system prompt))
+    'read-coding-system))
+
 (when (featurep 'xemacs)
   (require 'nnheaderxm))