;;; @ version
;;;
-(defconst mime/viewer-RCS-ID
- "$Id: tm-view.el,v 5.21 1994/11/21 18:38:48 morioka Exp morioka $")
+(defconst mime-viewer/RCS-ID
+ "$Id: tm-view.el,v 6.8 1995/03/12 15:58:32 morioka Exp $")
-(defconst mime/viewer-version (get-version-string mime/viewer-RCS-ID))
+(defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
+(defconst mime/viewer-version mime-viewer/version)
;;; @ constants
"-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
))
-(defvar mime/content-filter-alist
- '(("text/plain" . mime/decode-text/plain)))
+(defvar mime-viewer/content-filter-alist
+ '(("text/plain" . mime-viewer/filter-text/plain)))
-(defvar mime/make-content-subject-function
+(defvar mime-viewer/content-subject-function
(function
- (lambda (cid subj ctype)
+ (lambda (cnum subj ctype params)
(insert
(format "[%s %s (%s)]\n"
- (if (listp cid)
+ (if (listp cnum)
(mapconcat (function
(lambda (num)
(format "%s" (+ num 1))
))
- cid ".")
+ cnum ".")
"0")
- subj (car ctype)))
+ subj ctype))
)))
-(defvar mime/make-content-header-filter
-;;(setq mime/make-content-header-filter
- (function
- (lambda (cid)
- (if (listp cid)
- (delete-region (goto-char (point-min))
- (or (and (re-search-forward "^$" nil t)
- (match-end 0))
- (point-max))
- )
- )
- )))
+(defvar mime-viewer/content-header-filter-function
+ (function mime-viewer/default-content-header-filter-function))
-(defvar mime/default-showing-Content-Type-list
-;;(setq mime/default-showing-Content-Type-list
+(defun mime-viewer/default-content-header-filter-function (cnum)
+ (if (listp cnum)
+ (delete-region (goto-char (point-min))
+ (or (and (re-search-forward "^$" nil t)
+ (match-end 0))
+ (point-max))
+ )
+ ))
+
+(defvar mime-viewer/default-showing-Content-Type-list
'("text/plain" "text/richtext" "text/enriched"
"text/x-latex" "application/x-latex"
"application/octet-stream" nil))
-(defvar mime/go-to-top-node-method-alist
-;;(setq mime/go-to-top-node-method-alist
- '((gnus-article-mode . (lambda ()
- (mime/exit-view-mode)
- (delete-other-windows)
- (gnus-article-show-summary)
- ))
- (rmail-mode . (lambda ()
- (mime/exit-view-mode)
- (rmail-summary)
- (delete-other-windows)
- ))
- (mh-show-mode . (lambda ()
- (let ((win (get-buffer-window
- mime/output-buffer-name))
- (buf
- (nth 2 (car mime/preview-flat-content-list)))
- )
- (if win
- (delete-window win)
- )
- (mime/exit-view-mode)
- (pop-to-buffer
- (let ((name (buffer-name buf)))
- (string-match "show-" name)
- (substring name (match-end 0))
- ))
- )))
- (mime/show-message-mode . (lambda ()
- (set-window-configuration
- mime/show-mode-old-window-configuration)
- (let ((mother mime/mother-buffer))
- (kill-buffer
- (nth 2 (car
- mime/preview-flat-content-list)))
- (mime/exit-view-mode)
- (pop-to-buffer mother)
- (goto-char (point-min))
- (mime/up-content)
- )))
+(defvar mime-viewer/quitting-method-alist
+ '((gnus-article-mode
+ . (lambda ()
+ (mime-viewer/kill-buffer)
+ (delete-other-windows)
+ (gnus-article-show-summary)
+ ))
+ (rmail-mode
+ . (lambda ()
+ (mime-viewer/kill-buffer)
+ (rmail-summary)
+ (delete-other-windows)
+ ))
+ (mh-show-mode
+ . (lambda ()
+ (let ((win (get-buffer-window
+ mime/output-buffer-name))
+ (buf
+ (mime::preview-content-info/buffer
+ (car mime::preview/content-list)))
+ )
+ (if win
+ (delete-window win)
+ )
+ (mime-viewer/kill-buffer)
+ (pop-to-buffer
+ (let ((name (buffer-name buf)))
+ (string-match "show-" name)
+ (substring name (match-end 0))
+ ))
+ )))
+ (mime/show-message-mode
+ . (lambda ()
+ (set-window-configuration
+ mime/show-mode-old-window-configuration)
+ (let ((mother mime/mother-buffer))
+ (kill-buffer
+ (mime::preview-content-info/buffer
+ (car mime::preview/content-list)))
+ (mime-viewer/kill-buffer)
+ (pop-to-buffer mother)
+ (goto-char (point-min))
+ (mime-viewer/up-content)
+ )))
))
-(defvar mime/use-internal-decoder nil)
+(defvar mime-viewer/decoding-mode "play" "MIME body decoding mode")
+
+
+;;; @ data structure
+;;;
+
+;;; @@ content-info
+;;;
+
+(defun mime::make-content-info (beg end ctype params encoding children)
+ (vector beg end ctype params encoding children)
+ )
+
+(defun mime::content-info/point-min (cinfo)
+ (elt cinfo 0)
+ )
+
+(defun mime::content-info/point-max (cinfo)
+ (elt cinfo 1)
+ )
+
+(defun mime::content-info/type (cinfo)
+ (elt cinfo 2)
+ )
+
+(defun mime::content-info/parameters (cinfo)
+ (elt cinfo 3)
+ )
+
+(defun mime::content-info/encoding (cinfo)
+ (elt cinfo 4)
+ )
+
+(defun mime::content-info/children (cinfo)
+ (elt cinfo 5)
+ )
+
+;;; @@ preview-content-info
+;;;
+
+(defun mime::make-preview-content-info (beg end buf cinfo)
+ (vector beg end buf cinfo)
+ )
+
+(defun mime::preview-content-info/point-min (pcinfo)
+ (elt pcinfo 0)
+ )
+
+(defun mime::preview-content-info/point-max (pcinfo)
+ (elt pcinfo 1)
+ )
+
+(defun mime::preview-content-info/buffer (pcinfo)
+ (elt pcinfo 2)
+ )
+
+(defun mime::preview-content-info/content-info (pcinfo)
+ (elt pcinfo 3)
+ )
+
-(defvar mime/body-decoding-mode "play" "MIME body decoding mode")
+;;; @ buffer local variables
+;;;
+
+(defvar mime::article/content-info)
+(defvar mime::article/preview-buffer)
+
+(defvar mime::preview/content-list nil)
+(defvar mime::preview/original-major-mode nil)
;;; @ parser
;;;
-(defun mime/parse-contents ()
+(defun mime-viewer/parse-message ()
+ (make-variable-buffer-local 'mime::article/content-info)
+ (setq mime::article/content-info (mime-viewer/parse))
+ (let ((ret (mime-viewer/make-preview-buffer)))
+ (make-variable-buffer-local 'mime::article/preview-buffer)
+ (setq mime::article/preview-buffer (car ret))
+ ret))
+
+(defun mime-viewer/parse ()
(save-excursion
(save-restriction
- (goto-char (point-min))
- (let* ((ctl (mime/Content-Type))
- (ctype (car ctl))
- (boundary (assoc "boundary" (cdr ctl)))
- beg end dest)
- (if (stringp ctype)
- (setq ctype (downcase ctype))
- )
- (search-forward "\n\n" nil t)
- (cond (boundary
- (let ((sep (concat "\n--"
- (setq boundary
- (message/strip-quoted-string
- (cdr boundary)))
- "\n"))
- cb ce ct ret ncb)
- (setq beg (match-end 0))
- (search-forward (concat "\n--" boundary "--\n") nil t)
- (setq end (match-beginning 0))
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (goto-char (point-min))
- (search-forward (concat "--" boundary "\n") nil t)
- (setq cb (match-end 0))
- (while (search-forward sep nil t)
- (setq ce (match-beginning 0))
- (setq ncb (match-end 0))
- (save-excursion
- (save-restriction
- (narrow-to-region cb ce)
- (setq ret (mime/parse-contents))
- ))
- (setq dest (nconc dest (list ret)))
- (goto-char (nth 1 ret))
- (search-forward (concat "--" boundary "\n") nil t)
- (goto-char (setq cb (match-end 0)))
- )
- (setq ce (point-max))
- (save-excursion
- (save-restriction
- (narrow-to-region cb ce)
- (setq ret (mime/parse-contents))
- ))
- (setq dest (append dest (list ret)))
- ))
- (setq beg (point-min))
- (goto-char beg)
- (search-forward (concat "\n--" boundary "--\n") nil t)
- (setq end (match-beginning 0))
- ))
- ((string= ctype "message/rfc822")
- (save-excursion
- (save-restriction
- (narrow-to-region (match-end 0) (point-max))
- (setq dest (list (mime/parse-contents)))
+ (let ((ctl (progn
+ (goto-char (point-min))
+ (mime/Content-Type)
))
- (setq beg (point-min))
- (setq end (point-max))
- )
- (t (setq beg (point-min))
- (setq end (point-max))
- ))
- (list beg end dest)
- ))))
+ (encoding (progn
+ (goto-char (point-min))
+ (mime/Content-Transfer-Encoding)
+ ))
+ )
+ (let ((ctype (car ctl))
+ (params (cdr ctl))
+ )
+ (if (stringp ctype)
+ (setq ctype (downcase ctype))
+ )
+ (if (stringp encoding)
+ (setq encoding (downcase encoding))
+ )
+ (let ((boundary (assoc "boundary" params)))
+ (search-forward "\n\n" nil t)
+ (cond (boundary
+ (setq boundary
+ (message/strip-quoted-string (cdr boundary)))
+ (mime-viewer/parse-multipart
+ (match-end 0)
+ (progn
+ (search-forward (concat "--" boundary "--\n") nil t)
+ (match-beginning 0)
+ )
+ boundary ctype params encoding)
+ )
+ ((string= ctype "message/rfc822")
+ (mime::make-content-info
+ (point-min) (point-max)
+ ctype params encoding
+ (save-excursion
+ (save-restriction
+ (narrow-to-region (match-end 0) (point-max))
+ (list (mime-viewer/parse))
+ ))
+ )
+ )
+ (t
+ (mime::make-content-info (point-min) (point-max)
+ ctype params encoding nil)
+ ))
+ ))))))
+
+(defun mime-viewer/parse-multipart (beg end boundary ctype params encoding)
+ (let ((sep (concat "^--" boundary "$"))
+ cb ce ct ret ncb children)
+ (save-excursion
+ (save-restriction
+ (narrow-to-region beg end)
+ (goto-char (point-min))
+ (search-forward (concat "--" boundary "\n") nil t)
+ (setq cb (match-end 0))
+ (while (re-search-forward sep nil t)
+ (setq ce (match-beginning 0))
+ (setq ncb (match-end 0))
+ (save-excursion
+ (save-restriction
+ (narrow-to-region cb ce)
+ (setq ret (mime-viewer/parse))
+ ))
+ (setq children (nconc children (list ret)))
+ (goto-char (mime::content-info/point-max ret))
+ (search-forward (concat "--" boundary "\n") nil t)
+ (goto-char (setq cb (match-end 0)))
+ )
+ (setq ce (point-max))
+ (save-excursion
+ (save-restriction
+ (narrow-to-region cb ce)
+ (setq ret (mime-viewer/parse))
+ ))
+ (setq children (nconc children (list ret)))
+ ))
+ (setq beg (point-min))
+ (goto-char beg)
+ (mime::make-content-info beg end ctype params encoding children)
+ ))
(defun mime/Content-Type ()
(save-excursion
(replace-as-filename (mime/get-subject param))
)
-(defun mime/make-preview-buffer (&optional buf cl obuf)
- (let ((the-buf (current-buffer)) fcl)
- (if (null buf)
- (setq buf (current-buffer))
- (setq buf (get-buffer buf))
- )
- (if (null cl)
+(defun mime-viewer/make-preview-buffer (&optional buf cinfo obuf)
+ (let ((the-buf (current-buffer)) pcl dest)
+ (setq buf
+ (if (null buf)
+ (current-buffer)
+ (get-buffer buf)
+ ))
+ (if (null cinfo)
(progn
(switch-to-buffer buf)
- (setq cl mime/content-list)
+ (setq cinfo mime::article/content-info)
))
(if (null obuf)
(setq obuf (concat "*Preview-" (buffer-name buf) "*"))
)
- (setq fcl (mime/make-flat-content-list cl))
+ (setq pcl (mime::make-flat-content-list cinfo))
(if (get-buffer obuf)
(kill-buffer obuf)
)
- (let ((r fcl) cell cid ctype beg end e nb ne subj dest str)
- (while r
- (setq cell (car r))
- (setq beg (car cell))
- (setq end (nth 1 cell))
- (setq cid (mime/get-point-content-number beg cl))
- (switch-to-buffer buf)
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (goto-char beg)
- (setq ctype (mime/Content-Type))
- (setq e
- (if (not (member (car ctype)
- mime/default-showing-Content-Type-list))
- (progn
- (goto-char beg)
- (search-forward "\n\n" nil t)
- (match-end 0)
- )
- (+ end 1)
- ))
- ))
- (if (> e (point-max))
- (setq e (point-max))
- )
- (setq str (buffer-substring beg e))
- (switch-to-buffer obuf)
- (setq nb (point))
- (insert str)
- (setq ne (point))
- (save-excursion
- (save-restriction
- (narrow-to-region nb ne)
- (mime/decode-message-header)
- (setq subj (mime/get-subject (cdr ctype)))
- (let ((f (cdr (assoc (car ctype) mime/content-filter-alist))))
- (if (and f (fboundp f))
- (funcall f ctype)
- ))
- (funcall mime/make-content-header-filter cid)
- (goto-char nb)
- (funcall mime/make-content-subject-function cid subj ctype)
- (setq ne (point-max))
- (setq dest (nconc dest (list (list nb (- ne 1) buf beg end))))
- ))
- (goto-char ne)
- (setq r (cdr r))
- )
- (set-buffer-modified-p nil)
- (setq buffer-read-only t)
- (switch-to-buffer the-buf)
- (list obuf dest)
- )))
+ (setq dest
+ (mapcar
+ (function
+ (lambda (cell)
+ (let ((beg (mime::content-info/point-min cell))
+ (end (mime::content-info/point-max cell))
+ (ctype (mime::content-info/type cell))
+ (params (mime::content-info/parameters cell))
+ cnum e nb ne subj str)
+ (setq cnum (mime::get-point-content-number beg cinfo))
+ (switch-to-buffer buf)
+ (setq e
+ (if (not
+ (member
+ ctype
+ mime-viewer/default-showing-Content-Type-list))
+ (save-excursion
+ (save-restriction
+ (goto-char beg)
+ (search-forward "\n\n" nil t)
+ (match-end 0)
+ ))
+ end))
+ (if (> e (point-max))
+ (setq e (point-max))
+ )
+ (setq str (buffer-substring beg e))
+ (switch-to-buffer obuf)
+ (setq nb (point))
+ (insert str)
+ (setq ne (point))
+ (prog1
+ (save-excursion
+ (save-restriction
+ (narrow-to-region nb ne)
+ (mime/decode-message-header)
+ (setq subj (mime/get-subject params))
+ (let ((f
+ (cdr
+ (assoc ctype
+ mime-viewer/content-filter-alist))))
+ (if (and f (fboundp f))
+ (funcall f ctype params)
+ ))
+ (funcall mime-viewer/content-header-filter-function
+ cnum)
+ (goto-char nb)
+ (funcall mime-viewer/content-subject-function
+ cnum subj ctype params)
+ (setq ne (point-max))
+ (mime::make-preview-content-info nb (- ne 1)
+ buf cell)
+ ))
+ (goto-char ne)
+ )
+ ))) pcl))
+ (set-buffer-modified-p nil)
+ (setq buffer-read-only t)
+ (switch-to-buffer the-buf)
+ (list obuf dest)
+ ))
-(defun mime/parse-message ()
- (interactive)
- (make-variable-buffer-local 'mime/content-list)
- (setq mime/content-list (mime/parse-contents))
- (let ((ret (mime/make-preview-buffer)))
- (make-variable-buffer-local 'mime/preview-buffer)
- (setq mime/preview-buffer (car ret))
- ret))
;;; @ content information
;;;
-(defun mime/get-point-content-number (p &optional cl)
- (if (null cl)
- (setq cl mime/content-list)
+(defun mime::get-point-content-number (p &optional cinfo)
+ (if (null cinfo)
+ (setq cinfo mime::article/content-info)
)
- (let ((b (car cl))
- (e (nth 1 cl))
- (c (nth 2 cl))
+ (let ((b (mime::content-info/point-min cinfo))
+ (e (mime::content-info/point-max cinfo))
+ (c (mime::content-info/children cinfo))
)
(if (and (<= b p)(<= p e))
(or (let (co ret (sn 0))
(catch 'tag
(while c
(setq co (car c))
- (setq ret (mime/get-point-content-number p co))
+ (setq ret (mime::get-point-content-number p co))
(cond ((eq ret t) (throw 'tag (list sn)))
(ret (throw 'tag (cons sn ret)))
)
)))
t))))
-(defun mime/get-content-region (cn &optional cl)
- (if (null cl)
- (setq cl mime/content-list)
+(defun mime::article/get-content-region (cn &optional cinfo)
+ (if (null cinfo)
+ (setq cinfo mime::article/content-info)
)
(if (eq cn t)
- cl
+ cinfo
(let ((sn (car cn)))
(if (null sn)
- cl
- (let ((rcl (nth sn (nth 2 cl))))
- (if rcl
- (mime/get-content-region (cdr cn) rcl)
+ cinfo
+ (let ((rc (nth sn (mime::content-info/children cinfo))))
+ (if rc
+ (mime::article/get-content-region (cdr cn) rc)
))
))))
-(defun mime/make-flat-content-list (&optional cl)
- (if (null cl)
- (setq cl mime/content-list)
+(defun mime::make-flat-content-list (&optional cinfo)
+ (if (null cinfo)
+ (setq cinfo mime::article/content-info)
)
- (let ((dest (list cl))
- (rcl (nth 2 cl))
+ (let ((dest (list cinfo))
+ (rcl (mime::content-info/children cinfo))
)
(while rcl
- (setq dest (append dest (mime/make-flat-content-list (car rcl))))
+ (setq dest (nconc dest (mime::make-flat-content-list (car rcl))))
(setq rcl (cdr rcl))
)
dest))
-(defun mime/get-point-preview-content (p &optional fcl)
- (if (null fcl)
- (setq fcl mime/preview-flat-content-list)
+(defun mime::point-preview-content (p &optional pcl)
+ (if (null pcl)
+ (setq pcl mime::preview/content-list)
)
(catch 'tag
- (let ((r fcl) cell)
+ (let ((r pcl) cell)
(while r
(setq cell (car r))
- (if (and (<= (car cell) p)(<= p (nth 1 cell)))
+ (if (and (<= (mime::preview-content-info/point-min cell) p)
+ (<= p (mime::preview-content-info/point-max cell))
+ )
(throw 'tag cell)
)
(setq r (cdr r))
))
- (car (last fcl))
+ (car (last pcl))
))
(total (cdr (assoc "total" cal)))
(the-buf (current-buffer))
file
- (mother mime/preview-buffer))
+ (mother mime::article/preview-buffer))
(if (not (file-exists-p root-dir))
(shell-command (concat "mkdir " root-dir))
)
(get-unified-alist mime/content-decoding-condition al)
)
-(defun mime/decode-content-region (beg end)
+(defun mime::article/decode-content-region (cinfo)
(interactive "*r")
- (let (ctl encoding)
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (and (goto-char beg)
- (setq ctl (mime/Content-Type))
- (goto-char beg)
- (setq encoding (mime/Content-Transfer-Encoding "7bit"))
- )))
- (if ctl
- (let ((ctype (downcase (car ctl))) method cal ret)
- (setq ctl (cdr ctl))
- (setq cal (nconc (list (cons 'type ctype)
- (cons 'encoding encoding)
- (cons 'major-mode major-mode)
- )
- ctl))
- (if mime/body-decoding-mode
+ (let ((beg (mime::content-info/point-min cinfo))
+ (end (mime::content-info/point-max cinfo))
+ (ctype (mime::content-info/type cinfo))
+ (params (mime::content-info/parameters cinfo))
+ (encoding (mime::content-info/encoding cinfo))
+ )
+ (if ctype
+ (let (method cal ret)
+ (setq cal (append (list (cons 'type ctype)
+ (cons 'encoding encoding)
+ (cons 'major-mode major-mode)
+ )
+ params))
+ (if mime-viewer/decoding-mode
(setq cal (cons
- (cons 'mode mime/body-decoding-mode)
+ (cons 'mode mime-viewer/decoding-mode)
cal))
)
(setq ret (mime/get-content-decoding-alist cal))
;;; @ content filter
;;;
-(defun mime/decode-text/plain (ctl)
- (interactive)
+(defun mime-viewer/filter-text/plain (ctype params)
(save-excursion
(save-restriction
- (let ((charset (cdr (assoc "charset" (cdr ctl))))
- (encoding
+ (let ((charset (cdr (assoc "charset" params)))
+ (encoding
(save-excursion
(save-restriction
(goto-char (point-min))
(progn
(setq mime/viewer-mode-map (make-keymap))
(suppress-keymap mime/viewer-mode-map)
- (define-key mime/viewer-mode-map "u" 'mime/up-content)
- (define-key mime/viewer-mode-map "p" 'mime/previous-content)
- (define-key mime/viewer-mode-map "n" 'mime/next-content)
- (define-key mime/viewer-mode-map " " 'mime/scroll-up-content)
- (define-key mime/viewer-mode-map "\M- " 'mime/scroll-down-content)
- (define-key mime/viewer-mode-map "\177" 'mime/scroll-down-content)
- (define-key mime/viewer-mode-map "\C-m" 'mime/next-line-content)
- (define-key mime/viewer-mode-map "\C-\M-m" 'mime/previous-line-content)
- (define-key mime/viewer-mode-map "v" 'mime/play-content)
- (define-key mime/viewer-mode-map "e" 'mime/extract-content)
- (define-key mime/viewer-mode-map "\C-c\C-p" 'mime/print-content)
- (define-key mime/viewer-mode-map "q" 'mime/quit-view-mode)
- (define-key mime/viewer-mode-map "\C-c\C-x" 'mime/exit-view-mode)
+ (define-key mime/viewer-mode-map
+ "u" (function mime-viewer/up-content))
+ (define-key mime/viewer-mode-map
+ "p" (function mime-viewer/previous-content))
+ (define-key mime/viewer-mode-map
+ "n" (function mime-viewer/next-content))
+ (define-key mime/viewer-mode-map
+ " " (function mime-viewer/scroll-up-content))
+ (define-key mime/viewer-mode-map
+ "\M- " (function mime-viewer/scroll-down-content))
+ (define-key mime/viewer-mode-map
+ "\177" (function mime-viewer/scroll-down-content))
+ (define-key mime/viewer-mode-map
+ "\C-m" (function mime-viewer/next-line-content))
+ (define-key mime/viewer-mode-map
+ "\C-\M-m" (function mime-viewer/previous-line-content))
+ (define-key mime/viewer-mode-map
+ "v" (function mime-viewer/play-content))
+ (define-key mime/viewer-mode-map
+ "e" (function mime-viewer/extract-content))
+ (define-key mime/viewer-mode-map
+ "\C-c\C-p" (function mime-viewer/print-content))
+ (define-key mime/viewer-mode-map
+ "q" (function mime-viewer/quit))
+ (define-key mime/viewer-mode-map
+ "\C-c\C-x" (function mime-viewer/kill-buffer))
))
(defun mime/viewer-mode (&optional mother)
(erase-buffer)
(switch-to-buffer the-buf)
)))
- (let ((ret (mime/parse-message))
+ (let ((ret (mime-viewer/parse-message))
(mode major-mode))
(switch-to-buffer (car ret))
(setq major-mode 'mime/viewer-mode)
(setq mode-name "MIME-View")
- (make-variable-buffer-local 'mime/viewer-original-major-mode)
- (setq mime/viewer-original-major-mode
+ (make-variable-buffer-local 'mime::preview/original-major-mode)
+ (setq mime::preview/original-major-mode
(if mother
(progn
(make-variable-buffer-local
'mime/show-message-mode)
mode))
(use-local-map mime/viewer-mode-map)
- (make-variable-buffer-local 'mime/preview-flat-content-list)
- (setq mime/preview-flat-content-list (nth 1 ret))
+ (make-variable-buffer-local 'mime::preview/content-list)
+ (setq mime::preview/content-list (nth 1 ret))
(goto-char
- (let ((ce (nth 1 (car mime/preview-flat-content-list)))
+ (let ((ce (mime::preview-content-info/point-max
+ (car mime::preview/content-list)
+ ))
e)
(goto-char (point-min))
(search-forward "\n\n" nil t)
(run-hooks 'mime/viewer-mode-hook)
))
-(defun mime/decode-content ()
+(defun mime::preview/decode-content ()
(interactive)
- (let ((pc (mime/get-point-preview-content (point))))
+ (let ((pc (mime::point-preview-content (point))))
(if pc
(let ((the-buf (current-buffer)))
- (switch-to-buffer (nth 2 pc))
- (mime/decode-content-region (nth 3 pc)(nth 4 pc))
- (if (eq (current-buffer) (nth 2 pc))
+ (switch-to-buffer (mime::preview-content-info/buffer pc))
+ (mime::article/decode-content-region
+ (mime::preview-content-info/content-info pc))
+ (if (eq (current-buffer)
+ (mime::preview-content-info/buffer pc))
(switch-to-buffer the-buf)
)
))))
-(defun mime/play-content ()
+(defun mime-viewer/play-content ()
(interactive)
- (let ((mime/body-decoding-mode "play"))
- (mime/decode-content)
+ (let ((mime-viewer/decoding-mode "play"))
+ (mime::preview/decode-content)
))
-(defun mime/extract-content ()
+(defun mime-viewer/extract-content ()
(interactive)
- (let ((mime/body-decoding-mode "extract"))
- (mime/decode-content)
+ (let ((mime-viewer/decoding-mode "extract"))
+ (mime::preview/decode-content)
))
-(defun mime/print-content ()
+(defun mime-viewer/print-content ()
(interactive)
- (let ((mime/body-decoding-mode "print"))
- (mime/decode-content)
+ (let ((mime-viewer/decoding-mode "print"))
+ (mime::preview/decode-content)
))
-(defun mime/up-content ()
+(defun mime-viewer/up-content ()
(interactive)
- (let ((pc (mime/get-point-preview-content (point)))
+ (let ((pc (mime::point-preview-content (point))) cinfo
(the-buf (current-buffer))
cn r)
- (switch-to-buffer (nth 2 pc))
- (setq cn (mime/get-point-content-number (nth 3 pc)))
+ (switch-to-buffer (mime::preview-content-info/buffer pc))
+ (setq cinfo (mime::preview-content-info/content-info pc))
+ (setq cn (mime::get-point-content-number
+ (mime::content-info/point-min cinfo)))
(if (eq cn t)
- (mime/quit-view-mode the-buf (nth 2 pc))
- (setq r (mime/get-content-region (butlast cn)))
+ (mime-viewer/quit the-buf
+ (mime::preview-content-info/buffer pc)
+ )
+ (setq r (mime::article/get-content-region (butlast cn)))
(switch-to-buffer the-buf)
(catch 'tag
- (let ((rfcl mime/preview-flat-content-list) cell)
- (while rfcl
- (setq cell (car rfcl))
- (if (and (= (car r)(nth 3 cell))
- (= (nth 1 r)(nth 4 cell))
- )
+ (let ((rpcl mime::preview/content-list) cell)
+ (while rpcl
+ (setq cell (car rpcl))
+ (if (eq r (mime::preview-content-info/content-info cell))
(progn
- (goto-char (nth 0 cell))
+ (goto-char (mime::preview-content-info/point-min cell))
(throw 'tag nil)
))
- (setq rfcl (cdr rfcl))
+ (setq rpcl (cdr rpcl))
)))
)))
-(defun mime/previous-content ()
+(defun mime-viewer/previous-content ()
(interactive)
- (let* ((fcl mime/preview-flat-content-list)
+ (let* ((pcl mime::preview/content-list)
(p (point))
- (i (- (length fcl) 1))
- )
+ (i (- (length pcl) 1))
+ beg)
(catch 'tag
(while (>= i 0)
- (if (> p (car (nth i fcl)))
- (throw 'tag (goto-char (car (nth i fcl))))
+ (setq beg (mime::preview-content-info/point-min (nth i pcl)))
+ (if (> p beg)
+ (throw 'tag (goto-char beg))
)
(setq i (- i 1))
))
))
-(defun mime/next-content ()
+(defun mime-viewer/next-content ()
(interactive)
- (let ((fcl mime/preview-flat-content-list)
+ (let ((pcl mime::preview/content-list)
(p (point))
- )
+ beg)
(catch 'tag
- (while fcl
- (if (< p (car (car fcl)))
- (throw 'tag (goto-char (car (car fcl))))
+ (while pcl
+ (setq beg (mime::preview-content-info/point-min (car pcl)))
+ (if (< p beg)
+ (throw 'tag (goto-char beg))
)
- (setq fcl (cdr fcl))
+ (setq pcl (cdr pcl))
))
))
-(defun mime/scroll-up-content (&optional h)
+(defun mime-viewer/scroll-up-content (&optional h)
(interactive)
(if (null h)
(setq h (- (window-height) 1))
)
- (let ((fcl mime/preview-flat-content-list)
+ (let ((pcl mime::preview/content-list)
(p (point))
- np)
- (setq np (or (catch 'tag
- (while fcl
- (if (< p (car (car fcl)))
- (throw 'tag (car (car fcl)))
- )
- (setq fcl (cdr fcl))
- ))
- (point-max)))
+ np beg)
+ (setq np
+ (or (catch 'tag
+ (while pcl
+ (setq beg (mime::preview-content-info/point-min (car pcl)))
+ (if (< p beg)
+ (throw 'tag beg)
+ )
+ (setq pcl (cdr pcl))
+ ))
+ (point-max)))
(forward-line h)
(if (> (point) np)
(goto-char np)
)))
-(defun mime/scroll-down-content (&optional h)
+(defun mime-viewer/scroll-down-content (&optional h)
(interactive)
(if (null h)
(setq h (- (window-height) 1))
)
- (let ((fcl mime/preview-flat-content-list)
+ (let ((pcl mime::preview/content-list)
(p (point))
- pp)
- (setq pp (or (let ((i (- (length fcl) 1)))
- (catch 'tag
- (while (> i 0)
- (if (> p (nth 1 (nth i fcl)))
- (throw 'tag (nth 1 (nth i fcl)))
- )
- (setq i (- i 1))
- )))
- (point-min)))
+ pp beg)
+ (setq pp
+ (or (let ((i (- (length pcl) 1)))
+ (catch 'tag
+ (while (> i 0)
+ (setq beg (mime::preview-content-info/point-min
+ (nth i pcl)))
+ (if (> p beg)
+ (throw 'tag beg)
+ )
+ (setq i (- i 1))
+ )))
+ (point-min)))
(forward-line (- h))
(if (< (point) pp)
(goto-char pp)
)))
-(defun mime/next-line-content ()
+(defun mime-viewer/next-line-content ()
(interactive)
- (mime/scroll-up-content 1)
+ (mime-viewer/scroll-up-content 1)
)
-(defun mime/previous-line-content ()
+(defun mime-viewer/previous-line-content ()
(interactive)
- (mime/scroll-down-content 1)
+ (mime-viewer/scroll-down-content 1)
)
-(defun mime/quit-view-mode (&optional the-buf buf)
+(defun mime-viewer/quit (&optional the-buf buf)
(interactive)
(if (null the-buf)
(setq the-buf (current-buffer))
)
(if (null buf)
- (setq buf (nth 2 (mime/get-point-preview-content (point))))
+ (setq buf (mime::preview-content-info/buffer
+ (mime::point-preview-content (point))))
)
(let ((r (progn
(switch-to-buffer buf)
- (assoc major-mode mime/go-to-top-node-method-alist)
+ (assoc major-mode mime-viewer/quitting-method-alist)
)))
(if r
(progn
))
))
-(defun mime/exit-view-mode ()
+(defun mime-viewer/kill-buffer ()
(interactive)
(kill-buffer (current-buffer))
)