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
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.
37 (defvar mmelmo-header-max-column fill-column
38 "*Inserted header is folded with this value.
39 If function is specified, its return value is used.")
41 (defvar mmelmo-header-inserted-hook nil
42 "*A hook called when header is inserted.")
44 (defvar mmelmo-entity-content-inserted-hook nil
45 "*A hook called when entity-content is inserted.")
47 (defun mmelmo-get-original-buffer ()
48 (let ((ret-val (get-buffer (concat mmelmo-entity-buffer-name "0"))))
51 (set-buffer (setq ret-val
53 (concat mmelmo-entity-buffer-name "0"))))
54 (mmelmo-original-mode)))
57 (defun mmelmo-cleanup-entity-buffers ()
58 "Cleanup entity buffers of mmelmo."
60 (if (string-match mmelmo-entity-buffer-name x)
62 (mapcar 'buffer-name (buffer-list))))
64 (defun mmelmo-insert-sorted-header-from-buffer (buffer
66 &optional invisible-fields
69 (let ((the-buf (current-buffer))
70 (mode-obj (mime-find-field-presentation-method 'wide))
72 f-b p f-e field-name field field-body
73 vf-alist (sl sorted-fields))
77 (narrow-to-region start end)
79 (while (re-search-forward std11-field-head-regexp nil t)
80 (setq f-b (match-beginning 0)
82 field-name (buffer-substring f-b p)
83 f-e (std11-field-end))
84 (when (mime-visible-field-p field-name
85 visible-fields invisible-fields)
87 (capitalize (buffer-substring f-b (1- p))))
88 field-body (buffer-substring p f-e)
89 field-decoder (inline (mime-find-field-decoder-internal
91 (setq vf-alist (append (list
93 (list field-body field-decoder)))
98 (function (lambda (s d)
103 (while (setq re (nth n sl))
105 (and (string-match re sf)
107 (and (string-match re df)
110 (with-current-buffer the-buf
112 (let* ((vf (car vf-alist))
113 (field-name (car vf))
114 (field-body (car (cdr vf)))
115 (field-decoder (car (cdr (cdr vf)))))
117 (insert (if field-decoder
118 (funcall field-decoder field-body
119 (string-width field-name)
120 (if (functionp mmelmo-header-max-column)
121 (funcall mmelmo-header-max-column)
122 mmelmo-header-max-column))
126 (setq vf-alist (cdr vf-alist)))
127 (run-hooks 'mmelmo-header-inserted-hook))))))
129 (defun mmelmo-original-mode ()
130 (setq major-mode 'mmelmo-original-mode)
131 (setq buffer-read-only t)
132 (elmo-set-buffer-multibyte nil)
133 (setq mode-name "MMELMO-Original"))
135 ;; For FLIMs without rfc2231 feature .
136 (if (not (fboundp 'mime-parse-parameters-from-list))
137 (defun mime-parse-parameters-from-list (attrlist)
139 (if (not (eq (% (length attrlist) 2) 0))
140 (message "Invalid attributes."))
142 (setq ret-val (append ret-val
143 (list (cons (downcase (car attrlist))
144 (downcase (car (cdr attrlist)))))))
145 (setq attrlist (cdr (cdr attrlist))))
148 ;;;(provide 'mmelmo) ; for circular dependency.
150 (product-provide (provide 'mmelmo) (require 'elmo-version))
152 (static-if (fboundp 'luna-define-method)
153 ;; FLIM 1.13 or later
158 ;;; mmelmo.el ends here