]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/nnml.el
(comint-postoutput-scroll-to-bottom): Cope with unset
[gnu-emacs] / lisp / gnus / nnml.el
index cd921f2e3863072e0364099dd266c90a4ad7edd5..6819086fa6c8c70bffaddb882a809a80fbd1dd93 100644 (file)
@@ -38,7 +38,7 @@
 (nnoo-declare nnml)
 
 (defvoo nnml-directory message-directory
-  "Mail spool directory.")
+  "Spool directory for the nnml mail backend.")
 
 (defvoo nnml-active-file
   (concat (file-name-as-directory nnml-directory) "active")
@@ -98,6 +98,9 @@ all.  This may very well take some time.")
       (let ((file nil)
            (number (length sequence))
            (count 0)
+           ;; 1997/8/12 by MORIOKA Tomohiko
+           (file-name-coding-system 'binary) ; for Emacs 20
+           (pathname-coding-system 'binary)  ; for XEmacs/mule
            beg article)
        (if (stringp (car sequence))
            'headers
@@ -160,6 +163,9 @@ all.  This may very well take some time.")
 (deffoo nnml-request-article (id &optional group server buffer)
   (nnml-possibly-change-directory group server)
   (let* ((nntp-server-buffer (or buffer nntp-server-buffer))
+        ;; 1997/8/12 by MORIOKA Tomohiko
+        (file-name-coding-system 'binary) ; for Emacs 20
+        (pathname-coding-system 'binary)  ; for XEmacs/mule
         path gpath group-num)
     (if (stringp id)
        (when (and (setq group-num (nnml-find-group-number id))
@@ -188,27 +194,30 @@ all.  This may very well take some time.")
            (string-to-int (file-name-nondirectory path)))))))
 
 (deffoo nnml-request-group (group &optional server dont-check)
-  (cond
-   ((not (nnml-possibly-change-directory group server))
-    (nnheader-report 'nnml "Invalid group (no such directory)"))
-   ((not (file-exists-p nnml-current-directory))
-    (nnheader-report 'nnml "Directory %s does not exist"
-                    nnml-current-directory))
-   ((not (file-directory-p nnml-current-directory))
-    (nnheader-report 'nnml "%s is not a directory" nnml-current-directory))
-   (dont-check
-    (nnheader-report 'nnml "Group %s selected" group)
-    t)
-   (t
-    (nnheader-re-read-dir nnml-current-directory)
-    (nnmail-activate 'nnml)
-    (let ((active (nth 1 (assoc group nnml-group-alist))))
-      (if (not active)
-         (nnheader-report 'nnml "No such group: %s" group)
-       (nnheader-report 'nnml "Selected group %s" group)
-       (nnheader-insert "211 %d %d %d %s\n"
-                        (max (1+ (- (cdr active) (car active))) 0)
-                        (car active) (cdr active) group))))))
+  ;; 1997/8/12 by MORIOKA Tomohiko
+  (let ((file-name-coding-system 'binary) ; for Emacs 20
+       (pathname-coding-system 'binary)) ; for XEmacs/mule
+    (cond
+     ((not (nnml-possibly-change-directory group server))
+      (nnheader-report 'nnml "Invalid group (no such directory)"))
+     ((not (file-exists-p nnml-current-directory))
+      (nnheader-report 'nnml "Directory %s does not exist"
+                      nnml-current-directory))
+     ((not (file-directory-p nnml-current-directory))
+      (nnheader-report 'nnml "%s is not a directory" nnml-current-directory))
+     (dont-check
+      (nnheader-report 'nnml "Group %s selected" group)
+      t)
+     (t
+      (nnheader-re-read-dir nnml-current-directory)
+      (nnmail-activate 'nnml)
+      (let ((active (nth 1 (assoc group nnml-group-alist))))
+       (if (not active)
+           (nnheader-report 'nnml "No such group: %s" group)
+         (nnheader-report 'nnml "Selected group %s" group)
+         (nnheader-insert "211 %d %d %d %s\n"
+                          (max (1+ (- (cdr active) (car active))) 0)
+                          (car active) (cdr active) group)))))))
 
 (deffoo nnml-request-scan (&optional group server)
   (setq nnml-article-file-alist nil)
@@ -236,7 +245,13 @@ all.  This may very well take some time.")
 
 (deffoo nnml-request-list (&optional server)
   (save-excursion
-    (nnmail-find-file nnml-active-file)
+    ;; 1997/8/12 by MORIOKA Tomohiko
+    ;; for XEmacs/mule.
+    (let ((nnmail-file-coding-system nnmail-active-file-coding-system)
+         (file-name-coding-system 'binary) ; for Emacs 20
+         (pathname-coding-system 'binary)) ; for XEmacs/mule
+      (nnmail-find-file nnml-active-file)
+      )
     (setq nnml-group-alist (nnmail-get-active))
     t))
 
@@ -460,8 +475,15 @@ all.  This may very well take some time.")
 (defun nnml-article-to-file (article)
   (nnml-update-file-alist)
   (let (file)
-    (when (setq file (cdr (assq article nnml-article-file-alist)))
-      (concat nnml-current-directory file))))
+    (if (setq file (cdr (assq article nnml-article-file-alist)))
+       (concat nnml-current-directory file)
+      ;; Just to make sure nothing went wrong when reading over NFS --
+      ;; check once more.
+      (when (file-exists-p
+            (setq file (concat nnml-current-directory "/"
+                               (number-to-string article))))
+       (nnml-update-file-alist t)
+       file))))
 
 (defun nnml-deletable-article-p (group article)
   "Say whether ARTICLE in GROUP can be deleted."
@@ -540,7 +562,10 @@ all.  This may very well take some time.")
     (nnml-open-server server))
   (if (not group)
       t
-    (let ((pathname (nnmail-group-pathname group nnml-directory)))
+    (let ((pathname (nnmail-group-pathname group nnml-directory))
+         ;; 1997/8/14 by MORIOKA Tomohiko
+         (file-name-coding-system 'binary) ; for Emacs 20
+         (pathname-coding-system 'binary)) ; for XEmacs/mule
       (when (not (equal pathname nnml-current-directory))
        (setq nnml-current-directory pathname
              nnml-current-group group
@@ -752,8 +777,7 @@ all.  This may very well take some time.")
             (search-forward "\n\n" nil t)
             (setq chars (- (point-max) (point)))
             (max 1 (1- (point)))))
-         (when (and (not (= 0 chars))  ; none of them empty files...
-                    (not (= (point-min) (point-max))))
+         (unless (zerop (buffer-size))
            (goto-char (point-min))
            (setq headers (nnml-parse-head chars (caar files)))
            (save-excursion
@@ -783,8 +807,9 @@ all.  This may very well take some time.")
                (setf (car active) num)))))))
     t))
 
-(defun nnml-update-file-alist ()
-  (unless nnml-article-file-alist
+(defun nnml-update-file-alist (&optional force)
+  (when (or (not nnml-article-file-alist)
+           force)
     (setq nnml-article-file-alist
          (nnheader-article-to-file-alist nnml-current-directory))))