* elmo2.el (elmo-folder-diff-async-callback): New variable.
[elisp/wanderlust.git] / elmo / mmelmo-1.el
1 ;;; mmelmo-1.el -- mm-backend (for FLIM 1.12.x) by ELMO.
2
3 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
7
8 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
9
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)
13 ;; any later version.
14 ;;
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.
19 ;;
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.
24 ;;
25
26 ;;; Commentary:
27 ;; 
28
29 ;;; Code:
30 ;; 
31
32 (require 'mime)
33 (require 'mime-parse)
34 (eval-when-compile
35   (require 'std11))
36
37 (require 'mmelmo)
38
39 (defvar mmelmo-force-reload nil)
40 (defvar mmelmo-sort-field-list nil)
41
42 ;;; mmelmo: Only the initialization method is different from mmbuffer.
43 (mm-define-backend elmo (buffer))
44
45 (mm-define-method initialize-instance ((entity elmo))
46   (mime-entity-set-buffer-internal
47    entity
48    (get-buffer-create (concat mmelmo-entity-buffer-name "0")))
49     (save-excursion
50       (set-buffer (mime-entity-buffer-internal entity))
51       (mmelmo-original-mode)
52       (let ((buffer-read-only nil)
53             (location (mime-entity-location-internal entity))
54             header-start header-end body-start body-end)
55         (erase-buffer)
56         (setq mime-message-structure entity)
57         (elmo-read-msg-with-buffer-cache (nth 0 location)
58                                          (nth 1 location)
59                                          (current-buffer)
60                                          (nth 2 location)
61                                          mmelmo-force-reload)
62         (setq header-start (point-min))
63         (setq body-end (point-max))
64         (goto-char header-start)
65         (if (re-search-forward
66              (concat "^" (regexp-quote mail-header-separator) "$\\|^$" )
67              nil t)
68             (setq header-end (match-beginning 0)
69                   body-start (if (= header-end body-end)
70                                  body-end
71                                (1+ (match-end 0))))
72           (setq header-end (point-min)
73                 body-start (point-min)))
74         (save-restriction
75           (narrow-to-region header-start header-end)
76           (mime-entity-set-content-type-internal
77            entity
78            (let ((str (std11-fetch-field "Content-Type")))
79              (if str
80                  (mime-parse-Content-Type str)
81                )))
82           )
83         (mime-entity-set-header-start-internal entity header-start)
84         (mime-entity-set-header-end-internal entity header-end)
85         (mime-entity-set-body-start-internal entity body-start)
86         (mime-entity-set-body-end-internal entity body-end)
87         )))
88
89 (mm-define-method insert-header ((entity elmo)
90                                  &optional invisible-fields visible-fields)
91   (mmelmo-insert-sorted-header-from-buffer
92    (mime-entity-buffer entity)
93    (mime-entity-header-start-internal entity)
94    (mime-entity-header-end-internal entity)
95    invisible-fields visible-fields))
96
97 (mm-define-method insert-text-content ((entity elmo))
98   (insert
99    (decode-mime-charset-string (mime-entity-content entity)
100                                (or (mime-content-type-parameter
101                                     (mime-entity-content-type entity)
102                                     "charset")
103                                    default-mime-charset)
104                                'CRLF))
105   (run-hooks 'mmelmo-entity-content-inserted-hook))
106
107 (provide 'mmelmo-1)
108
109 ;;; mmelmo-1.el ends here