This commit was generated by cvs2svn to compensate for changes in r434,
[elisp/tm.git] / tm-rmail.el
index 1099108..24f4971 100644 (file)
@@ -1,12 +1,12 @@
 ;;;
 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
-;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
+;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
 ;;;
 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;;; modified by KOBAYASHI Shuhei <shuhei@cmpt01.phys.tohoku.ac.jp>
+;;; modified by KOBAYASHI Shuhei <shuhei-k@jaist.ac.jp>
 ;;; Created: 1994/8/30
 ;;; Version:
-;;;    $Revision: 7.20 $
+;;;    $Revision: 7.25 $
 ;;; Keywords: mail, MIME, multimedia, multilingual, encoded-word
 ;;;
 ;;; This file is part of tm (Tools for MIME).
@@ -40,7 +40,7 @@
 ;;;
 
 (defconst tm-rmail/RCS-ID
-  "$Id: tm-rmail.el,v 7.20 1995/12/15 13:56:51 morioka Exp $")
+  "$Id: tm-rmail.el,v 7.25 1996/06/12 05:38:23 morioka Exp $")
 (defconst tm-rmail/version (get-version-string tm-rmail/RCS-ID))
 
 (defvar tm-rmail/decode-all nil)
 (defun tm-rmail/preview-message ()
   (interactive)
   (setq tm-rmail/decode-all t)
-  (let ((ret (rmail-widen-to-current-msgbeg
-             (function
-              (lambda ()
-                (cons (mime/Content-Type)
-                      (mime/Content-Transfer-Encoding "7bit")
-                      )
-                )))))
+  (let ((ret (tm-rmail/get-Content-Type-and-Content-Transfer-Encoding)))
     (narrow-to-region (point-min)
                      (save-excursion
                        (goto-char (point-max))
                            (match-beginning 0)
                          (point-max)
                          )))
-    (mime/viewer-mode nil (car ret)(cdr ret) nil
-                     (format "*Preview-%s [%d/%d]*"
-                             (buffer-name)
-                             rmail-current-message rmail-total-messages))
-    ))
+    (let ((abuf (current-buffer))
+         (buf-name (format "*Preview-%s [%d/%d]*"
+                           (buffer-name)
+                           rmail-current-message rmail-total-messages))
+         buf win)
+      (if (and mime::article/preview-buffer
+                (setq buf (get-buffer mime::article/preview-buffer))
+                )
+         (progn
+           (save-excursion
+             (set-buffer buf)
+             (rename-buffer buf-name)
+             )
+           (if (setq win (get-buffer-window buf))
+               (progn
+                 (delete-window (get-buffer-window abuf))
+                 (set-window-buffer win abuf)
+                 (set-buffer abuf)
+                 ))
+           ))
+      (setq win (get-buffer-window abuf))
+      (save-window-excursion
+       (mime/viewer-mode nil (car ret)(cdr ret) nil buf-name)
+       (or buf
+           (setq buf (current-buffer))
+           )
+       )
+      (set-window-buffer win buf)
+      )))
 
 (defun tm-rmail/preview-message-if-you-need ()
   (if tm-rmail/decode-all
 
 (add-hook 'rmail-show-message-hook 'tm-rmail/preview-message-if-you-need)
 
+(cond ((fboundp 'rmail-summary-rmail-update)
+       ;; for Emacs 19 or later
+       (or (fboundp 'tm:rmail-summary-rmail-update)
+          (fset 'tm:rmail-summary-rmail-update
+                (symbol-function 'rmail-summary-rmail-update))
+          )
+       
+       (defun rmail-summary-rmail-update ()
+        (tm:rmail-summary-rmail-update)
+        (if tm-rmail/decode-all
+            (let ((win (get-buffer-window rmail-buffer)))
+              (if win
+                  (delete-window win)
+                )))
+        )
+       
+       (defun tm-rmail/get-Content-Type-and-Content-Transfer-Encoding ()
+        (rmail-widen-to-current-msgbeg
+         (function
+          (lambda ()
+            (cons (mime/Content-Type)
+                  (mime/Content-Transfer-Encoding "7bit")
+                  )))))
+       )
+      (t
+       ;; for Emacs 18
+       (defun tm-rmail/get-Content-Type-and-Content-Transfer-Encoding ()
+        (save-restriction
+          (rmail-widen-to-current-msgbeg
+           (function
+            (lambda ()
+              (goto-char (point-min))
+              (narrow-to-region (or (and (re-search-forward "^.+:" nil t)
+                                         (match-beginning 0))
+                                    (point-min))
+                                (point-max))
+              )))
+          (cons (mime/Content-Type)
+                (mime/Content-Transfer-Encoding "7bit")
+                )))
+       ))
+
 (define-key rmail-mode-map "v" (function tm-rmail/preview-message))
 
 (defun tm-rmail/setup ()
   (local-set-key "v" (function
                      (lambda ()
                        (interactive)
-                       (pop-to-buffer rmail-buffer)
+                       (set-buffer rmail-buffer)
                        (tm-rmail/preview-message)
                        )))
   )
     )
   )
 
+(defun tm-rmail/show-summary-method ()
+  (save-excursion
+    (set-buffer mime::preview/article-buffer)
+    (rmail-summary)
+    ))
+
 (call-after-loaded
  'tm-view
  (function
     (set-alist 'mime-viewer/over-to-next-method-alist
               'rmail-mode
               (function tm-rmail/over-to-next-method))
+
+    (set-alist 'mime-viewer/show-summary-method
+              'rmail-mode
+              (function tm-rmail/show-summary-method))
     )))
 
 
@@ -287,13 +357,32 @@ GNUS. The message will be appended if being composed."
        (require 'tm-mail)
        (set-alist 'mime-editor/message-inserter-alist
                   'mail-mode (function tm-mail/insert-message))
+       (set-alist 'mime-editor/split-message-sender-alist
+                  'mail-mode (function
+                              (lambda ()
+                                (interactive)
+                                (sendmail-send-it)
+                                )))
        )))
     )))
 
 
+;;; @ for BBDB
+;;;
+
+(call-after-loaded
+ 'bbdb
+ (function
+  (lambda ()
+    (require 'tm-bbdb)
+    )))
+
+
 ;;; @ end
 ;;;
 
 (provide 'tm-rmail)
 
 (run-hooks 'tm-rmail-load-hook)
+
+;;; tm-rmail.el ends here.