X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mime-play.el;h=76e780b9c05d13ab33a0792c622f3b7325b95750;hb=89015e1aec762f3aef859e61ede1f74fd77ce9e3;hp=d88d09db54aa201e4e619370c0311d226b6eae79;hpb=259acb30f8500da2ab795178b9f1ecd848de9de8;p=elisp%2Fsemi.git diff --git a/mime-play.el b/mime-play.el index d88d09d..76e780b 100644 --- a/mime-play.el +++ b/mime-play.el @@ -5,7 +5,7 @@ ;; Author: MORIOKA Tomohiko ;; Created: 1995/9/26 (separated from tm-view.el) ;; Renamed: 1997/2/21 from tm-play.el -;; Version: $Id: mime-play.el,v 0.20 1997-03-17 05:05:14 morioka Exp $ +;; Version: $Id: mime-play.el,v 0.53 1997-10-31 07:48:39 morioka Exp $ ;; Keywords: MIME, multimedia, mail, news ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). @@ -37,39 +37,36 @@ (defvar mime-preview/after-decoded-position nil) -(defun mime-play-entity (&optional mode) +(defun mime-view-play-current-entity (&optional mode) "Play current entity. It decodes current entity to call internal or external method. The -method is selected from variable `mime/content-decoding-condition'. +method is selected from variable `mime-acting-condition'. If MODE is specified, play as it. Default MODE is \"play\"." (interactive) (or mode (setq mode "play") ) - (let ((pc (mime-preview/point-pcinfo (point)))) - (if pc - (let ((the-buf (current-buffer))) + (let ((cinfo (get-text-property (point) 'mime-view-cinfo))) + (if cinfo + (let ((the-buf (current-buffer)) + (raw-buffer (get-text-property (point) 'mime-view-raw-buffer)) + ) (setq mime-preview/after-decoded-position (point)) - (set-buffer (mime::preview-content-info/buffer pc)) - (mime-article/decode-content - (mime::preview-content-info/content-info pc) mode) - (if (eq (current-buffer) - (mime::preview-content-info/buffer pc)) + (set-buffer raw-buffer) + (mime-display-content cinfo mode) + (if (eq (current-buffer) raw-buffer) (progn (set-buffer the-buf) (goto-char mime-preview/after-decoded-position) )) )))) -(defun mime-article/decode-content (cinfo &optional mode) - (or mode - (setq mode mime-view-decoding-mode) - ) - (let ((beg (mime::content-info/point-min cinfo)) - (end (mime::content-info/point-max cinfo)) - (ctype (or (mime::content-info/type cinfo) "text/plain")) - (params (mime::content-info/parameters cinfo)) - (encoding (mime::content-info/encoding cinfo)) +(defun mime-display-content (cinfo &optional mode) + (let ((beg (mime-entity-info-point-min cinfo)) + (end (mime-entity-info-point-max cinfo)) + (ctype (or (mime-entity-info-type/subtype cinfo) "text/plain")) + (params (mime-entity-info-parameters cinfo)) + (encoding (mime-entity-info-encoding cinfo)) ) ;; Check for VM (if (< beg (point-min)) @@ -96,7 +93,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (mime-article/start-external-method-region beg end ret) ) (t - (mime-article/show-output-buffer + (mime-show-echo-buffer "No method are specified for %s\n" ctype) )) ) @@ -107,7 +104,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." ;;; (defun mime/get-content-decoding-alist (al) - (get-unified-alist mime/content-decoding-condition al) + (get-unified-alist mime-acting-condition al) ) @@ -142,13 +139,13 @@ If MODE is specified, play as it. Default MODE is \"play\"." (setq cal (put-alist 'file file cal)) (setq args (nconc (list (car method) - mime/output-buffer-name (car method) + mime-echo-buffer-name (car method) ) (mime-article/make-method-args cal (cdr (cdr method))) )) (apply (function start-process) args) - (mime-article/show-output-buffer) + (mime-show-echo-buffer) )) )))) @@ -169,20 +166,40 @@ If MODE is specified, play as it. Default MODE is \"play\"." )) format)) -(defun mime-article/show-output-buffer (&rest forms) - (get-buffer-create mime/output-buffer-name) +(defvar mime-echo-window-is-shared-with-bbdb t + "*If non-nil, mime-echo window is shared with BBDB window.") + +(defvar mime-echo-window-height + (function + (lambda () + (/ (window-height) 5) + )) + "*Size of mime-echo window. +It allows function or integer. If it is function, +`mime-show-echo-buffer' calls it to get height of mime-echo window. +Otherwise `mime-show-echo-buffer' uses it as height of mime-echo +window.") + +(defun mime-show-echo-buffer (&rest forms) + "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/output-buffer-name)) + (win (get-buffer-window mime-echo-buffer-name)) ) (or win - (if (and mime/output-buffer-window-is-shared-with-bbdb + (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/output-buffer-name) - (select-window (get-buffer-window mime::article/preview-buffer)) - (setq win (split-window-vertically (/ (* (window-height) 3) 4))) - (set-window-buffer win mime/output-buffer-name) + (set-window-buffer win mime-echo-buffer-name) + (select-window (get-buffer-window mime-view-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) )) (select-window win) (goto-char (point-max)) @@ -235,23 +252,22 @@ If MODE is specified, play as it. Default MODE is \"play\"." ;;; @ mail/news message ;;; -(defun mime-view-quitting-method-for-mime/show-message-mode () - (let ((mother mime::preview/mother-buffer) +(defun mime-view-quitting-method-for-mime-show-message-mode () + "Quitting method for mime-view. +It is registered to variable `mime-view-quitting-method-alist'." + (let ((mother mime-mother-buffer) (win-conf mime::preview/original-window-configuration) ) - (kill-buffer - (mime::preview-content-info/buffer (car mime::preview/content-list))) + (kill-buffer mime-raw-buffer) (mime-view-kill-buffer) (set-window-configuration win-conf) (pop-to-buffer mother) - ;;(goto-char (point-min)) - ;;(mime-view-up-content) )) -(defun mime-article/view-message/rfc822 (beg end cal) +(defun mime-display-message/rfc822 (beg end cal) (let* ((cnum (mime-article/point-content-number beg)) (new-name (format "%s-%s" (buffer-name) cnum)) - (mother mime::article/preview-buffer) + (mother mime-view-buffer) (text-decoder (cdr (or (assq major-mode mime-text-decoder-alist) (assq t mime-text-decoder-alist)))) @@ -264,7 +280,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (if (re-search-forward "^\n" nil t) (delete-region (point-min) (match-end 0)) ) - (setq major-mode 'mime/show-message-mode) + (setq major-mode 'mime-show-message-mode) (setq mime-text-decoder text-decoder) (mime-view-mode mother) )) @@ -287,7 +303,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (write-region start end file) )) -(defun mime-article/decode-message/partial (beg end cal) +(defun mime-display-message/partial (beg end cal) (goto-char beg) (let* ((root-dir (expand-file-name @@ -296,7 +312,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (number (cdr (assoc "number" cal))) (total (cdr (assoc "total" cal))) file - (mother mime::article/preview-buffer) + (mother mime-view-buffer) ) (or (file-exists-p root-dir) (make-directory root-dir) @@ -316,19 +332,19 @@ If MODE is specified, play as it. Default MODE is \"play\"." (set-buffer full-buf) (erase-buffer) (as-binary-input-file (insert-file-contents file)) - (setq major-mode 'mime/show-message-mode) + (setq major-mode 'mime-show-message-mode) (mime-view-mode mother) ) (set-window-buffer pwin (save-excursion (set-buffer full-buf) - mime::article/preview-buffer)) + mime-view-buffer)) (select-window pwin) ) (re-search-forward "^$") (goto-char (1+ (match-end 0))) (setq file (concat root-dir "/" number)) - (mime-article::write-region (point) (point-max) file) + (mime-article::write-region (point) end file) (let ((total-file (concat root-dir "/CT"))) (setq total (if total @@ -336,10 +352,10 @@ If MODE is specified, play as it. Default MODE is \"play\"." (or (file-exists-p total-file) (save-excursion (set-buffer - (get-buffer-create mime/temp-buffer-name)) + (get-buffer-create mime-temp-buffer-name)) (erase-buffer) (insert total) - (write-file total-file) + (write-region (point-min)(point-max) total-file) (kill-buffer (current-buffer)) )) (string-to-number total) @@ -359,7 +375,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (if (and total (> total 0)) (catch 'tag (save-excursion - (set-buffer (get-buffer-create mime/temp-buffer-name)) + (set-buffer (get-buffer-create mime-temp-buffer-name)) (let ((full-buf (current-buffer))) (erase-buffer) (let ((i 1)) @@ -372,7 +388,9 @@ If MODE is specified, play as it. Default MODE is \"play\"." (goto-char (point-max)) (setq i (1+ i)) )) - (as-binary-output-file (write-file (concat root-dir "/FULL"))) + (as-binary-output-file + (write-region (point-min)(point-max) + (expand-file-name "FULL" root-dir))) (let ((i 1)) (while (<= i total) (let ((file (format "%s/%d" root-dir i))) @@ -386,7 +404,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." (delete-file file) )) (save-window-excursion - (setq major-mode 'mime/show-message-mode) + (setq major-mode 'mime-show-message-mode) (mime-view-mode mother) ) (let ((pwin (or (get-buffer-window mother) @@ -394,7 +412,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." )) (pbuf (save-excursion (set-buffer full-buf) - mime::article/preview-buffer))) + mime-view-buffer))) (set-window-buffer pwin pbuf) (select-window pwin) ))))) @@ -411,13 +429,13 @@ If MODE is specified, play as it. Default MODE is \"play\"." )) (defun mime-article/dired-function-for-one-frame (dir) - (let ((win (or (get-buffer-window mime::article/preview-buffer) + (let ((win (or (get-buffer-window mime-view-buffer) (get-largest-window)))) (select-window win) (dired dir) )) -(defun mime-article/decode-message/external-ftp (beg end cal) +(defun mime-display-message/external-ftp (beg end cal) (let* ((site (cdr (assoc "site" cal))) (directory (cdr (assoc "directory" cal))) (name (cdr (assoc "name" cal))) @@ -434,34 +452,16 @@ If MODE is specified, play as it. Default MODE is \"play\"." ;;; @ rot13-47 ;;; -(require 'view) - -(defconst mime-view-text/plain-mode-map (copy-keymap view-mode-map)) -(define-key mime-view-text/plain-mode-map - "q" (function mime-view-text/plain-exit)) - -(defun mime-view-text/plain-mode () - "\\{mime-view-text/plain-mode-map}" - (setq buffer-read-only t) - (setq major-mode 'mime-view-text/plain-mode) - (setq mode-name "MIME-View text/plain") - (use-local-map mime-view-text/plain-mode-map) - ) - -(defun mime-view-text/plain-exit () - (interactive) - (kill-buffer (current-buffer)) - ) - -(defun mime-article/decode-caesar (beg end cal) - (let* ((cnum (mime-article/point-content-number beg)) +(defun mime-display-caesar (start end cal) + "Internal method for mime-view to display ROT13-47-48 message." + (let* ((cnum (mime-article/point-content-number start)) (new-name (format "%s-%s" (buffer-name) cnum)) - (mother mime::article/preview-buffer) + (the-buf (current-buffer)) + (mother mime-view-buffer) (charset (cdr (assoc "charset" cal))) (encoding (cdr (assq 'encoding cal))) (mode major-mode) - str) - (setq str (buffer-substring beg end)) + ) (let ((pwin (or (get-buffer-window mother) (get-largest-window))) (buf (get-buffer-create new-name)) @@ -472,7 +472,7 @@ If MODE is specified, play as it. Default MODE is \"play\"." ) (setq buffer-read-only nil) (erase-buffer) - (insert str) + (insert-buffer-substring the-buf start end) (goto-char (point-min)) (if (re-search-forward "^\n" nil t) (delete-region (point-min) (match-end 0)) @@ -482,13 +482,10 @@ If MODE is specified, play as it. Default MODE is \"play\"." (and (functionp m) (funcall m charset encoding) )) - (save-excursion - (set-mark (point-min)) - (goto-char (point-max)) - (tm:caesar-region) - ) + (mule-caesar-region (point-min) (point-max)) (set-buffer-modified-p nil) - (mime-view-text/plain-mode) + (set-buffer mother) + (view-buffer new-name) ))