;;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Created: 1994/08/21 renamed from mime.el
-;;; Version: $Revision: 7.56 $
+;;; Version: $Revision: 7.59 $
;;; Keywords: mail, news, MIME, multimedia, multilingual
;;;
;;; This file is part of tm (Tools for MIME).
;;;
(defconst mime-editor/RCS-ID
- "$Id: tm-edit.el,v 7.56 1996/05/05 16:40:31 morioka Exp $")
+ "$Id: tm-edit.el,v 7.59 1996/05/09 18:40:11 morioka Exp $")
(defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
(reverse mime-editor/menu-list)
))
-;;; modified by Pekka Marjola <pema@niksula.hut.fi>
+;;; modified by Pekka Marjola <pema@iki.fi>
;;; 1995/9/5 (c.f. [tm-en:69])
(defun mime-editor/define-menu-for-xemacs ()
"Define menu for Emacs 19."
;; Define menu. Menus for other emacs implementations are
;; welcome.
- ;; modified by Pekka Marjola <pema@niksula.hut.fi>
- ;; 1995/9/5 (c.f. [tm-eng:69])
(cond (running-xemacs
(mime-editor/define-menu-for-xemacs))
- ((string-match "^19\\." emacs-version)
+ ((>= emacs-major-version 19)
(mime-editor/define-menu-for-emacs19)
))
;; end
;; Remove extra whitespaces after the tag.
(if (looking-at "[ \t]+$")
(delete-region (match-beginning 0) (match-end 0)))
- (cond ((= (following-char) ?\^M)
- ;; It must be image, audio or video.
- (let ((beg (point))
- (end (mime-editor/content-end)))
- ;; Insert explicit MIME tags after hidden messages.
- (forward-line 1)
- (if (and (not (eobp))
- (not (looking-at mime-editor/single-part-tag-regexp)))
- (progn
- (insert (mime-make-text-tag) "\n")
- (forward-line -1) ;Process it again as text.
+ (cond
+ ((= (following-char) ?\^M)
+ ;; It must be image, audio or video.
+ (let ((beg (point))
+ (end (mime-editor/content-end)))
+ ;; Insert explicit MIME tags after hidden messages.
+ (forward-line 1)
+ (if (and (not (eobp))
+ (not (looking-at mime-editor/single-part-tag-regexp)))
+ (progn
+ (insert (mime-make-text-tag) "\n")
+ (forward-line -1) ;Process it again as text.
+ ))
+ ;; Show a hidden message. The point is not altered
+ ;; after the conversion.
+ (mime-flag-region beg end ?\n)
+ ))
+ ((mime-test-content-type contype "message")
+ ;; Content-type "message" should be sent as is.
+ (forward-line 1)
+ )
+ ((mime-test-content-type contype "text")
+ ;; Define charset for text if necessary.
+ (setq charset (or charset (mime-editor/choose-charset)))
+ (mime-editor/define-charset charset)
+ (cond ((string-equal contype "text/x-rot13-47")
+ (save-excursion
+ (forward-line)
+ (set-mark (point))
+ (goto-char (mime-editor/content-end))
+ (tm:caesar-region)
+ ))
+ ((string-equal contype "text/enriched")
+ (save-excursion
+ (let ((beg (progn
+ (forward-line)
+ (point)))
+ (end (mime-editor/content-end))
+ )
+ (enriched-encode beg end)
+ (goto-char beg)
+ (if (search-forward "\n\n")
+ (delete-region beg (match-end 0))
+ )
+ ))))
+ ;; Point is now on current tag.
+ ;; Define encoding and encode text if necessary.
+ (or encoding ;Encoding is not specified.
+ (let* ((encoding
+ (cdr
+ (assoc charset
+ mime-editor/charset-default-encoding-alist)
))
- ;; Show a hidden message. The point is not altered
- ;; after the conversion.
- (mime-flag-region beg end ?\n)))
- ((mime-test-content-type contype "message")
- ;; Content-type "message" should be sent as is.
- (forward-line 1))
- ((mime-test-content-type contype "text")
- ;; Define charset for text if necessary.
- (setq charset (or charset (mime-editor/choose-charset)))
- (mime-editor/define-charset charset)
- (cond ((string-equal contype "text/x-rot13-47")
- (save-excursion
- (forward-line)
- (set-mark (point))
- (goto-char (mime-editor/content-end))
- (tm:caesar-region)
- ))
- ((string-equal contype "text/enriched")
- (save-excursion
- (let ((beg (progn
- (forward-line)
- (point)))
- (end (mime-editor/content-end))
- )
- (enriched-encode beg end)
- (goto-char beg)
- (if (search-forward "\n\n")
- (delete-region beg (match-end 0))
- )
- ))))
- ;; Point is now on current tag.
- ;; Define encoding and encode text if necessary.
- (if (null encoding) ;Encoding is not specified.
- (let* ((encoding
- (cdr
- (assoc charset
- mime-editor/charset-default-encoding-alist)
- ))
- (beg (mime-editor/content-beginning))
- )
- (mime/code-convert-region-from-emacs
- beg (mime-editor/content-end) charset)
- (mime-encode-region encoding
- beg (mime-editor/content-end))
- (mime-editor/define-encoding encoding)))
- (forward-line 1))
- ((null encoding) ;Encoding is not specified.
- ;; Application, image, audio, video, and any other
- ;; unknown content-type without encoding should be
- ;; encoded.
- (let* ((encoding "base64") ;Encode in BASE64 by default.
- (beg (mime-editor/content-beginning))
- (end (mime-editor/content-end))
- (body (buffer-substring beg end))
- )
- (mime-encode-region encoding beg end)
- (mime-editor/define-encoding encoding))
- (forward-line 1))
- )
+ (beg (mime-editor/content-beginning))
+ )
+ (mime-charset-encode-region beg (mime-editor/content-end)
+ charset)
+ (mime-encode-region encoding beg (mime-editor/content-end))
+ (mime-editor/define-encoding encoding)
+ ))
+ (forward-line 1)
+ )
+ ((null encoding) ;Encoding is not specified.
+ ;; Application, image, audio, video, and any other
+ ;; unknown content-type without encoding should be
+ ;; encoded.
+ (let* ((encoding "base64") ;Encode in BASE64 by default.
+ (beg (mime-editor/content-beginning))
+ (end (mime-editor/content-end))
+ (body (buffer-substring beg end))
+ )
+ (mime-encode-region encoding beg end)
+ (mime-editor/define-encoding encoding))
+ (forward-line 1)
+ )
+ )
)))
(defun mime-delete-field (field)
)
(setq type ctype)
)
- (cond ((string-equal type "multipart")
- (let ((boundary (assoc-value "boundary" params)))
- (re-search-forward (concat "\n--" boundary) nil t)
- (let ((bb (match-beginning 0)) eb tag)
- (setq tag (format "\n--<<%s>>-{" stype))
- (goto-char bb)
- (insert tag)
- (setq bb (+ bb (length tag)))
- (re-search-forward (concat "\n--" boundary "--") nil t)
- (setq eb (match-beginning 0))
- (replace-match (format "\n--}-<<%s>>" stype))
- (save-restriction
- (narrow-to-region bb eb)
- (goto-char (point-min))
- (while (re-search-forward
- (concat "\n--" boundary "\n") nil t)
- (let ((beg (match-beginning 0))
- end)
- (delete-region beg (match-end 0))
- (save-excursion
- (if (re-search-forward
- (concat "\n--" boundary) nil t)
- (setq end (match-beginning 0))
- (setq end (point-max))
- )
- (save-restriction
- (narrow-to-region beg end)
- (mime-editor::edit-again code-conversion)
- (goto-char (point-max))
- ))))
- ))
- (goto-char (point-min))
- (or (= (point-min) 1)
- (delete-region (point-min)
- (if (re-search-forward "^$" nil t)
- (match-end 0)
- (point-min)
- )))
- ))
- (t
- (let* ((str (rfc822/get-header-string-except
- "^Content-Type" ""))
- charset
- (pstr
- (mapconcat (function
- (lambda (attr)
- (if (string-equal (car attr)
- "charset")
- (progn
- (setq charset (cdr attr))
- "")
- (concat ";" (car attr)
- "=" (cdr attr))
- )
- ))
- params ""))
- )
- (if code-conversion
- (if charset
- (mime/code-convert-region-to-emacs
- (point-min) (point-max) charset)
- (decode-coding-region
- (point-min) (point-max)
- mime/default-coding-system)
- ))
- (and str
- (setq pstr (concat pstr "\n" str))
- )
- (let ((he
- (if (re-search-forward "^$" nil t)
- (match-end 0)
- (point-min)
- )))
- (if (= (point-min) 1)
- (progn
- (goto-char he)
- (insert
- (concat
- "\n"
- (mime-create-tag (concat type "/" stype))
- ))
- )
- (delete-region (point-min) he)
- (insert
- (concat "\n" (mime-create-tag
- (concat type "/" stype pstr))))
- ))
- ))))
+ (cond
+ ((string-equal type "multipart")
+ (let ((boundary (assoc-value "boundary" params)))
+ (re-search-forward (concat "\n--" boundary) nil t)
+ (let ((bb (match-beginning 0)) eb tag)
+ (setq tag (format "\n--<<%s>>-{" stype))
+ (goto-char bb)
+ (insert tag)
+ (setq bb (+ bb (length tag)))
+ (re-search-forward (concat "\n--" boundary "--") nil t)
+ (setq eb (match-beginning 0))
+ (replace-match (format "\n--}-<<%s>>" stype))
+ (save-restriction
+ (narrow-to-region bb eb)
+ (goto-char (point-min))
+ (while (re-search-forward
+ (concat "\n--" boundary "\n") nil t)
+ (let ((beg (match-beginning 0))
+ end)
+ (delete-region beg (match-end 0))
+ (save-excursion
+ (if (re-search-forward
+ (concat "\n--" boundary) nil t)
+ (setq end (match-beginning 0))
+ (setq end (point-max))
+ )
+ (save-restriction
+ (narrow-to-region beg end)
+ (mime-editor::edit-again code-conversion)
+ (goto-char (point-max))
+ ))))
+ ))
+ (goto-char (point-min))
+ (or (= (point-min) 1)
+ (delete-region (point-min)
+ (if (re-search-forward "^$" nil t)
+ (match-end 0)
+ (point-min)
+ )))
+ ))
+ (t
+ (let* ((str (rfc822/get-header-string-except
+ "^Content-Type" ""))
+ charset
+ (pstr
+ (mapconcat (function
+ (lambda (attr)
+ (if (string-equal (car attr)
+ "charset")
+ (progn
+ (setq charset (cdr attr))
+ "")
+ (concat ";" (car attr)
+ "=" (cdr attr))
+ )
+ ))
+ params ""))
+ )
+ (if code-conversion
+ (if charset
+ (mime-charset-decode-region (point-min)(point-max)
+ charset)
+ (character-decode-region (point-min)(point-max)
+ mime/default-coding-system)
+ ))
+ (and str
+ (setq pstr (concat pstr "\n" str))
+ )
+ (let ((he
+ (if (re-search-forward "^$" nil t)
+ (match-end 0)
+ (point-min)
+ )))
+ (if (= (point-min) 1)
+ (progn
+ (goto-char he)
+ (insert
+ (concat
+ "\n"
+ (mime-create-tag (concat type "/" stype))
+ ))
+ )
+ (delete-region (point-min) he)
+ (insert
+ (concat "\n" (mime-create-tag
+ (concat type "/" stype pstr))))
+ ))
+ ))))
(if code-conversion
(decode-coding-region (point-min) (point-max)
mime/default-coding-system)