tm 7.89.
[elisp/tm.git] / tm-edit.el
index 54cda4e..da7bc8c 100644 (file)
@@ -6,7 +6,7 @@
 ;;         MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1994/08/21 renamed from mime.el
-;; Version: $Revision: 7.88 $
+;; Version: $Revision: 7.89 $
 ;; 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.88 1996/09/24 22:00:21 morioka Exp $")
+  "$Id: tm-edit.el,v 7.89 1996/10/01 13:03:50 morioka Exp $")
 
 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
 
@@ -857,13 +857,22 @@ just return to previous mode."
   "Insert a text message.
 Charset is automatically obtained from the `mime/lc-charset-alist'."
   (interactive)
-  (if (and (mime-editor/insert-tag "text" nil nil)
-          (looking-at mime-editor/single-part-tag-regexp))
+  (let ((ret (mime-editor/insert-tag "text" nil nil)))
+  (if ret
       (progn
-       ;; Make a space between the following message.
-       (insert "\n")
-       (forward-char -1)
-       )))
+       (if (looking-at mime-editor/single-part-tag-regexp)
+           (progn
+             ;; Make a space between the following message.
+             (insert "\n")
+             (forward-char -1)
+             ))
+       (if (and (member (second ret) '("enriched" "richtext"))
+                (fboundp 'enriched-mode)
+                )
+           (enriched-mode t)
+         (if (boundp 'enriched-mode)
+             (enriched-mode nil)
+           ))))))
 
 (defun mime-editor/insert-file (file)
   "Insert a message from a file."
@@ -986,6 +995,15 @@ Charset is automatically obtained from the `mime/lc-charset-alist'."
   "Insert new MIME tag and return a list of PRITYPE, SUBTYPE, and PARAMETERS.
 If nothing is inserted, return nil."
   (interactive)
+  (let ((p (point)))
+    (mime-editor/goto-tag)
+    (if (and (re-search-forward mime-editor/tag-regexp nil t)
+            (< (match-beginning 0) p)
+            (< p (match-end 0))
+            )
+       (goto-char (match-beginning 0))
+      (goto-char p)
+      ))
   (let ((oldtag nil)
        (newtag nil)
        (current (point))
@@ -1050,8 +1068,14 @@ Optional argument ENCODING specifies an encoding method such as base64."
          (progn
            (invisible-region (point-min) (point-max))
            (goto-char (point-max))
-           ))
-      )
+           )
+       (goto-char (point-max))
+       ))
+    (or hide-p
+       (looking-at mime-editor/tag-regexp)
+       (= (point)(point-max))
+       (mime-editor/insert-tag "text" "plain")
+       )
     ;; Define encoding even if it is 7bit.
     (if (stringp encoding)
        (save-excursion
@@ -1972,6 +1996,14 @@ Content-Transfer-Encoding: 7bit
                              (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")