1 ;;; nnfolder.el --- mail folder access for Gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Simon Josefsson <simon@josefsson.org> (adding MARKS)
7 ;; ShengHuo Zhu <zsh@cs.rochester.edu> (adding NOV)
8 ;; Scott Byer <byer@mv.us.adobe.com>
9 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation, either version 3 of the License, or
18 ;; (at your option) any later version.
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
34 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
40 (eval-when-compile (require 'cl))
45 ;; FIXME not explicitly used in this file.
46 (autoload 'gnus-article-unpropagatable-p "gnus-sum")
48 (nnoo-declare nnfolder)
50 (defvoo nnfolder-directory (expand-file-name message-directory)
51 "The name of the nnfolder directory.")
53 (defvoo nnfolder-nov-directory nil
54 "The name of the nnfolder NOV directory.
55 If nil, `nnfolder-directory' is used.")
57 (defvoo nnfolder-marks-directory nil
58 "The name of the nnfolder MARKS directory.
59 If nil, `nnfolder-directory' is used.")
61 (defvoo nnfolder-active-file
62 (nnheader-concat nnfolder-directory "active")
63 "The name of the active file.")
65 ;; I renamed this variable to something more in keeping with the general GNU
68 (defvoo nnfolder-ignore-active-file nil
69 "If non-nil, the active file is ignored.
70 This causes nnfolder to do some extra work in order to determine the
71 true active ranges of an mbox file. Note that the active file is
72 still saved, but its values are not used. This costs some extra time
73 when scanning an mbox when opening it.")
75 (defvoo nnfolder-distrust-mbox nil
76 "If non-nil, the folder will be distrusted.
77 This means that nnfolder will not trust the user with respect to
78 inserting unaccounted for mail in the middle of an mbox file. This
79 can greatly slow down scans, which now must scan the entire file for
80 unmarked messages. When nil, scans occur forward from the last marked
81 message, a huge time saver for large mailboxes.")
83 (defvoo nnfolder-newsgroups-file
84 (concat (file-name-as-directory nnfolder-directory) "newsgroups")
85 "Mail newsgroups description file.")
87 (defvoo nnfolder-get-new-mail t
88 "If non-nil, nnfolder will check the incoming mail file and split the mail.")
90 (defvoo nnfolder-prepare-save-mail-hook nil
91 "Hook run narrowed to an article before saving.")
93 (defvoo nnfolder-save-buffer-hook nil
94 "Hook run before saving the nnfolder mbox buffer.")
97 (defvoo nnfolder-inhibit-expiry nil
98 "If non-nil, inhibit expiry.")
102 (defconst nnfolder-version "nnfolder 2.0"
105 (defconst nnfolder-article-marker "X-Gnus-Article-Number: "
106 "String used to demarcate what the article number for a message is.")
108 (defvoo nnfolder-current-group nil)
109 (defvoo nnfolder-current-buffer nil)
110 (defvoo nnfolder-status-string "")
111 (defvoo nnfolder-group-alist nil)
112 (defvoo nnfolder-buffer-alist nil)
113 (defvoo nnfolder-scantime-alist nil)
114 (defvoo nnfolder-active-timestamp nil)
115 (defvoo nnfolder-active-file-coding-system mm-text-coding-system)
116 (defvoo nnfolder-active-file-coding-system-for-write
117 nnmail-active-file-coding-system)
118 (defvoo nnfolder-file-coding-system mm-text-coding-system)
119 (defvoo nnfolder-file-coding-system-for-write nnheader-file-coding-system
120 "Coding system for save nnfolder file.
121 if nil, `nnfolder-file-coding-system' is used.") ; FIXME: fill-in the doc-string of this variable
123 (defvoo nnfolder-nov-is-evil nil
124 "If non-nil, Gnus will never generate and use nov databases for mail groups.
125 Using nov databases will speed up header fetching considerably.
126 This variable shouldn't be flipped much. If you have, for some reason,
127 set this to t, and want to set it to nil again, you should always run
128 the `nnfolder-generate-active-file' command. The function will go
129 through all nnfolder directories and generate nov databases for them
130 all. This may very well take some time.")
132 (defvoo nnfolder-nov-file-suffix ".nov")
134 (defvoo nnfolder-nov-buffer-alist nil)
136 (defvar nnfolder-nov-buffer-file-name nil)
138 (defvoo nnfolder-marks-is-evil nil
139 "If non-nil, Gnus will never generate and use marks file for mail groups.
140 Using marks files makes it possible to backup and restore mail groups
141 separately from `.newsrc.eld'. If you have, for some reason, set
142 this to t, and want to set it to nil again, you should always remove
143 the corresponding marks file (usually base nnfolder file name
144 concatenated with `.mrk', but see `nnfolder-marks-file-suffix') for
145 the group. Then the marks file will be regenerated properly by Gnus.")
147 (defvoo nnfolder-marks nil)
149 (defvoo nnfolder-marks-file-suffix ".mrk")
151 (defvar nnfolder-marks-modtime (gnus-make-hashtable))
155 ;;; Interface functions
157 (nnoo-define-basics nnfolder)
159 (deffoo nnfolder-retrieve-headers (articles &optional group server fetch-old)
160 (with-current-buffer nntp-server-buffer
162 (let (article start stop num)
163 (nnfolder-possibly-change-group group server)
164 (when nnfolder-current-buffer
165 (set-buffer nnfolder-current-buffer)
166 (goto-char (point-min))
167 (if (stringp (car articles))
169 (if (nnfolder-retrieve-headers-with-nov articles fetch-old)
171 (setq articles (gnus-sorted-intersection
172 ;; Is ARTICLES sorted?
174 (nnfolder-existing-articles)))
175 (while (setq article (pop articles))
176 (set-buffer nnfolder-current-buffer)
177 (cond ((nnfolder-goto-article article)
179 (setq stop (if (search-forward "\n\n" nil t)
182 (set-buffer nntp-server-buffer)