- (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)
- (if (string-equal contype "text/x-rot13-47")
- (save-excursion
- (forward-line)
- (set-mark (point))
- (goto-char (mime-editor/content-end))
- (tm:caesar-region)
- ))
- ;; 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))
- (end (mime-editor/content-end))
- (body (buffer-substring beg end))
- (encoded (mime-editor/encode-string
- (cons charset encoding) body))
- )
- (if (not (string-equal body encoded))
- (progn
- (goto-char beg)
- (delete-region beg end)
- (insert encoded)
- (goto-char beg)))
- (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))
- (encoded (mime-editor/encode-string
- (cons nil encoding) body))
- )
- (if (not (string-equal body encoded))
- (progn
- (goto-char beg)
- (delete-region beg end)
- (insert encoded)
- (goto-char beg)))
- (mime-editor/define-encoding encoding))
- (forward-line 1))