This commit was generated by cvs2svn to compensate for changes in r113,
[elisp/tm.git] / tm-comp.el
index 4bc5212..32ff347 100644 (file)
@@ -4,12 +4,17 @@
 ;;; by  MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;;; and   OKABE Yasuo    <okabe@kudpc.kyoto-u.ac.jp>
 ;;; modified by MORITA Masahiro <hiro@isl.ntt.JP>
-;;;         and MORIOKA Tomohiko
+;;;             MORIOKA Tomohiko,
+;;;      Kazushi (Jam) MARUKAWA <kazusi-m@is.aist-nara.ac.jp>,
+;;;             OKABE Yasuo,
+;;;            KOBAYASHI Shuhei <shuhei@cmpt01.phys.tohoku.ac.jp>,
+;;;         and YAMAOKA Katsumi <yamaoka@ga.sony.co.jp>
 ;;;
 
-(provide 'tm-comp)
 (require 'tm-misc)
+(require 'tm-view)
 (require 'tl-header)
+(require 'tl-list)
 (require 'mail-utils)
 
 
@@ -17,7 +22,7 @@
 ;;;
 
 (defconst mime/composer-RCS-ID
-  "$Id: tm-comp.el,v 3.3 1994/12/16 12:54:23 morioka Exp $")
+  "$Id: tm-comp.el,v 6.3 1995/04/18 16:38:42 morioka Exp $")
 
 (defconst mime/composer-version (get-version-string mime/composer-RCS-ID))
 
                          (and (fboundp 'bury-buffer) (bury-buffer))))
     ))
 
+(defvar tm-comp/message-inserter-alist nil)
+
 
 ;;; @ edit
 ;;;
@@ -187,9 +194,12 @@ Optional argument ENCODING specifies an encoding method such as base64."
            (file-coding-system-for-read
             (if (featurep 'mule) *noconv*))
            (kanji-flag nil))           ;NEmacs
-       (insert-file-contents file)))
+       (let (jka-compr-compression-info-list
+             jam-zcat-filename-list)
+         (insert-file-contents file))))
     (prog1
-       (if (string-equal (downcase encoding) "x-uue")
+       (if (and (stringp encoding)
+                (string-equal (downcase encoding) "x-uue"))
            (let ((mime-transfer-encoders
                   (copy-alist (cons (list "x-uue" "uuencode"
                                           (file-name-nondirectory file))
@@ -232,6 +242,18 @@ Optional argument ENCODING specifies an encoding method such as base64."
     ))
 
 
+(defun tm-comp/insert-message (&optional message)
+  (interactive)
+  (let ((inserter (assoc-value major-mode tm-comp/message-inserter-alist)))
+    (if (and inserter (fboundp inserter))
+       (progn
+         (mime-insert-tag "message" "rfc822")
+         (funcall inserter message)
+         )
+      (message "Sorry, I don't have message inserter for your MUA.")
+      )))
+
+
 ;;; @ split
 ;;;
 
@@ -365,15 +387,70 @@ Optional argument ENCODING specifies an encoding method such as base64."
                   (fset 'mime-mode-exit-and-run
                         'tm-comp::mime-mode-exit-and-run)
                   ))
+            (define-key (lookup-key (current-local-map) mime-prefix)
+              "m" 'tm-comp/insert-message)
             )))
 
-(autoload 'mime/viewer-mode "tm-view" nil t)
+
+;;; @ draft preview
+;;; 
+;; by "OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
+;;      Mon, 10 Apr 1995 20:03:07 +0900
+
+(defvar mime/draft-header-separator-alist
+  '((news-reply-mode . mail-header-separator)
+    (mh-letter-mode . mail-header-separator)
+    ))
+
+(defvar mime::article/draft-header-separator nil)
 
 (defun mime/draft-preview ()
   (interactive)
-  (goto-char (point-min))
-  (mime/viewer-mode)
-  (pop-to-buffer (current-buffer)))
+  (let ((sep (assoc-value major-mode mime/draft-header-separator-alist)))
+    (or (stringp sep) (setq sep (eval sep)))
+    (make-variable-buffer-local 'mime::article/draft-header-separator)
+    (goto-char (point-min))
+    (re-search-forward
+     (concat "^\\(" (regexp-quote sep) "\\)?$"))
+    (setq mime::article/draft-header-separator
+         (buffer-substring (match-beginning 0) (match-end 0)))
+    (replace-match "")
+    (mime/viewer-mode (current-buffer))
+    (pop-to-buffer (current-buffer))
+    ))
+
+(defun mime-viewer::quitting-method/draft-preview ()
+  (let ((mother mime/mother-buffer))
+    (save-excursion
+      (switch-to-buffer mother)
+      (goto-char (point-min))
+      (if (and
+          (re-search-forward
+           (concat "^\\("
+                   (regexp-quote mime::article/draft-header-separator)
+                   "\\)?$") nil t)
+          (bolp))
+         (progn
+           (insert mime::article/draft-header-separator)
+           (set-buffer-modified-p (buffer-modified-p))
+           )))
+    (mime-viewer/kill-buffer)
+    (pop-to-buffer mother)
+    ))
+
+(set-alist 'mime-viewer/quitting-method-alist
+          'mh-letter-mode
+          (function mime-viewer::quitting-method/draft-preview)
+          )
+
+(set-alist 'mime-viewer/quitting-method-alist
+          'news-reply-mode
+          (function mime-viewer::quitting-method/draft-preview)
+          )
+
+
+;;; @ etc
+;;;
 
 (defun message/get-header-string-except (pat boundary)
   (save-excursion
@@ -405,3 +482,8 @@ Optional argument ENCODING specifies an encoding method such as base64."
                     ?_
                   arg)))) str "")
   )
+
+
+(run-hooks 'tm-comp-load-hook)
+
+(provide 'tm-comp)