(mime-view-read-situation-examples-file): New function; don't occur
authortomo <tomo>
Wed, 27 Dec 2000 11:52:40 +0000 (11:52 +0000)
committertomo <tomo>
Wed, 27 Dec 2000 11:52:40 +0000 (11:52 +0000)
error.
(mime-view-read-mailcap): New function.

mime-view.el

index 888f4d7..8fb0a95 100644 (file)
@@ -360,6 +360,52 @@ mother-buffer."
 (defvar mime-acting-situation-example-list-max-size 16)
 (defvar mime-situation-examples-file-coding-system nil)
 
+(defun mime-view-read-situation-examples-file (&optional file)
+  (or file
+      (setq file mime-situation-examples-file))
+  (if (file-readable-p file)
+      (with-temp-buffer
+       (insert-file-contents file)
+       (setq mime-situation-examples-file-coding-system
+              (and (boundp 'buffer-file-coding-system)
+                  buffer-file-coding-system)
+             ;; (static-cond
+              ;;  ((boundp 'buffer-file-coding-system)
+              ;;   (symbol-value 'buffer-file-coding-system))
+              ;;  ((boundp 'file-coding-system)
+              ;;   (symbol-value 'file-coding-system))
+              ;;  (t nil))
+             )
+       (condition-case nil
+           (eval-buffer)
+         (error nil))
+       ;; format check
+       (condition-case nil
+           (let ((i 0))
+             (while (and (> (length mime-preview-situation-example-list)
+                            mime-preview-situation-example-list-max-size)
+                         (< i 16))
+               (setq mime-preview-situation-example-list
+                     (mime-reduce-situation-examples
+                      mime-preview-situation-example-list))
+               (setq i (1+ i))))
+         (error (setq mime-preview-situation-example-list nil)))
+       ;; (let ((rest mime-preview-situation-example-list))
+       ;;   (while rest
+       ;;     (ctree-set-calist-strictly 'mime-preview-condition
+       ;;                                (caar rest))
+       ;;     (setq rest (cdr rest))))
+       (condition-case nil
+           (let ((i 0))
+             (while (and (> (length mime-acting-situation-example-list)
+                            mime-acting-situation-example-list-max-size)
+                         (< i 16))
+               (setq mime-acting-situation-example-list
+                     (mime-reduce-situation-examples
+                      mime-acting-situation-example-list))
+               (setq i (1+ i))))
+         (error (setq mime-acting-situation-example-list nil))))))
+
 (defun mime-save-situation-examples ()
   (if (or mime-preview-situation-example-list
          mime-acting-situation-example-list)
@@ -871,34 +917,33 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
 (defvar mime-acting-condition nil
   "Condition-tree about how to process entity.")
 
-(if (file-readable-p mime-mailcap-file)
-    (let ((entries (mime-parse-mailcap-file)))
-      (while entries
-       (let ((entry (car entries))
-             view print shared)
-         (while entry
-           (let* ((field (car entry))
-                  (field-type (car field)))
-             (cond ((eq field-type 'view)  (setq view field))
-                   ((eq field-type 'print) (setq print field))
-                   ((memq field-type '(compose composetyped edit)))
-                   (t (setq shared (cons field shared))))
-             )
-           (setq entry (cdr entry))
-           )
-         (setq shared (nreverse shared))
-         (ctree-set-calist-with-default
-          'mime-acting-condition
-          (append shared (list '(mode . "play")(cons 'method (cdr view)))))
-         (if print
-             (ctree-set-calist-with-default
-              'mime-acting-condition
-              (append shared
-                      (list '(mode . "print")(cons 'method (cdr view))))
-              ))
-         )
-       (setq entries (cdr entries))
-       )))
+(defun mime-view-read-mailcap ()
+  (if (file-readable-p mime-mailcap-file)
+      (let ((entries (mime-parse-mailcap-file)))
+       (while entries
+         (let ((entry (car entries))
+               view print shared)
+           (while entry
+             (let* ((field (car entry))
+                    (field-type (car field)))
+               (cond ((eq field-type 'view)  (setq view field))
+                     ((eq field-type 'print) (setq print field))
+                     ((memq field-type '(compose composetyped edit)))
+                     (t (setq shared (cons field shared))))
+               )
+             (setq entry (cdr entry)))
+           (setq shared (nreverse shared))
+           (ctree-set-calist-with-default
+            'mime-acting-condition
+            (append shared (list '(mode . "play")(cons 'method (cdr view)))))
+           (if print
+               (ctree-set-calist-with-default
+                'mime-acting-condition
+                (append shared
+                        (list '(mode . "print")(cons 'method (cdr view)))))))
+         (setq entries (cdr entries))))))
+
+(mime-view-read-mailcap)
 
 (ctree-set-calist-strictly
  'mime-acting-condition
@@ -1796,46 +1841,6 @@ It calls function registered in variable
 
 (provide 'mime-view)
 
-(let ((file mime-situation-examples-file))
-  (if (file-readable-p file)
-      (with-temp-buffer
-       (insert-file-contents file)
-       (setq mime-situation-examples-file-coding-system
-              (and (boundp 'buffer-file-coding-system)
-                  buffer-file-coding-system)
-             ;; (static-cond
-              ;;  ((boundp 'buffer-file-coding-system)
-              ;;   (symbol-value 'buffer-file-coding-system))
-              ;;  ((boundp 'file-coding-system)
-              ;;   (symbol-value 'file-coding-system))
-              ;;  (t nil))
-             )
-       (eval-buffer)
-       ;; format check
-       (condition-case nil
-           (let ((i 0))
-             (while (and (> (length mime-preview-situation-example-list)
-                            mime-preview-situation-example-list-max-size)
-                         (< i 16))
-               (setq mime-preview-situation-example-list
-                     (mime-reduce-situation-examples
-                      mime-preview-situation-example-list))
-               (setq i (1+ i))))
-         (error (setq mime-preview-situation-example-list nil)))
-       ;; (let ((rest mime-preview-situation-example-list))
-       ;;   (while rest
-       ;;     (ctree-set-calist-strictly 'mime-preview-condition
-       ;;                                (caar rest))
-       ;;     (setq rest (cdr rest))))
-       (condition-case nil
-           (let ((i 0))
-             (while (and (> (length mime-acting-situation-example-list)
-                            mime-acting-situation-example-list-max-size)
-                         (< i 16))
-               (setq mime-acting-situation-example-list
-                     (mime-reduce-situation-examples
-                      mime-acting-situation-example-list))
-               (setq i (1+ i))))
-         (error (setq mime-acting-situation-example-list nil))))))
+(mime-view-read-situation-examples-file)
 
 ;;; mime-view.el ends here