1 ;;; mmelmo.el -- mm-backend by ELMO.
3 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
7 ;; Time-stamp: <00/03/07 17:00:43 teranisi>
9 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
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)
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.
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.
38 (defvar mmelmo-header-max-column fill-column
39 "*Inserted header is folded with this value.
40 If function is specified, its return value is used.")
42 (defvar mmelmo-header-inserted-hook nil
43 "*A hook called when header is inserted.")
45 (defvar mmelmo-entity-content-inserted-hook nil
46 "*A hook called when entity-content is inserted.")
48 (defun mmelmo-get-original-buffer ()
52 (get-buffer (concat mmelmo-entity-buffer-name "0")))
54 (set-buffer (setq ret-val
56 (concat mmelmo-entity-buffer-name "0"))))
57 (mmelmo-original-mode)
60 (defun mmelmo-cleanup-entity-buffers ()
61 "Cleanup entity buffers of mmelmo."
63 (if (string-match mmelmo-entity-buffer-name x)
65 (mapcar 'buffer-name (buffer-list))))
67 (defun mmelmo-insert-sorted-header-from-buffer (buffer
69 &optional invisible-fields
72 (let ((the-buf (current-buffer))
73 (mode-obj (mime-find-field-presentation-method 'wide))
75 f-b p f-e field-name field field-body
76 vf-alist (sl sorted-fields))
80 (narrow-to-region start end)
82 (while (re-search-forward std11-field-head-regexp nil t)
83 (setq f-b (match-beginning 0)
85 field-name (buffer-substring f-b p)
86 f-e (std11-field-end))
87 (when (mime-visible-field-p field-name
88 visible-fields invisible-fields)
90 (capitalize (buffer-substring f-b (1- p))))
91 field-body (buffer-substring p f-e)
92 field-decoder (inline (mime-find-field-decoder-internal
94 (setq vf-alist (append (list
96 (list field-body field-decoder)))
101 (function (lambda (s d)
106 (while (setq re (nth n sl))
108 (and (string-match re sf)
110 (and (string-match re df)
113 (with-current-buffer the-buf
115 (let* ((vf (car vf-alist))
116 (field-name (car vf))
117 (field-body (car (cdr vf)))
118 (field-decoder (car (cdr (cdr vf)))))
120 (insert (if field-decoder
121 (funcall field-decoder field-body
122 (string-width field-name)
123 (if (functionp mmelmo-header-max-column)
124 (funcall mmelmo-header-max-column)
125 mmelmo-header-max-column))
129 (setq vf-alist (cdr vf-alist)))
130 (run-hooks 'mmelmo-header-inserted-hook))))))
132 (defun mmelmo-original-mode ()
133 (setq major-mode 'mmelmo-original-mode)
134 (setq buffer-read-only t)
135 (elmo-set-buffer-multibyte nil)
136 (setq mode-name "MMELMO-Original"))
138 ;; For FLIMs without rfc2231 feature .
139 (if (not (fboundp 'mime-parse-parameters-from-list))
140 (defun mime-parse-parameters-from-list (attrlist)
142 (if (not (eq (% (length attrlist) 2) 0))
143 (message "Invalid attributes."))
145 (setq ret-val (append ret-val
146 (list (cons (downcase (car attrlist))
147 (downcase (car (cdr attrlist)))))))
148 (setq attrlist (cdr (cdr attrlist))))
151 (provide 'mmelmo) ; for circular dependency.
152 (static-if (fboundp 'luna-define-method)
153 ;; FLIM 1.13 or later
159 ;;; mmelmo.el ends here