Merge remi-1_8_4.
[elisp/semi.git] / mime-play.el
1 ;;; mime-play.el --- Playback processing module for mime-view.el
2
3 ;; Copyright (C) 1994,1995,1996,1997,1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1995/9/26 (separated from tm-view.el)
7 ;;      Renamed: 1997/2/21 from tm-play.el
8 ;; Keywords: MIME, multimedia, mail, news
9
10 ;; This file is part of SEMI (Secretariat of Emacs MIME Interfaces).
11
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
16
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Code:
28
29 (require 'mime-view)
30 (require 'alist)
31 (require 'filename)
32
33 (eval-when-compile
34   (require 'mime-text)
35   (condition-case nil
36       (require 'bbdb)
37     (error (defvar bbdb-buffer-name nil)))
38   )
39
40 (defvar mime-acting-situation-example-list nil)
41
42 (defvar mime-acting-situation-example-list-max-size 16)
43
44 (defun mime-save-acting-situation-examples ()
45   (let* ((file mime-acting-situation-examples-file)
46          (buffer (get-buffer-create " *mime-example*")))
47     (unwind-protect
48         (save-excursion
49           (set-buffer buffer)
50           (setq buffer-file-name file)
51           (erase-buffer)
52           (insert ";;; " (file-name-nondirectory file) "\n")
53           (insert "\n;; This file is generated automatically by "
54                   mime-view-version-string "\n\n")
55           (insert ";;; Code:\n\n")
56           (pp `(setq mime-acting-situation-example-list
57                      ',mime-acting-situation-example-list)
58               (current-buffer))
59           (insert "\n;;; "
60                   (file-name-nondirectory file)
61                   " ends here.\n")
62           (save-buffer))
63       (kill-buffer buffer))))
64
65 (add-hook 'kill-emacs-hook 'mime-save-acting-situation-examples)
66
67 (defun mime-reduce-acting-situation-examples ()
68   (let* ((rest mime-acting-situation-example-list)
69          (min-example (car rest))
70          (min-score (cdr min-example)))
71     (while rest
72       (let* ((example (car rest))
73              (score (cdr example)))
74         (cond ((< score min-score)
75                (setq min-score score
76                      min-example example)
77                )
78               ((= score min-score)
79                (if (<= (length (car example))(length (car min-example)))
80                    (setq min-example example)
81                  ))
82               ))
83       (setq rest (cdr rest)))
84     (setq mime-acting-situation-example-list
85           (delq min-example mime-acting-situation-example-list))
86     (setq min-example (car min-example))
87     (let ((examples mime-acting-situation-example-list)
88           (max-score 0)
89           max-examples)
90       (while examples
91         (let* ((ret (mime-compare-situation-with-example min-example
92                                                          (caar examples)))
93                (ret-score (car ret)))
94           (cond ((> ret-score max-score)
95                  (setq max-score ret-score
96                        max-examples (list (cdr ret)))
97                  )
98                 ((= ret-score max-score)
99                  (setq max-examples (cons (cdr ret) max-examples))
100                  )))
101         (setq examples (cdr examples)))
102       (while max-examples
103         (let* ((example (car max-examples))
104                (cell (assoc example mime-acting-situation-example-list)))
105           (if cell
106               (setcdr cell (1+ (cdr cell)))
107             (setq mime-acting-situation-example-list
108                   (cons (cons example 0)
109                         mime-acting-situation-example-list))
110             ))
111         (setq max-examples (cdr max-examples))
112         ))))
113
114
115 ;;; @ content decoder
116 ;;;
117
118 (defvar mime-preview-after-decoded-position nil)
119
120 (defun mime-preview-play-current-entity (&optional ignore-examples mode)
121   "Play current entity.
122 It decodes current entity to call internal or external method.  The
123 method is selected from variable `mime-acting-condition'.
124 If IGNORE-EXAMPLES (C-u prefix) is specified, this function ignores
125 `mime-acting-situation-example-list'.
126 If MODE is specified, play as it.  Default MODE is \"play\"."
127   (interactive "P")
128   (let ((entity (get-text-property (point) 'mime-view-entity)))
129     (if entity
130         (let ((the-buf (current-buffer))
131               (raw-buffer (mime-entity-buffer entity)))
132           (setq mime-preview-after-decoded-position (point))
133           (set-buffer raw-buffer)
134           (mime-raw-play-entity entity (or mode "play") nil ignore-examples)
135           (when (eq (current-buffer) raw-buffer)
136             (set-buffer the-buf)
137             (goto-char mime-preview-after-decoded-position)
138             )))))
139
140 (defun mime-sort-situation (situation)
141   (sort situation
142         #'(lambda (a b)
143             (let ((a-t (car a))
144                   (b-t (car b))
145                   (order '((type . 1)
146                            (subtype . 2)
147                            (mode . 3)
148                            (method . 4)
149                            (major-mode . 5)
150                            (disposition-type . 6)
151                            ))
152                   a-order b-order)
153               (if (symbolp a-t)
154                   (let ((ret (assq a-t order)))
155                     (if ret
156                         (setq a-order (cdr ret))
157                       (setq a-order 7)
158                       ))
159                 (setq a-order 8)
160                 )
161               (if (symbolp b-t)
162                   (let ((ret (assq b-t order)))
163                     (if ret
164                         (setq b-order (cdr ret))
165                       (setq b-order 7)
166                       ))
167                 (setq b-order 8)
168                 )
169               (if (= a-order b-order)
170                   (string< (format "%s" a-t)(format "%s" b-t))
171                 (< a-order b-order))
172               )))
173   )
174
175 (defsubst mime-delq-null-situation (situations field
176                                                &optional ignored-value)
177   (let (dest)
178     (while situations
179       (let* ((situation (car situations))
180              (cell (assq field situation)))
181         (if cell
182             (or (eq (cdr cell) ignored-value)
183                 (setq dest (cons situation dest))
184                 )))
185       (setq situations (cdr situations)))
186     dest))
187
188 (defun mime-compare-situation-with-example (situation example)
189   (let ((example (copy-alist example))
190         (match 0))
191     (while situation
192       (let* ((cell (car situation))
193              (key (car cell))
194              (ecell (assoc key example)))
195         (when ecell
196           (if (equal cell ecell)
197               (setq match (1+ match))
198             (setq example (delq ecell example))
199             ))
200         )
201       (setq situation (cdr situation))
202       )
203     (cons match example)
204     ))
205
206 (defun mime-raw-play-entity (entity &optional mode situation ignore-examples
207                                     ignored-method)
208   "Play entity specified by ENTITY.
209 It decodes the entity to call internal or external method.  The method
210 is selected from variable `mime-acting-condition'.  If MODE is
211 specified, play as it.  Default MODE is \"play\"."
212   (let (method ret)
213     (or situation
214         (setq situation (mime-entity-situation entity)))
215     (if mode
216         (setq situation (cons (cons 'mode mode) situation))
217       )
218     (if ignore-examples
219         (or (assq 'ignore-examples situation)
220             (setq situation
221                   (cons (cons 'ignore-examples ignore-examples) situation)))
222       )
223     (setq ret
224           (mime-delq-null-situation
225            (ctree-find-calist mime-acting-condition situation
226                               mime-view-find-every-acting-situation)
227            'method ignored-method))
228     (or ignore-examples
229         (if (cdr ret)
230             (let ((rest ret)
231                   (max-score 0)
232                   max-escore
233                   max-examples
234                   max-situations)
235               (while rest
236                 (let ((situation (car rest))
237                       (examples mime-acting-situation-example-list))
238                   (while examples
239                     (let* ((ret
240                             (mime-compare-situation-with-example
241                              situation (caar examples)))
242                            (ret-score (car ret)))
243                       (cond ((> ret-score max-score)
244                              (setq max-score ret-score
245                                    max-escore (cdar examples)
246                                    max-examples (list (cdr ret))
247                                    max-situations (list situation))
248                              )
249                             ((= ret-score max-score)
250                              (cond ((> (cdar examples) max-escore)
251                                     (setq max-escore (cdar examples)
252                                           max-examples (list (cdr ret))
253                                           max-situations (list situation))
254                                     )
255                                    ((= (cdar examples) max-escore)
256                                     (setq max-examples
257                                           (cons (cdr ret) max-examples))
258                                     (or (member situation max-situations)
259                                         (setq max-situations
260                                               (cons situation max-situations)))
261                                     )))))
262                     (setq examples (cdr examples))))
263                 (setq rest (cdr rest)))
264               (when max-situations
265                 (setq ret max-situations)
266                 (while max-examples
267                   (let* ((example (car max-examples))
268                          (cell
269                           (assoc example mime-acting-situation-example-list)))
270                     (if cell
271                         (setcdr cell (1+ (cdr cell)))
272                       (setq mime-acting-situation-example-list
273                             (cons (cons example 0)
274                                   mime-acting-situation-example-list))
275                       ))
276                   (setq max-examples (cdr max-examples))
277                   )))))
278     (cond ((cdr ret)
279            (setq ret (select-menu-alist
280                       "Methods"
281                       (mapcar (function
282                                (lambda (situation)
283                                  (cons
284                                   (format "%s"
285                                           (cdr (assq 'method situation)))
286                                   situation)))
287                               ret)))
288            (setq ret (mime-sort-situation ret))
289            (add-to-list 'mime-acting-situation-example-list (cons ret 0))
290            )
291           (t
292            (setq ret (car ret))
293            ))
294     (setq method (cdr (assq 'method ret)))
295     (cond ((and (symbolp method)
296                 (fboundp method))
297            (funcall method entity ret)
298            )
299           ((stringp method)
300            (mime-activate-mailcap-method entity ret)
301            )
302           ;; ((and (listp method)(stringp (car method)))
303           ;;  (mime-activate-external-method entity ret)
304           ;;  )
305           (t
306            (mime-show-echo-buffer "No method are specified for %s\n"
307                                   (mime-entity-type/subtype entity))
308            ))
309     ))
310
311
312 ;;; @ external decoder
313 ;;;
314
315 (defvar mime-mailcap-method-filename-alist nil)
316
317 (defun mime-activate-mailcap-method (entity situation)
318   (save-excursion
319     (save-restriction
320       (let ((start (mime-entity-point-min entity))
321             (end (mime-entity-point-max entity)))
322         (narrow-to-region start end)
323         (goto-char start)
324         (let ((method (cdr (assoc 'method situation)))
325               (name (mime-entity-safe-filename entity)))
326           (setq name
327                 (if (and name (not (string= name "")))
328                     (expand-file-name name mime-temp-directory)
329                   (make-temp-name
330                    (expand-file-name "EMI" mime-temp-directory))
331                   ))
332           (mime-write-entity-content entity name)
333           (message "External method is starting...")
334           (let ((process
335                  (let ((command
336                         (mailcap-format-command
337                          method
338                          (cons (cons 'filename name) situation))))
339                    (start-process command mime-echo-buffer-name
340                                   shell-file-name shell-command-switch command)
341                    )))
342             (set-alist 'mime-mailcap-method-filename-alist process name)
343             (set-process-sentinel process 'mime-mailcap-method-sentinel)
344             )
345           )))))
346
347 (defun mime-mailcap-method-sentinel (process event)
348   (let ((file (cdr (assq process mime-mailcap-method-filename-alist))))
349     (if (file-exists-p file)
350         (delete-file file)
351       ))
352   (remove-alist 'mime-mailcap-method-filename-alist process)
353   (message (format "%s %s" process event)))
354
355 (defvar mime-echo-window-is-shared-with-bbdb t
356   "*If non-nil, mime-echo window is shared with BBDB window.")
357
358 (defvar mime-echo-window-height
359   (function
360    (lambda ()
361      (/ (window-height) 5)
362      ))
363   "*Size of mime-echo window.
364 It allows function or integer.  If it is function,
365 `mime-show-echo-buffer' calls it to get height of mime-echo window.
366 Otherwise `mime-show-echo-buffer' uses it as height of mime-echo
367 window.")
368
369 (defun mime-show-echo-buffer (&rest forms)
370   "Show mime-echo buffer to display MIME-playing information."
371   (get-buffer-create mime-echo-buffer-name)
372   (let ((the-win (selected-window))
373         (win (get-buffer-window mime-echo-buffer-name))
374         )
375     (or win
376         (if (and mime-echo-window-is-shared-with-bbdb
377                  (boundp 'bbdb-buffer-name)
378                  (setq win (get-buffer-window bbdb-buffer-name))
379                  )
380             (set-window-buffer win mime-echo-buffer-name)
381           (select-window (get-buffer-window mime-preview-buffer))
382           (setq win (split-window-vertically
383                      (- (window-height)
384                         (if (functionp mime-echo-window-height)
385                             (funcall mime-echo-window-height)
386                           mime-echo-window-height)
387                         )))
388           (set-window-buffer win mime-echo-buffer-name)
389           ))
390     (select-window win)
391     (goto-char (point-max))
392     (if forms
393         (insert (apply (function format) forms))
394       )
395     (select-window the-win)
396     ))
397
398
399 ;;; @ file name
400 ;;;
401
402 (defvar mime-view-file-name-char-regexp "[A-Za-z0-9+_-]")
403
404 (defvar mime-view-file-name-regexp-1
405   (concat mime-view-file-name-char-regexp "+\\."
406           mime-view-file-name-char-regexp "+"))
407
408 (defvar mime-view-file-name-regexp-2
409   (concat (regexp-* mime-view-file-name-char-regexp)
410           "\\(\\." mime-view-file-name-char-regexp "+\\)*"))
411
412 (defun mime-entity-safe-filename (entity)
413   (let ((filename
414          (or (mime-entity-filename entity)
415              (let ((subj
416                     (or (mime-read-field 'Content-Description entity)
417                         (mime-read-field 'Subject entity))))
418                (if (and subj
419                         (or (string-match mime-view-file-name-regexp-1 subj)
420                             (string-match mime-view-file-name-regexp-2 subj)))
421                    (substring subj (match-beginning 0)(match-end 0))
422                  )))))
423     (if filename
424         (replace-as-filename filename)
425       )))
426
427
428 ;;; @ file extraction
429 ;;;
430
431 (defun mime-save-content (entity situation)
432   (let* ((name (mime-entity-safe-filename entity))
433          (filename (if (and name (not (string-equal name "")))
434                        (expand-file-name name
435                                          (save-window-excursion
436                                            (call-interactively
437                                             (function
438                                              (lambda (dir)
439                                                (interactive "DDirectory: ")
440                                                dir)))))
441                      (save-window-excursion
442                        (call-interactively
443                         (function
444                          (lambda (file)
445                            (interactive "FFilename: ")
446                            (expand-file-name file)))))))
447          )
448     (if (file-exists-p filename)
449         (or (yes-or-no-p (format "File %s exists. Save anyway? " filename))
450             (error "")))
451     (mime-write-entity-content entity filename)
452     ))
453
454
455 ;;; @ file detection
456 ;;;
457
458 (defvar mime-file-content-type-alist
459   '(("JPEG"             image jpeg)
460     ("GIF"              image gif)
461     ("Standard MIDI"    audio midi)
462     )
463   "*Alist of \"file\" output patterns vs. corresponding media-types.
464 Each element looks like (REGEXP TYPE SUBTYPE).
465 REGEXP is pattern for \"file\" command output.
466 TYPE is symbol to indicate primary type of media-type.
467 SUBTYPE is symbol to indicate subtype of media-type.")
468
469 (defun mime-detect-content (entity situation)
470   (let ((beg (mime-entity-point-min entity))
471         (end (mime-entity-point-max entity)))
472     (goto-char beg)
473     (let* ((name (save-restriction
474                    (narrow-to-region beg end)
475                    (mime-entity-safe-filename entity)
476                    ))
477            (encoding (or (cdr (assq 'encoding situation)) "7bit"))
478            (filename (if (and name (not (string-equal name "")))
479                          (expand-file-name name mime-temp-directory)
480                        (make-temp-name
481                         (expand-file-name "EMI" mime-temp-directory)))))
482       (mime-write-decoded-region (mime-entity-body-start entity) end
483                                  filename encoding)
484       (let (type subtype)
485         (with-temp-buffer
486           (call-process "file" nil t nil filename)
487           (goto-char (point-min))
488           (if (search-forward (concat filename ": ") nil t)
489               (let ((rest mime-file-content-type-alist))
490                 (while (not (let ((cell (car rest)))
491                               (if cell
492                                   (if (looking-at (car cell))
493                                       (setq type (nth 1 cell)
494                                             subtype (nth 2 cell))
495                                     )
496                                 t)))
497                   (setq rest (cdr rest))))))
498         (if type
499             (mime-raw-play-entity
500              entity nil
501              (put-alist 'type type
502                         (put-alist 'subtype subtype
503                                    (del-alist 'method
504                                               (copy-alist situation))))
505              (cdr (assq 'ignore-examples situation))
506              'mime-detect-content)
507           ))
508       )))
509
510
511 ;;; @ mail/news message
512 ;;;
513
514 (defun mime-preview-quitting-method-for-mime-show-message-mode ()
515   "Quitting method for mime-view.
516 It is registered to variable `mime-preview-quitting-method-alist'."
517   (let ((mother mime-mother-buffer)
518         (win-conf mime-preview-original-window-configuration)
519         )
520     (kill-buffer mime-raw-buffer)
521     (mime-preview-kill-buffer)
522     (set-window-configuration win-conf)
523     (pop-to-buffer mother)
524     ))
525
526 (defun mime-view-message/rfc822 (entity situation)
527   (let* ((new-name
528           (format "%s-%s" (buffer-name) (mime-entity-number entity)))
529          (mother mime-preview-buffer)
530          (children (car (mime-entity-children entity))))
531     (set-buffer (get-buffer-create new-name))
532     (erase-buffer)
533     (insert-buffer-substring (mime-entity-buffer children)
534                              (mime-entity-point-min children)
535                              (mime-entity-point-max children))
536     (setq mime-message-structure children)
537     (setq major-mode 'mime-show-message-mode)
538     (mime-view-buffer (current-buffer) nil mother
539                       nil (if (mime-entity-cooked-p entity) 'cooked))
540     ))
541
542
543 ;;; @ message/partial
544 ;;;
545
546 (defun mime-store-message/partial-piece (entity cal)
547   (goto-char (mime-entity-point-min entity))
548   (let* ((root-dir
549           (expand-file-name
550            (concat "m-prts-" (user-login-name)) mime-temp-directory))
551          (id (cdr (assoc "id" cal)))
552          (number (cdr (assoc "number" cal)))
553          (total (cdr (assoc "total" cal)))
554          file
555          (mother mime-preview-buffer)
556          )
557     (or (file-exists-p root-dir)
558         (make-directory root-dir)
559         )
560     (setq id (replace-as-filename id))
561     (setq root-dir (concat root-dir "/" id))
562     (or (file-exists-p root-dir)
563         (make-directory root-dir)
564         )
565     (setq file (concat root-dir "/FULL"))
566     (if (file-exists-p file)
567         (let ((full-buf (get-buffer-create "FULL"))
568               (pwin (or (get-buffer-window mother)
569                         (get-largest-window)))
570               )
571           (save-window-excursion
572             (set-buffer full-buf)
573             (erase-buffer)
574             (as-binary-input-file (insert-file-contents file))
575             (setq major-mode 'mime-show-message-mode)
576             (mime-view-buffer (current-buffer) nil mother)
577             )
578           (set-window-buffer pwin
579                              (save-excursion
580                                (set-buffer full-buf)
581                                mime-preview-buffer))
582           (select-window pwin)
583           )
584       (setq file (concat root-dir "/" number))
585       (mime-write-entity-body entity file)
586       (let ((total-file (concat root-dir "/CT")))
587         (setq total
588               (if total
589                   (progn
590                     (or (file-exists-p total-file)
591                         (save-excursion
592                           (set-buffer
593                            (get-buffer-create mime-temp-buffer-name))
594                           (erase-buffer)
595                           (insert total)
596                           (write-region (point-min)(point-max) total-file)
597                           (kill-buffer (current-buffer))
598                           ))
599                     (string-to-number total)
600                     )
601                 (and (file-exists-p total-file)
602                      (save-excursion
603                        (set-buffer (find-file-noselect total-file))
604                        (prog1
605                            (and (re-search-forward "[0-9]+" nil t)
606                                 (string-to-number
607                                  (buffer-substring (match-beginning 0)
608                                                    (match-end 0)))
609                                 )
610                          (kill-buffer (current-buffer))
611                          )))
612                 )))
613       (if (and total (> total 0))
614           (catch 'tag
615             (save-excursion
616               (set-buffer (get-buffer-create mime-temp-buffer-name))
617               (let ((full-buf (current-buffer)))
618                 (erase-buffer)
619                 (let ((i 1))
620                   (while (<= i total)
621                     (setq file (concat root-dir "/" (int-to-string i)))
622                     (or (file-exists-p file)
623                         (throw 'tag nil)
624                         )
625                     (as-binary-input-file (insert-file-contents file))
626                     (goto-char (point-max))
627                     (setq i (1+ i))
628                     ))
629                 (as-binary-output-file
630                  (write-region (point-min)(point-max)
631                                (expand-file-name "FULL" root-dir)))
632                 (let ((i 1))
633                   (while (<= i total)
634                     (let ((file (format "%s/%d" root-dir i)))
635                       (and (file-exists-p file)
636                            (delete-file file)
637                            ))
638                     (setq i (1+ i))
639                     ))
640                 (let ((file (expand-file-name "CT" root-dir)))
641                   (and (file-exists-p file)
642                        (delete-file file)
643                        ))
644                 (save-window-excursion
645                   (setq major-mode 'mime-show-message-mode)
646                   (mime-view-buffer (current-buffer) nil mother)
647                   )
648                 (let ((pwin (or (get-buffer-window mother)
649                                 (get-largest-window)))
650                       (pbuf (save-excursion
651                               (set-buffer full-buf)
652                               mime-preview-buffer)))
653                   (set-window-buffer pwin pbuf)
654                   (select-window pwin)
655                   )))))
656       )))
657
658
659 ;;; @ message/external-body
660 ;;;
661
662 (defvar mime-raw-dired-function
663   (if (and (>= emacs-major-version 19) window-system)
664       (function dired-other-frame)
665     (function mime-raw-dired-function-for-one-frame)
666     ))
667
668 (defun mime-raw-dired-function-for-one-frame (dir)
669   (let ((win (or (get-buffer-window mime-preview-buffer)
670                  (get-largest-window))))
671     (select-window win)
672     (dired dir)
673     ))
674
675 (defun mime-view-message/external-anon-ftp (entity cal)
676   (let* ((site (cdr (assoc "site" cal)))
677          (directory (cdr (assoc "directory" cal)))
678          (name (cdr (assoc "name" cal)))
679          (pathname (concat "/anonymous@" site ":" directory)))
680     (message (concat "Accessing " (expand-file-name name pathname) " ..."))
681     (funcall mime-raw-dired-function pathname)
682     (goto-char (point-min))
683     (search-forward name)
684     ))
685
686 (defvar mime-raw-browse-url-function (function mime-browse-url))
687
688 (defun mime-view-message/external-url (entity cal)
689   (let ((url (cdr (assoc "url" cal))))
690     (message (concat "Accessing " url " ..."))
691     (funcall mime-raw-browse-url-function url)))
692
693
694 ;;; @ rot13-47
695 ;;;
696
697 (defun mime-view-caesar (entity situation)
698   "Internal method for mime-view to display ROT13-47-48 message."
699   (let* ((new-name (format "%s-%s" (buffer-name)
700                            (mime-entity-number entity)))
701          (mother mime-preview-buffer))
702     (let ((pwin (or (get-buffer-window mother)
703                     (get-largest-window)))
704           (buf (get-buffer-create new-name)))
705       (set-window-buffer pwin buf)
706       (set-buffer buf)
707       (select-window pwin)
708       )
709     (setq buffer-read-only nil)
710     (erase-buffer)
711     (mime-text-insert-decoded-body entity)
712     (mule-caesar-region (point-min) (point-max))
713     (set-buffer-modified-p nil)
714     (set-buffer mother)
715     (view-buffer new-name)
716     ))
717
718
719 ;;; @ end
720 ;;;
721
722 (provide 'mime-play)
723
724 (let* ((file mime-acting-situation-examples-file)
725        (buffer (get-buffer-create " *mime-example*")))
726   (if (file-readable-p file)
727       (unwind-protect
728           (save-excursion
729             (set-buffer buffer)
730             (erase-buffer)
731             (insert-file-contents file)
732             (eval-buffer)
733             ;; format check
734             (condition-case nil
735                 (let ((i 0))
736                   (while (and (> (length mime-acting-situation-example-list)
737                                  mime-acting-situation-example-list-max-size)
738                               (< i 16))
739                     (mime-reduce-acting-situation-examples)
740                     (setq i (1+ i))
741                     ))
742               (error (setq mime-acting-situation-example-list nil)))
743             )
744         (kill-buffer buffer))))
745
746 ;;; mime-play.el ends here