Synch with Gnus.
[elisp/gnus.git-] / lisp / nnheader.el
index 0396036..c777023 100644 (file)
@@ -189,7 +189,10 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
 ;; Parsing headers and NOV lines.
 
 (defsubst nnheader-header-value ()
-  (buffer-substring (match-end 0) (std11-field-end)))
+  (let ((pt (point)))
+    (prog1
+       (buffer-substring (match-end 0) (std11-field-end))
+      (goto-char pt))))
 
 (defun nnheader-parse-head (&optional naked)
   (let ((case-fold-search t)
@@ -231,7 +234,8 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
           ;; From.
           (progn
             (goto-char p)
-            (if (search-forward "\nfrom:" nil t)
+            (if (or (search-forward "\nfrom: " nil t)
+                    (search-forward "\nfrom:" nil t))
                 (nnheader-header-value) "(nobody)"))
           ;; Date.
           (progn
@@ -793,11 +797,14 @@ 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
+  "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,
+`nnheader-directory-files-safe' is used.")
+
 (defun nnheader-directory-files-safe (&rest args)
-  ;; It has been reported numerous times that `directory-files'
-  ;; fails with an alarming frequency on NFS mounted file systems.
-  ;; This function executes that function twice and returns
-  ;; the longest result.
+  "Execute `directory-files' twice and returns the longer result."
   (let ((first (apply 'directory-files args))
        (second (apply 'directory-files args)))
     (if (> (length first) (length second))
@@ -807,14 +814,20 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
 (defun nnheader-directory-articles (dir)
   "Return a list of all article files in directory DIR."
   (mapcar 'nnheader-file-to-number
-         (nnheader-directory-files-safe
-          dir nil nnheader-numerical-short-files t)))
+         (if nnheader-directory-files-is-safe 
+             (directory-files
+              dir nil nnheader-numerical-short-files t)
+           (nnheader-directory-files-safe
+            dir nil nnheader-numerical-short-files t))))
 
 (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))
-         (nnheader-directory-files-safe
-          dir nil nnheader-numerical-short-files t)))
+         (if nnheader-directory-files-is-safe 
+             (directory-files
+              dir nil nnheader-numerical-short-files t)
+           (nnheader-directory-files-safe
+            dir nil nnheader-numerical-short-files t))))
 
 (defun nnheader-fold-continuation-lines ()
   "Fold continuation lines in the current buffer."
@@ -836,7 +849,8 @@ If FULL, translate everything."
                      2 0))
        ;; We translate -- but only the file name.  We leave the directory
        ;; alone.
-       (if (memq system-type '(win32 w32 mswindows windows-nt))
+       (if (and (featurep 'xemacs)
+                (memq system-type '(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.
@@ -854,7 +868,7 @@ If FULL, translate everything."
              (if (string-match "\\(^\\w:\\|[/\\]\\)\\([^/\\]+\\)$" file)
                  (setq leaf (substring file (match-beginning 2))
                        path (substring file 0 (match-beginning 2)))))
-         ;; Fall back on this.
+         ;; Emacs DTRT, says andrewi.
          (setq leaf (file-name-nondirectory file)
                path (file-name-directory file))))
       (setq len (length leaf))