;;;
(defconst mime-viewer/RCS-ID
- "$Id: tm-view.el,v 6.16 1995/04/19 04:43:09 morioka Exp $")
+ "$Id: tm-view.el,v 6.18 1995/04/23 15:51:19 morioka Exp $")
(defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
(defconst mime/viewer-version mime-viewer/version)
;; 'file '"access-type" '"name" '"site" '"directory"))
((type . "message/partial")
(method . mime/decode-message/partial-region))
+ ((type . "message/rfc822")
+ (method "tm-file" nil 'file 'type 'encoding 'mode 'name))
((method "metamail" t
"-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
))
(defun mime-viewer/parse (&optional ctl encoding)
(save-excursion
(save-restriction
- (if (null ctl)
- (setq ctl (progn
- (goto-char (point-min))
- (mime/Content-Type)
- ))
- )
- (if (null encoding)
- (setq encoding (progn
- (goto-char (point-min))
- (mime/Content-Transfer-Encoding)
- ))
- )
+ (setq ctl (or (mime/Content-Type)
+ ctl))
+ (setq encoding (or (mime/Content-Transfer-Encoding)
+ 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)))
+ (goto-char (point-min))
(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)
- )
+ (save-excursion
+ (save-restriction
+ (setq boundary
+ (message/strip-quoted-string (cdr boundary)))
+ (narrow-to-region
+ (point-min)
+ (if (search-forward (concat "--" boundary "--\n") nil t)
+ (match-beginning 0)
+ (point-max)
+ ))
+ (mime-viewer/parse-multipart
+ (point-min)
+ (point-max)
+ 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))
+ (narrow-to-region (progn
+ (goto-char (point-min))
+ (if (re-search-forward "^$" nil t)
+ (+ (match-end 0) 1)
+ (point-min)
+ ))
+ (point-max))
(list (mime-viewer/parse))
))
)
)))))
(defun mime-viewer/parse-multipart (beg end boundary ctype params encoding)
- (let ((sep (concat "^--" boundary "$"))
+ (let ((sep (concat "^--" (regexp-quote boundary) "$"))
cb ce ct ret ncb children)
(save-excursion
(save-restriction
(save-excursion
(save-restriction
(narrow-to-region cb ce)
- (setq ret (mime-viewer/parse))
+ (setq ret (apply (function mime-viewer/parse)
+ (cond ((string= ctype "multipart/mixed")
+ '(("text/plain") "7bit")
+ )
+ ((string= ctype "multipart/digest")
+ '(("message/rfc822") "7bit")
+ ))
+ ))
))
(setq children (nconc children (list ret)))
(goto-char (mime::content-info/point-max ret))
(save-excursion
(save-restriction
(narrow-to-region cb ce)
- (setq ret (mime-viewer/parse))
+ (setq ret (apply (function mime-viewer/parse)
+ (cond ((string= ctype "multipart/mixed")
+ '(("text/plain") "7bit")
+ )
+ ((string= ctype "multipart/digest")
+ '(("message/rfc822") "7bit")
+ ))
+ ))
))
(setq children (nconc children (list ret)))
))
)))
(defun mime/Content-Transfer-Encoding (&optional default-encoding)
- (save-excursion
- (save-restriction
- (if (and (re-search-forward "^Content-Transfer-Encoding:[ \t]*" nil t)
- (re-search-forward mime/token-regexp nil t)
- )
- (downcase (buffer-substring (match-beginning 0) (match-end 0)))
- default-encoding)
- )))
+ (let ((str (message/get-field-body "Content-Transfer-Encoding")))
+ (if str
+ (downcase str)
+ default-encoding)
+ ))
(defun mime/get-subject (param)
(save-excursion
(save-excursion
(save-restriction
(goto-char beg)
- (search-forward "\n\n" nil t)
- (match-end 0)
+ (re-search-forward "^$" nil t)
+ (+ (match-end 0) 1)
))
end))
(if (> e (point-max))
b args)
(if (nth 1 method)
(setq b beg)
- (search-forward "\n\n" nil t)
- (setq b (match-end 0))
+ (setq b
+ (if (re-search-forward "^$" nil t)
+ (+ (match-end 0) 1)
+ (point-min)
+ ))
)
(goto-char b)
(write-region b end file)
)
(defun mime::article/decode-content-region (cinfo)
- (interactive "*r")
(let ((beg (mime::content-info/point-min cinfo))
(end (mime::content-info/point-max cinfo))
(ctype (mime::content-info/type cinfo))