Add description about
[elisp/semi.git] / mime-view.el
index a2531e6..519d475 100644 (file)
   :type 'file)
 
 
-;;; @ buffer local variables
-;;;
-
-;;; @@ in raw-buffer
+;;; @ in raw-buffer (representation space)
 ;;;
 
 (defvar mime-raw-message-info nil
@@ -121,27 +118,6 @@ This value is overridden by buffer local variable
 `mime-raw-representation-type' if it is not nil.")
 
 
-;;; @@ in preview-buffer
-;;;
-
-(defvar mime-mother-buffer nil
-  "Mother buffer corresponding with the (MIME-preview) buffer.
-If current MIME-preview buffer is generated by other buffer, such as
-message/partial, it is called `mother-buffer'.")
-(make-variable-buffer-local 'mime-mother-buffer)
-
-(defvar mime-raw-buffer nil
-  "Raw buffer corresponding with the (MIME-preview) buffer.")
-(make-variable-buffer-local 'mime-raw-buffer)
-
-(defvar mime-preview-original-window-configuration nil
-  "Window-configuration before mime-view-mode is called.")
-(make-variable-buffer-local 'mime-preview-original-window-configuration)
-
-
-;;; @ entity information
-;;;
-
 (defsubst mime-raw-find-entity-from-node-id (entity-node-id
                                             &optional message-info)
   "Return entity from ENTITY-NODE-ID in mime-raw-buffer.
@@ -186,6 +162,43 @@ If optional argument MESSAGE-INFO is not specified,
          message-info))))
 
 
+;;; @ in preview-buffer (presentation space)
+;;;
+
+(defvar mime-mother-buffer nil
+  "Mother buffer corresponding with the (MIME-preview) buffer.
+If current MIME-preview buffer is generated by other buffer, such as
+message/partial, it is called `mother-buffer'.")
+(make-variable-buffer-local 'mime-mother-buffer)
+
+(defvar mime-raw-buffer nil
+  "Raw buffer corresponding with the (MIME-preview) buffer.")
+(make-variable-buffer-local 'mime-raw-buffer)
+
+(defvar mime-preview-original-window-configuration nil
+  "Window-configuration before mime-view-mode is called.")
+(make-variable-buffer-local 'mime-preview-original-window-configuration)
+
+(defun mime-preview-original-major-mode (&optional recursive)
+  "Return major-mode of original buffer.
+If optional argument RECURSIVE is non-nil and current buffer has
+mime-mother-buffer, it returns original major-mode of the
+mother-buffer."
+  (if (and recursive mime-mother-buffer)
+      (save-excursion
+       (set-buffer mime-mother-buffer)
+       (mime-preview-original-major-mode recursive)
+       )
+    (save-excursion
+      (set-buffer
+       (mime-entity-buffer
+       (get-text-property (point-min) 'mime-view-entity)))
+      major-mode)))
+
+
+;;; @ entity information
+;;;
+
 (defsubst mime-entity-parent (entity &optional message-info)
   "Return mother entity of ENTITY.
 If optional argument MESSAGE-INFO is not specified,
@@ -197,10 +210,30 @@ If optional argument MESSAGE-INFO is not specified,
         (set-buffer (mime-entity-buffer entity))
         mime-raw-message-info))))
 
-(defsubst mime-entity-situation (entity)
+(defun mime-entity-situation (entity)
   "Return situation of ENTITY."
   (append (or (mime-entity-content-type entity)
              (make-mime-content-type 'text 'plain))
+         (let ((d (mime-entity-content-disposition entity)))
+           (cons (cons 'disposition-type
+                       (mime-content-disposition-type d))
+                 (mapcar (function
+                          (lambda (param)
+                            (let ((name (car param)))
+                              (cons (cond ((string= name "filename")
+                                           'filename)
+                                          ((string= name "creation-date")
+                                           'creation-date)
+                                          ((string= name "modification-date")
+                                           'modification-date)
+                                          ((string= name "read-date")
+                                           'read-date)
+                                          ((string= name "size")
+                                           'size)
+                                          (t (cons 'disposition (car param))))
+                                    (cdr param)))))
+                         (mime-content-disposition-parameters d))
+                 ))
          (list (cons 'encoding (mime-entity-encoding entity))
                (cons 'major-mode
                      (save-excursion
@@ -668,30 +701,18 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
        (setq entries (cdr entries))
        )))
 
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . t)(subtype . t)(mode . "extract")
-;;    (method . mime-method-to-save)))
+(ctree-set-calist-strictly
+ 'mime-acting-condition
+ '((type . application)(subtype . octet-stream)
+   (mode . "play")
+   (method . mime-method-to-detect)
+   ))
+
 (ctree-set-calist-with-default
  'mime-acting-condition
  '((mode . "extract")
    (method . mime-method-to-save)))
 
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . text)(subtype . plain)(mode . "play")
-;;    (method "tm-plain" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . text)(subtype . plain)(mode . "print")
-;;    (method "tm-plain" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . text)(subtype . html)(mode . "play")
-;;    (method "tm-html" nil 'file "" 'encoding 'mode 'name)
-;;    ))
 (ctree-set-calist-strictly
  'mime-acting-condition
  '((type . text)(subtype . x-rot13-47)(mode . "play")
@@ -703,40 +724,6 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
    (method . mime-method-to-display-caesar)
    ))
 
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . audio)(subtype . basic)(mode . "play")
-;;    (method "tm-au" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . image)(mode . "play")
-;;    (method "tm-image" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . image)(mode . "print")
-;;    (method "tm-image" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . video)(subtype . mpeg)(mode . "play")
-;;    (method "tm-mpeg" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . application)(subtype . postscript)(mode . "play")
-;;    (method "tm-ps" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-;; (ctree-set-calist-strictly
-;;  'mime-acting-condition
-;;  '((type . application)(subtype . postscript)(mode . "print")
-;;    (method "tm-ps" nil 'file "" 'encoding 'mode 'name)
-;;    ))
-
 (ctree-set-calist-strictly
  'mime-acting-condition
  '((type . message)(subtype . rfc822)(mode . "play")
@@ -770,11 +757,11 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
      . mime-preview-quitting-method-for-mime-show-message-mode))
   "Alist of major-mode vs. quitting-method of mime-view.")
 
-(defvar mime-view-over-to-previous-method-alist nil)
-(defvar mime-view-over-to-next-method-alist nil)
+(defvar mime-preview-over-to-previous-method-alist nil
+  "Alist of major-mode vs. over-to-previous-method of mime-view.")
 
-(defvar mime-view-show-summary-method nil
-  "Alist of major-mode vs. show-summary-method.")
+(defvar mime-preview-over-to-next-method-alist nil
+  "Alist of major-mode vs. over-to-next-method of mime-view.")
 
 
 ;;; @ following method
@@ -981,8 +968,6 @@ The compressed face will be piped to this command.")
     (define-key mime-view-mode-map
       "q"        (function mime-preview-quit))
     (define-key mime-view-mode-map
-      "h"        (function mime-preview-show-summary))
-    (define-key mime-view-mode-map
       "\C-c\C-x" (function mime-preview-kill-buffer))
     ;; (define-key mime-view-mode-map
     ;;   "<"        (function beginning-of-buffer))
@@ -1161,21 +1146,6 @@ It decodes current entity to call internal or external method as
 ;;; @@ following
 ;;;
 
-(defun mime-preview-original-major-mode (&optional recursive)
-  "Return major-mode of original buffer.
-If a current buffer has mime-mother-buffer, return original major-mode
-of the mother-buffer."
-  (if (and recursive mime-mother-buffer)
-      (save-excursion
-       (set-buffer mime-mother-buffer)
-       (mime-preview-original-major-mode recursive)
-       )
-    (save-excursion
-      (set-buffer
-       (mime-entity-buffer
-       (get-text-property (point-min) 'mime-view-entity)))
-      major-mode)))
-
 (defun mime-preview-follow-current-entity ()
   "Write follow message to current entity.
 It calls following-method selected from variable
@@ -1346,7 +1316,7 @@ If there is no upper entity, call function `mime-preview-quit'."
 (defun mime-preview-move-to-previous ()
   "Move to previous entity.
 If there is no previous entity, it calls function registered in
-variable `mime-view-over-to-previous-method-alist'."
+variable `mime-preview-over-to-previous-method-alist'."
   (interactive)
   (while (null (get-text-property (point) 'mime-view-entity))
     (backward-char)
@@ -1359,7 +1329,7 @@ variable `mime-view-over-to-previous-method-alist'."
          (mime-preview-move-to-previous)
          )
       (let ((f (assq (mime-preview-original-major-mode)
-                    mime-view-over-to-previous-method-alist)))
+                    mime-preview-over-to-previous-method-alist)))
        (if f
            (funcall (cdr f))
          ))
@@ -1368,7 +1338,7 @@ variable `mime-view-over-to-previous-method-alist'."
 (defun mime-preview-move-to-next ()
   "Move to next entity.
 If there is no previous entity, it calls function registered in
-variable `mime-view-over-to-next-method-alist'."
+variable `mime-preview-over-to-next-method-alist'."
   (interactive)
   (while (null (get-text-property (point) 'mime-view-entity))
     (forward-char)
@@ -1381,7 +1351,7 @@ variable `mime-view-over-to-next-method-alist'."
              (mime-preview-move-to-next)
            ))
       (let ((f (assq (mime-preview-original-major-mode)
-                    mime-view-over-to-next-method-alist)))
+                    mime-preview-over-to-next-method-alist)))
        (if f
            (funcall (cdr f))
          ))
@@ -1390,14 +1360,14 @@ variable `mime-view-over-to-next-method-alist'."
 (defun mime-preview-scroll-up-entity (&optional h)
   "Scroll up current entity.
 If reached to (point-max), it calls function registered in variable
-`mime-view-over-to-next-method-alist'."
+`mime-preview-over-to-next-method-alist'."
   (interactive)
   (or h
       (setq h (1- (window-height)))
       )
   (if (= (point) (point-max))
       (let ((f (assq (mime-preview-original-major-mode)
-                     mime-view-over-to-next-method-alist)))
+                     mime-preview-over-to-next-method-alist)))
         (if f
             (funcall (cdr f))
           ))
@@ -1413,14 +1383,14 @@ If reached to (point-max), it calls function registered in variable
 (defun mime-preview-scroll-down-entity (&optional h)
   "Scroll down current entity.
 If reached to (point-min), it calls function registered in variable
-`mime-view-over-to-previous-method-alist'."
+`mime-preview-over-to-previous-method-alist'."
   (interactive)
   (or h
       (setq h (1- (window-height)))
       )
   (if (= (point) (point-min))
       (let ((f (assq (mime-preview-original-major-mode)
-                    mime-view-over-to-previous-method-alist)))
+                    mime-preview-over-to-previous-method-alist)))
         (if f
             (funcall (cdr f))
           ))
@@ -1457,17 +1427,6 @@ It calls function registered in variable
        (funcall (cdr r))
       )))
 
-(defun mime-preview-show-summary ()
-  "Show summary.
-It calls function registered in variable
-`mime-view-show-summary-method'."
-  (interactive)
-  (let ((r (assq (mime-preview-original-major-mode)
-                mime-view-show-summary-method)))
-    (if r
-       (funcall (cdr r))
-      )))
-
 (defun mime-preview-kill-buffer ()
   (interactive)
   (kill-buffer (current-buffer))