+ (if (= end (point-max))
+ nil
+ (goto-char end)
+ (or (looking-at mime-editor/beginning-tag-regexp)
+ (eobp)
+ (insert (mime-make-text-tag) "\n")
+ ))
+ (visible-region beg end)
+ (goto-char beg)
+ )
+ (cond
+ ((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 (if charset
+ (intern (downcase 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))
+ )
+ ;; Patch for hard newlines
+ ;; (save-excursion
+ ;; (goto-char beg)
+ ;; (while (search-forward "\n" end t)
+ ;; (put-text-property (match-beginning 0)
+ ;; (point)
+ ;; 'hard t)))
+ ;; End patch for hard newlines
+ (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
+ (assq charset
+ mime-editor/charset-default-encoding-alist)
+ ))
+ (beg (mime-editor/content-beginning))
+ )
+ (encode-mime-charset-region beg (mime-editor/content-end)
+ charset)
+ (mime-encode-region beg (mime-editor/content-end) encoding)
+ (mime-editor/define-encoding encoding)
+ ))
+ (goto-char (mime-editor/content-end))
+ )
+ ((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 beg end encoding)
+ (mime-editor/define-encoding encoding))
+ (forward-line 1)
+ ))