(require 'filename)
(eval-when-compile
- (require 'mime-text)
(condition-case nil
(require 'bbdb)
(error (defvar bbdb-buffer-name nil)))
(erase-buffer)
(insert ";;; " (file-name-nondirectory file) "\n")
(insert "\n;; This file is generated automatically by "
- mime-view-version-string "\n\n")
+ mime-view-version "\n\n")
(insert ";;; Code:\n\n")
(pp `(setq mime-acting-situation-example-list
',mime-acting-situation-example-list)
(if (cdr ret)
(let ((rest ret)
(max-score 0)
- max-escore
+ (max-escore 0)
max-examples
max-situations)
(while rest
(name (mime-entity-safe-filename entity)))
(setq name
(if (and name (not (string= name "")))
- (expand-file-name name mime-temp-directory)
+ (expand-file-name name temporary-file-directory)
(make-temp-name
- (expand-file-name "EMI" mime-temp-directory))
+ (expand-file-name "EMI" temporary-file-directory))
))
(mime-write-entity-content entity name)
(message "External method is starting...")
(remove-alist 'mime-mailcap-method-filename-alist process)
(message (format "%s %s" process event)))
-(defvar mime-echo-window-is-shared-with-bbdb t
+(defvar mime-echo-window-is-shared-with-bbdb
+ (module-installed-p 'bbdb)
"*If non-nil, mime-echo window is shared with BBDB window.")
(defvar mime-echo-window-height
"Show mime-echo buffer to display MIME-playing information."
(get-buffer-create mime-echo-buffer-name)
(let ((the-win (selected-window))
- (win (get-buffer-window mime-echo-buffer-name))
+ (win (get-buffer-window mime-echo-buffer-name)))
+ (unless win
+ (unless (and mime-echo-window-is-shared-with-bbdb
+ (condition-case nil
+ (setq win (get-buffer-window bbdb-buffer-name))
+ (error nil)))
+ (select-window (get-buffer-window mime-preview-buffer))
+ (setq win (split-window-vertically
+ (- (window-height)
+ (if (functionp mime-echo-window-height)
+ (funcall mime-echo-window-height)
+ mime-echo-window-height)
+ )))
)
- (or win
- (if (and mime-echo-window-is-shared-with-bbdb
- (boundp 'bbdb-buffer-name)
- (setq win (get-buffer-window bbdb-buffer-name))
- )
- (set-window-buffer win mime-echo-buffer-name)
- (select-window (get-buffer-window mime-preview-buffer))
- (setq win (split-window-vertically
- (- (window-height)
- (if (functionp mime-echo-window-height)
- (funcall mime-echo-window-height)
- mime-echo-window-height)
- )))
- (set-window-buffer win mime-echo-buffer-name)
- ))
+ (set-window-buffer win mime-echo-buffer-name)
+ )
(select-window win)
(goto-char (point-max))
(if forms
;;; @ file detection
;;;
-(defvar mime-file-content-type-alist
- '(("JPEG" image jpeg)
- ("GIF" image gif)
- ("Standard MIDI" audio midi)
+(defvar mime-magic-type-alist
+ '(("^\377\330\377[\340\356]..JFIF" image jpeg)
+ ("^\211PNG" image png)
+ ("^GIF8[79]" image gif)
+ ("^II\\*\000" image tiff)
+ ("^MM\000\\*" image tiff)
+ ("^MThd" audio midi)
+ ("^\000\000\001\263" video mpeg)
)
- "*Alist of \"file\" output patterns vs. corresponding media-types.
+ "*Alist of regexp about magic-number vs. corresponding media-types.
Each element looks like (REGEXP TYPE SUBTYPE).
-REGEXP is pattern for \"file\" command output.
+REGEXP is a regular expression to match against the beginning of the
+content of entity.
TYPE is symbol to indicate primary type of media-type.
SUBTYPE is symbol to indicate subtype of media-type.")
(defun mime-detect-content (entity situation)
- (let ((beg (mime-entity-point-min entity))
- (end (mime-entity-point-max entity)))
- (goto-char beg)
- (let* ((name (save-restriction
- (narrow-to-region beg end)
- (mime-entity-safe-filename entity)
- ))
- (encoding (or (cdr (assq 'encoding situation)) "7bit"))
- (filename (if (and name (not (string-equal name "")))
- (expand-file-name name mime-temp-directory)
- (make-temp-name
- (expand-file-name "EMI" mime-temp-directory)))))
- (mime-write-decoded-region (mime-entity-body-start entity) end
- filename encoding)
- (let (type subtype)
- (with-temp-buffer
- (call-process "file" nil t nil filename)
- (goto-char (point-min))
- (if (search-forward (concat filename ": ") nil t)
- (let ((rest mime-file-content-type-alist))
- (while (not (let ((cell (car rest)))
- (if cell
- (if (looking-at (car cell))
- (setq type (nth 1 cell)
- subtype (nth 2 cell))
- )
- t)))
- (setq rest (cdr rest))))))
- (if type
- (mime-raw-play-entity
- entity nil
- (put-alist 'type type
- (put-alist 'subtype subtype
- (del-alist 'method
- (copy-alist situation))))
- (cdr (assq 'ignore-examples situation))
- 'mime-detect-content)
- ))
- )))
+ (let (type subtype)
+ (let ((mdata (save-excursion
+ ;;(set-buffer (mime-entity-buffer entity))
+ (let* ((start (mime-entity-body-start entity))
+ (end (progn
+ (goto-char start)
+ (end-of-line)
+ (point))))
+ (mime-decode-string (buffer-substring start end)
+ (mime-entity-encoding entity))
+ )))
+ (rest mime-magic-type-alist))
+ (while (not (let ((cell (car rest)))
+ (if cell
+ (if (string-match (car cell) mdata)
+ (setq type (nth 1 cell)
+ subtype (nth 2 cell))
+ )
+ t)))
+ (setq rest (cdr rest))))
+ (if type
+ (mime-raw-play-entity
+ entity nil
+ (put-alist 'type type
+ (put-alist 'subtype subtype
+ (del-alist 'method
+ (copy-alist situation))))
+ (cdr (assq 'ignore-examples situation))
+ 'mime-detect-content)
+ ))
+ )
;;; @ mail/news message
(goto-char (mime-entity-point-min entity))
(let* ((root-dir
(expand-file-name
- (concat "m-prts-" (user-login-name)) mime-temp-directory))
+ (concat "m-prts-" (user-login-name)) temporary-file-directory))
(id (cdr (assoc "id" cal)))
(number (cdr (assoc "number" cal)))
(total (cdr (assoc "total" cal)))
)
(setq buffer-read-only nil)
(erase-buffer)
- (mime-text-insert-decoded-body entity)
+ (mime-insert-text-content entity)
(mule-caesar-region (point-min) (point-max))
(set-buffer-modified-p nil)
(set-buffer mother)