;;; Code:
-(require 'std11)
-(require 'mime-lib)
+(require 'mime)
(require 'semi-def)
(require 'calist)
(require 'alist)
;;; @ entity information
;;;
+(defsubst mime-entity-representation-type (entity)
+ (with-current-buffer (mime-entity-buffer entity)
+ (or mime-raw-representation-type
+ (cdr (or (assq major-mode mime-raw-representation-type-alist)
+ (assq t mime-raw-representation-type-alist))))))
+
+(defsubst mime-entity-cooked-p (entity)
+ (eq (mime-entity-representation-type entity) 'cooked))
+
(defsubst mime-entity-parent (entity &optional message-info)
"Return mother entity of ENTITY.
If optional argument MESSAGE-INFO is not specified,
(defun mime-entity-filename (entity)
(or (mime-entity-uu-filename entity)
- (let ((ret (mime-entity-content-disposition entity)))
- (and ret
- (setq ret (mime-content-disposition-filename ret))
- (std11-strip-quoted-string ret)
- ))
- (let ((ret (mime-entity-content-type entity)))
- (and ret
- (setq ret
- (cdr
- (let ((param (mime-content-type-parameters ret)))
- (or (assoc "name" param)
- (assoc "x-name" param))
- )))
- (std11-strip-quoted-string ret)
- ))
- ))
+ (mime-content-disposition-filename
+ (mime-entity-content-disposition entity))
+ (cdr (let ((param (mime-content-type-parameters
+ (mime-entity-content-type entity))))
+ (or (assoc "name" param)
+ (assoc "x-name" param))
+ ))))
(defun mime-view-entity-title (entity)
- (or (mime-entity-read-field entity 'Content-Description)
- (mime-entity-read-field entity 'Subject)
+ (or (mime-read-field 'Content-Description entity)
+ (mime-read-field 'Subject entity)
(mime-entity-filename entity)
""))
'("From"))
-;;; @ X-Face
-;;;
-
-;; hack from Gnus 5.0.4.
-
-(defvar mime-view-x-face-to-pbm-command
- "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm")
-
-(defvar mime-view-x-face-command
- (concat mime-view-x-face-to-pbm-command
- " | xv -quit -")
- "String to be executed to display an X-Face field.
-The command will be executed in a sub-shell asynchronously.
-The compressed face will be piped to this command.")
-
-(defun mime-view-x-face-function ()
- "Function to display X-Face field. You can redefine to customize."
- ;; 1995/10/12 (c.f. tm-eng:130)
- ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
- (save-restriction
- (narrow-to-region (point-min) (re-search-forward "^$" nil t))
- ;; end
- (goto-char (point-min))
- (if (re-search-forward "^X-Face:[ \t]*" nil t)
- (let ((beg (match-end 0))
- (end (std11-field-end))
- )
- (call-process-region beg end "sh" nil 0 nil
- "-c" mime-view-x-face-command)
- ))))
-
-
;;; @ buffer setup
;;;
(when header-is-visible
(if header-presentation-method
(funcall header-presentation-method entity situation)
- (mime-insert-decoded-header
- entity
- mime-view-ignored-field-list mime-view-visible-field-list
- (save-excursion
- (set-buffer raw-buffer)
- (if (eq (cdr (assq major-mode mime-raw-representation-type-alist))
- 'binary)
- default-mime-charset)
- )))
+ (mime-insert-decoded-header entity
+ mime-view-ignored-field-list
+ mime-view-visible-field-list
+ (if (mime-entity-cooked-p entity)
+ nil
+ default-mime-charset))
+ )
(goto-char (point-max))
(insert "\n")
(run-hooks 'mime-display-header-hook)
(play "Play current entity" mime-preview-play-current-entity)
(extract "Extract current entity" mime-preview-extract-current-entity)
(print "Print current entity" mime-preview-print-current-entity)
- (x-face "Show X Face" mime-preview-display-x-face)
)
"Menu for MIME Viewer")
(setq preview-buffer
(concat "*Preview-" (buffer-name raw-buffer) "*")))
(set-buffer raw-buffer)
- (mime-parse-buffer)
(setq mime-preview-buffer preview-buffer)
(let ((inhibit-read-only t))
- (switch-to-buffer preview-buffer)
+ (set-buffer (get-buffer-create preview-buffer))
(widen)
(erase-buffer)
(setq mime-raw-buffer raw-buffer)
(search-forward "\n\n" nil t)
))
(run-hooks 'mime-view-mode-hook)
- ))
- (set-buffer-modified-p nil)
- (setq buffer-read-only t)
- )
+ (set-buffer-modified-p nil)
+ (setq buffer-read-only t)
+ (or (get-buffer-window preview-buffer)
+ (let ((r-win (get-buffer-window raw-buffer)))
+ (if r-win
+ (set-window-buffer r-win preview-buffer)
+ (switch-to-buffer preview-buffer)
+ )))
+ )))
(defun mime-view-buffer (&optional raw-buffer preview-buffer mother
default-keymap-or-function)
(interactive)
(mime-display-message
- (save-excursion
- (if raw-buffer (set-buffer raw-buffer))
- (mime-parse-message)
- )
+ (mime-parse-buffer raw-buffer)
preview-buffer mother default-keymap-or-function))
(defun mime-view-mode (&optional mother ctl encoding
(save-excursion
(if raw-buffer (set-buffer raw-buffer))
(or mime-view-redisplay
- (mime-parse-message ctl encoding))
+ (setq mime-message-structure (mime-parse-message ctl encoding)))
)
preview-buffer mother default-keymap-or-function))
))))
-;;; @@ X-Face
-;;;
-
-(defun mime-preview-display-x-face ()
- (interactive)
- (save-window-excursion
- (set-buffer mime-raw-buffer)
- (mime-view-x-face-function)
- ))
-
-
;;; @@ moving
;;;