(wl-summary-incorporate): Enclose `wl-summary-sync-force-update'
[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 ;; Time-stamp: <00/03/06 18:35:49 teranisi>
8
9 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15 ;;
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25 ;;
26
27 ;;; Commentary:
28 ;; 
29
30 ;;; Code:
31 ;; 
32
33 (require 'mime)
34 (require 'mime-parse)
35 (eval-when-compile
36   (require 'std11))
37
38 (require 'mmelmo)
39
40 (defvar mmelmo-force-reload nil)
41 (defvar mmelmo-sort-field-list nil)
42
43 ;;; mmelmo: Only the initialization method is different from mmbuffer.
44 (mm-define-backend elmo (buffer))
45
46 (mm-define-method initialize-instance ((entity elmo))
47   (mime-entity-set-buffer-internal 
48    entity
49    (get-buffer-create (concat mmelmo-entity-buffer-name "0")))
50     (save-excursion
51       (set-buffer (mime-entity-buffer-internal entity))
52       (mmelmo-original-mode)
53       (let ((buffer-read-only nil)
54             (location (mime-entity-location-internal entity))
55             header-start header-end body-start body-end)
56         (erase-buffer)
57         (setq mime-message-structure entity)
58         (elmo-read-msg-with-buffer-cache (nth 0 location)
59                                          (nth 1 location)
60                                          (current-buffer)
61                                          (nth 2 location)
62                                          mmelmo-force-reload)
63         (setq header-start (point-min))
64         (setq body-end (point-max))
65         (goto-char header-start)
66         (if (re-search-forward 
67              (concat "^" (regexp-quote mail-header-separator) "$\\|^$" )
68              nil t)
69             (setq header-end (match-beginning 0)
70                   body-start (if (= header-end body-end)
71                                  body-end
72                                (1+ (match-end 0))))
73           (setq header-end (point-min)
74                 body-start (point-min)))
75         (save-restriction
76           (narrow-to-region header-start header-end)
77           (mime-entity-set-content-type-internal
78            entity
79            (let ((str (std11-fetch-field "Content-Type")))
80              (if str
81                  (mime-parse-Content-Type str)
82                )))
83           )
84         (mime-entity-set-header-start-internal entity header-start)
85         (mime-entity-set-header-end-internal entity header-end)
86         (mime-entity-set-body-start-internal entity body-start)
87         (mime-entity-set-body-end-internal entity body-end)
88         )))
89
90 (mm-define-method insert-header ((entity elmo)
91                                  &optional invisible-fields visible-fields)
92   (mmelmo-insert-sorted-header-from-buffer
93    (mime-entity-buffer entity)
94    (mime-entity-header-start-internal entity)
95    (mime-entity-header-end-internal entity)
96    invisible-fields visible-fields))
97
98 (mm-define-method insert-text-content ((entity elmo))
99   (insert
100    (decode-mime-charset-string (mime-entity-content entity)
101                                (or (mime-content-type-parameter
102                                     (mime-entity-content-type entity)
103                                     "charset")
104                                    default-mime-charset)
105                                'CRLF))
106   (run-hooks 'mmelmo-entity-content-inserted-hook))
107
108 (provide 'mmelmo-1)
109
110 ;;; mmelmo-1.el ends here