(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)
(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
(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