1 ;;; elmo-mark.el --- Global mark folder for ELMO.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
8 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
34 (defcustom elmo-mark-default-mark "$"
35 "*Default global-mark for mark-folder."
41 (luna-define-class elmo-mark-folder (elmo-map-folder) (mark))
42 (luna-define-internal-accessors 'elmo-mark-folder))
44 (luna-define-method elmo-folder-initialize ((folder
47 (elmo-mark-folder-set-mark-internal
49 elmo-mark-default-mark)
52 (luna-define-method elmo-folder-have-subfolder-p ((folder elmo-mark-folder))
55 (luna-define-method elmo-folder-expand-msgdb-path ((folder
57 (expand-file-name "mark"
58 (expand-file-name "internal"
59 elmo-msgdb-directory)))
61 (luna-define-method elmo-map-folder-list-message-locations
62 ((folder elmo-mark-folder))
63 (elmo-mark-folder-list-message-locations folder))
65 (defun elmo-mark-folder-list-message-locations (folder)
67 (dolist (pair (or elmo-msgdb-global-mark-alist
68 (setq elmo-msgdb-global-mark-alist
71 elmo-msgdb-global-mark-filename
72 elmo-msgdb-directory)))))
73 (if (string= (elmo-mark-folder-mark-internal folder)
75 (setq result (cons (car pair) result))))
78 (luna-define-method elmo-folder-message-file-p ((folder elmo-mark-folder))
81 (luna-define-method elmo-message-file-name ((folder elmo-mark-folder)
83 (elmo-file-cache-get-path
84 (elmo-map-message-location folder number)))
86 (luna-define-method elmo-folder-msgdb-create ((folder elmo-mark-folder)
88 already-mark seen-mark
91 (elmo-mark-folder-msgdb-create folder numbers new-mark already-mark
92 seen-mark important-mark))
94 (defun elmo-mark-folder-msgdb-create (folder numbers new-mark already-mark
95 seen-mark important-mark)
97 (len (length numbers))
98 overview number-alist mark-alist entity message-id
100 (message "Creating msgdb...")
103 (elmo-msgdb-create-overview-entity-from-file
104 (car numbers) (elmo-message-file-name folder (car numbers))))
107 (setq num (elmo-msgdb-overview-entity-get-number entity))
109 (elmo-msgdb-append-element
111 (setq message-id (elmo-msgdb-overview-entity-get-id entity))
113 (elmo-msgdb-number-add number-alist
117 (elmo-msgdb-mark-append
119 num (elmo-mark-folder-mark-internal folder))))
120 (when (> len elmo-display-progress-threshold)
122 (elmo-display-progress
123 'elmo-mark-folder-msgdb-create "Creating msgdb..."
125 (setq numbers (cdr numbers)))
126 (message "Creating msgdb...done")
127 (list overview number-alist mark-alist)))
129 (luna-define-method elmo-folder-append-buffer ((folder elmo-mark-folder)
130 unread &optional number)
131 (let* ((msgid (elmo-field-body "message-id"))
132 (path (elmo-file-cache-get-path msgid))
135 (setq dir (directory-file-name (file-name-directory path)))
136 (unless (file-exists-p dir)
137 (elmo-make-directory dir))
138 (when (file-writable-p path)
139 (write-region-as-binary (point-min) (point-max)
141 (elmo-msgdb-global-mark-set msgid
142 (elmo-mark-folder-mark-internal folder))))
144 (luna-define-method elmo-map-folder-delete-messages ((folder elmo-mark-folder)
146 (dolist (location locations)
147 (elmo-msgdb-global-mark-delete location)))
149 (luna-define-method elmo-message-fetch-with-cache-process
150 ((folder elmo-mark-folder) number strategy &optional section unseen)
151 ;; disbable cache process
152 (elmo-message-fetch-internal folder number strategy section unseen))
154 (luna-define-method elmo-map-message-fetch ((folder elmo-mark-folder)
156 &optional section unseen)
157 (let ((file (elmo-file-cache-get-path location)))
158 (when (file-exists-p file)
159 (insert-file-contents-as-binary file))))
161 (luna-define-method elmo-folder-exists-p ((folder elmo-mark-folder))
164 (luna-define-method elmo-folder-writable-p ((folder elmo-mark-folder))
167 ;;; To override elmo-map-folder methods.
168 (luna-define-method elmo-folder-list-unreads-internal
169 ((folder elmo-mark-folder) unread-marks &optional mark-alist)
172 (luna-define-method elmo-folder-unmark-important ((folder elmo-mark-folder)
176 (luna-define-method elmo-folder-mark-as-important ((folder elmo-mark-folder)
180 (luna-define-method elmo-folder-unmark-read ((folder elmo-mark-folder) numbers)
183 (luna-define-method elmo-folder-mark-as-read ((folder elmo-mark-folder) numbers)
187 (product-provide (provide 'elmo-mark) (require 'elmo-version))
189 ;;; elmo-mark.el ends here