X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fnnfolder.el;h=876647f331edc8eaff6fc5ed22da6fe335f618d6;hb=9b741e050b400987d68ff761c6cc3276c932839c;hp=25613f60da51973ed120fc7fb8d061279453b5ca;hpb=3738187cad20787b5b99c4061256e30e19ee721a;p=elisp%2Fgnus.git- diff --git a/lisp/nnfolder.el b/lisp/nnfolder.el index 25613f6..876647f 100644 --- a/lisp/nnfolder.el +++ b/lisp/nnfolder.el @@ -1,12 +1,12 @@ ;;; nnfolder.el --- mail folder access for Gnus -;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 +;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 ;; Free Software Foundation, Inc. ;; Author: Simon Josefsson (adding MARKS) ;; ShengHuo Zhu (adding NOV) ;; Scott Byer ;; Lars Magne Ingebrigtsen -;; Masanobu UMEDA +;; Masanobu UMEDA ;; Keywords: mail ;; This file is part of GNU Emacs. @@ -30,11 +30,13 @@ ;;; Code: +(eval-when-compile (require 'cl)) +(eval-when-compile (require 'gnus-clfns)) + (require 'nnheader) (require 'message) (require 'nnmail) (require 'nnoo) -(eval-when-compile (require 'cl)) (require 'gnus) (require 'gnus-util) (require 'gnus-range) @@ -110,10 +112,10 @@ message, a huge time saver for large mailboxes.") (defvoo nnfolder-buffer-alist nil) (defvoo nnfolder-scantime-alist nil) (defvoo nnfolder-active-timestamp nil) -(defvoo nnfolder-active-file-coding-system mm-text-coding-system) +(defvoo nnfolder-active-file-coding-system nnheader-text-coding-system) (defvoo nnfolder-active-file-coding-system-for-write nnmail-active-file-coding-system) -(defvoo nnfolder-file-coding-system mm-text-coding-system) +(defvoo nnfolder-file-coding-system nnheader-text-coding-system) (defvoo nnfolder-file-coding-system-for-write nnheader-file-coding-system "Coding system for save nnfolder file. if nil, `nnfolder-file-coding-system' is used.") ; FIXME: fill-in the doc-string of this variable @@ -375,7 +377,7 @@ the group. Then the marks file will be regenerated properly by Gnus.") (let ((newnum (string-to-number (match-string 0)))) (if (nnmail-within-headers-p) (push newnum numbers)))) - ;; The article numbers are increasing, so this result is sorted. + ;; The article numbers are increasing, so this result is sorted. (nreverse numbers))))) (deffoo nnfolder-request-expire-articles @@ -428,7 +430,7 @@ the group. Then the marks file will be regenerated properly by Gnus.") (nnfolder-save-buffer) (nnfolder-adjust-min-active newsgroup) (nnfolder-save-active nnfolder-group-alist nnfolder-active-file) - (gnus-sorted-complement articles (nreverse deleted-articles))))) + (gnus-sorted-difference articles (nreverse deleted-articles))))) (deffoo nnfolder-request-move-article (article group server accept-form &optional last) @@ -473,6 +475,8 @@ the group. Then the marks file will be regenerated properly by Gnus.") result art-group) (goto-char (point-min)) (when (looking-at "X-From-Line: ") + (save-match-data + (mail-header-unfold-field)) (replace-match "From ")) (with-temp-buffer (let ((nnmail-file-coding-system nnfolder-active-file-coding-system) @@ -487,7 +491,7 @@ the group. Then the marks file will be regenerated properly by Gnus.") (while (re-search-backward (concat "^" nnfolder-article-marker) nil t) (delete-region (point) (progn (forward-line 1) (point)))) (when nnmail-cache-accepted-message-ids - (nnmail-cache-insert (nnmail-fetch-field "message-id"))) + (nnmail-cache-insert (nnmail-fetch-field "message-id") group)) (setq result (if (stringp group) (list (cons group (nnfolder-active-number group))) (setq art-group @@ -513,15 +517,13 @@ the group. Then the marks file will be regenerated properly by Gnus.") (save-excursion (set-buffer buffer) (goto-char (point-min)) - (let (xfrom) - (while (re-search-forward "^X-From-Line: \\(.*\\)$" nil t) - (setq xfrom (match-string 1)) - (gnus-delete-line)) - (goto-char (point-min)) - (if xfrom - (insert "From " xfrom "\n") - (unless (looking-at "From ") - (insert "From nobody " (current-time-string) "\n")))) + (if (not (looking-at "X-From-Line: ")) + (insert "From nobody " (current-time-string) "\n") + (replace-match "From ") + (forward-line 1) + (while (looking-at "[ \t]") + (delete-char -1) + (forward-line 1))) (nnfolder-normalize-buffer) (set-buffer nnfolder-current-buffer) (goto-char (point-min)) @@ -547,12 +549,12 @@ the group. Then the marks file will be regenerated properly by Gnus.") (if (not force) () ; Don't delete the articles. ;; Delete the file that holds the group. - (ignore-errors - (delete-file (nnfolder-group-pathname group)) - (when (file-exists-p (nnfolder-group-nov-pathname group)) - (delete-file (nnfolder-group-nov-pathname group))) - (when (file-exists-p (nnfolder-group-marks-pathname group)) - (delete-file (nnfolder-group-marks-pathname group))))) + (let ((data (nnfolder-group-pathname group)) + (nov (nnfolder-group-nov-pathname group)) + (mrk (nnfolder-group-marks-pathname group))) + (ignore-errors (delete-file data)) + (ignore-errors (delete-file nov)) + (ignore-errors (delete-file mrk)))) ;; Remove the group from all structures. (setq nnfolder-group-alist (delq (assoc group nnfolder-group-alist) nnfolder-group-alist) @@ -673,7 +675,8 @@ deleted. Point is left where the deleted region was." (setq nnfolder-current-buffer nil nnfolder-current-group nil)) ;; Change group. - (let ((file-name-coding-system nnmail-pathname-coding-system)) + (let ((file-name-coding-system nnmail-pathname-coding-system) + (pathname-coding-system nnmail-pathname-coding-system)) (when (and group (not (equal group nnfolder-current-group)) (progn @@ -684,15 +687,15 @@ deleted. Point is left where the deleted region was." (setq nnfolder-current-group group nnfolder-current-buffer nil) (let (inf file) - ;; If we have to change groups, see if we don't already have - ;; the folder in memory. If we do, verify the modtime and - ;; destroy the folder if needed so we can rescan it. + ;; If we have to change groups, see if we don't already have the + ;; folder in memory. If we do, verify the modtime and destroy + ;; the folder if needed so we can rescan it. (setq nnfolder-current-buffer (nth 1 (assoc group nnfolder-buffer-alist))) - ;; If the buffer is not live, make sure it isn't in the - ;; alist. If it is live, verify that nobody else has - ;; touched the file since last time. + ;; If the buffer is not live, make sure it isn't in the alist. If it + ;; is live, verify that nobody else has touched the file since last + ;; time. (when (and nnfolder-current-buffer (not (gnus-buffer-live-p nnfolder-current-buffer))) (setq nnfolder-buffer-alist (delq inf nnfolder-buffer-alist) @@ -711,7 +714,8 @@ deleted. Point is left where the deleted region was." (let ((nnmail-file-coding-system (or nnfolder-file-coding-system-for-write nnfolder-file-coding-system-for-write))) - (nnmail-write-region 1 1 file t 'nomesg))) + (nnmail-write-region (point-min) (point-min) + file t 'nomesg))) (when (setq nnfolder-current-buffer (nnfolder-read-folder group)) (set-buffer nnfolder-current-buffer) (push (list group nnfolder-current-buffer) @@ -834,7 +838,6 @@ deleted. Point is left where the deleted region was." (let ((nnheader-file-coding-system nnfolder-file-coding-system)) (nnheader-find-file-noselect file))))) - (mm-enable-multibyte) ;; Use multibyte buffer for future copying. (if (equal (cadr (assoc group nnfolder-scantime-alist)) (nth 5 (file-attributes file))) ;; This looks up-to-date, so we don't do any scanning. @@ -878,12 +881,12 @@ deleted. Point is left where the deleted region was." (setq articles (nreverse articles)))) (goto-char (point-min)) - ;; Anytime the active number is 1 or 0, it is suspect. In - ;; that case, search the file manually to find the active - ;; number. Or, of course, if we're being paranoid. (This - ;; would also be the place to build other lists from the - ;; header markers, such as expunge lists, etc., if we ever - ;; desired to abandon the active file entirely for mboxes.) + ;; Anytime the active number is 1 or 0, it is suspect. In that + ;; case, search the file manually to find the active number. Or, + ;; of course, if we're being paranoid. (This would also be the + ;; place to build other lists from the header markers, such as + ;; expunge lists, etc., if we ever desired to abandon the active + ;; file entirely for mboxes.) (when (or nnfolder-ignore-active-file novbuf (< maxid 2)) @@ -910,11 +913,10 @@ deleted. Point is left where the deleted region was." (setcdr active (max maxid (cdr active))) (goto-char (point-min))) - ;; As long as we trust that the user will only insert - ;; unmarked mail at the end, go to the end and search - ;; backwards for the last marker. Find the start of that - ;; message, and begin to search for unmarked messages from - ;; there. + ;; As long as we trust that the user will only insert unmarked mail + ;; at the end, go to the end and search backwards for the last + ;; marker. Find the start of that message, and begin to search for + ;; unmarked messages from there. (when (not (or nnfolder-distrust-mbox (< maxid 2))) (goto-char (point-max)) @@ -924,16 +926,16 @@ deleted. Point is left where the deleted region was." ;; (goto-char (point-min))) ) - ;; Keep track of the active number on our own, and insert it - ;; back into the active list when we're done. Also, prime - ;; the pump to cut down on the number of searches we do. + ;; Keep track of the active number on our own, and insert it back + ;; into the active list when we're done. Also, prime the pump to + ;; cut down on the number of searches we do. (unless (nnmail-search-unix-mail-delim) (goto-char (point-max))) (setq end (point-marker)) (while (not (= end (point-max))) (setq start (marker-position end)) (goto-char end) - ;; There may be more than one "From " line, so we skip past + ;; There may be more than one "From " line, so we skip past ;; them. (while (looking-at delim) (forward-line 1)) @@ -957,8 +959,7 @@ deleted. Point is left where the deleted region was." (widen))) (set-marker end nil) - ;; Make absolutely sure that the active list reflects - ;; reality! + ;; Make absolutely sure that the active list reflects reality! (nnfolder-save-active nnfolder-group-alist nnfolder-active-file) ;; Set the scantime for this group. @@ -1010,7 +1011,7 @@ This command does not work if you use short group names." (defun nnfolder-group-pathname (group) "Make pathname for GROUP." (setq group - (mm-encode-coding-string group nnmail-pathname-coding-system)) + (encode-coding-string group nnmail-pathname-coding-system)) (let ((dir (file-name-as-directory (expand-file-name nnfolder-directory)))) ;; If this file exists, we use it directly. (if (or nnmail-use-long-file-names @@ -1030,9 +1031,10 @@ This command does not work if you use short group names." (when (buffer-modified-p) (run-hooks 'nnfolder-save-buffer-hook) (gnus-make-directory (file-name-directory (buffer-file-name))) - (let ((coding-system-for-write - (or nnfolder-file-coding-system-for-write - nnfolder-file-coding-system))) + (let* ((coding-system-for-write + (or nnfolder-file-coding-system-for-write + nnfolder-file-coding-system)) + (output-coding-system coding-system-for-write)) (save-buffer))) (unless (or gnus-nov-is-evil nnfolder-nov-is-evil) (nnfolder-save-nov))) @@ -1163,13 +1165,14 @@ This command does not work if you use short group names." (nnfolder-open-marks group server) ;; Update info using `nnfolder-marks'. (mapcar (lambda (pred) - (gnus-info-set-marks - info - (gnus-update-alist-soft - (cdr pred) - (cdr (assq (cdr pred) nnfolder-marks)) - (gnus-info-marks info)) - t)) + (unless (memq (cdr pred) gnus-article-unpropagated-mark-lists) + (gnus-info-set-marks + info + (gnus-update-alist-soft + (cdr pred) + (cdr (assq (cdr pred) nnfolder-marks)) + (gnus-info-marks info)) + t))) gnus-article-mark-lists) (let ((seen (cdr (assq 'read nnfolder-marks)))) (gnus-info-set-read info @@ -1213,7 +1216,7 @@ This command does not work if you use short group names." (if (file-exists-p file) (condition-case err (with-temp-buffer - (gnus-sethash file (nth 5 (file-attributes file)) + (gnus-sethash file (nth 5 (file-attributes file)) nnfolder-marks-modtime) (nnheader-insert-file-contents file) (setq nnfolder-marks (read (current-buffer))) @@ -1233,7 +1236,8 @@ This command does not work if you use short group names." (push (cons 'read (gnus-info-read info)) nnfolder-marks) (dolist (el gnus-article-unpropagated-mark-lists) (setq nnfolder-marks (gnus-remassoc el nnfolder-marks))) - (nnfolder-save-marks group server))))) + (nnfolder-save-marks group server) + (nnheader-message 7 "Bootstrapping marks for %s...done" group))))) (provide 'nnfolder)