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 (elmo-mark-folder-msgdb-create folder numbers))
90 (defun elmo-mark-folder-msgdb-create (folder numbers)
92 (len (length numbers))
93 overview number-alist mark-alist entity message-id
95 (message "Creating msgdb...")
98 (elmo-msgdb-create-overview-entity-from-file
99 (car numbers) (elmo-message-file-name folder (car numbers))))
102 (setq num (elmo-msgdb-overview-entity-get-number entity))
104 (elmo-msgdb-append-element
106 (setq message-id (elmo-msgdb-overview-entity-get-id entity))
108 (elmo-msgdb-number-add number-alist
112 (elmo-msgdb-mark-append
114 num (elmo-mark-folder-mark-internal folder))))
115 (when (> len elmo-display-progress-threshold)
117 (elmo-display-progress
118 'elmo-mark-folder-msgdb-create "Creating msgdb..."
120 (setq numbers (cdr numbers)))
121 (message "Creating msgdb...done")
122 (list overview number-alist mark-alist)))
124 (luna-define-method elmo-folder-append-buffer ((folder elmo-mark-folder)
125 unread &optional number)
126 (let* ((msgid (elmo-field-body "message-id"))
127 (path (elmo-file-cache-get-path msgid))
130 (setq dir (directory-file-name (file-name-directory path)))
131 (unless (file-exists-p dir)
132 (elmo-make-directory dir))
133 (when (file-writable-p path)
134 (write-region-as-binary (point-min) (point-max)
136 (elmo-msgdb-global-mark-set msgid
137 (elmo-mark-folder-mark-internal folder))))
139 (luna-define-method elmo-map-folder-delete-messages ((folder elmo-mark-folder)
141 (dolist (location locations)
142 (elmo-msgdb-global-mark-delete location)))
144 (luna-define-method elmo-message-fetch-with-cache-process
145 ((folder elmo-mark-folder) number strategy &optional section unseen)
146 ;; disbable cache process
147 (elmo-message-fetch-internal folder number strategy section unseen))
149 (luna-define-method elmo-map-message-fetch ((folder elmo-mark-folder)
151 &optional section unseen)
152 (let ((file (elmo-file-cache-get-path location)))
153 (when (file-exists-p file)
154 (insert-file-contents-as-binary file))))
156 (luna-define-method elmo-folder-exists-p ((folder elmo-mark-folder))
159 (luna-define-method elmo-folder-writable-p ((folder elmo-mark-folder))
163 (product-provide (provide 'elmo-mark) (require 'elmo-version))
165 ;;; elmo-mark.el ends here