From xemacs-m  Wed Jan 29 10:30:24 1997
Received: from mikan.jaist.ac.jp (mikan-e0.jaist.ac.jp [150.65.1.9])
          by xemacs.org (8.8.4/8.8.4) with ESMTP
	  id KAA02153 for <xemacs-beta@xemacs.org>; Wed, 29 Jan 1997 10:30:09 -0600 (CST)
Received: from is18e0s01.jaist.ac.jp (MORIOKA Tomohiko <morioka@jaist.ac.jp>) by mikan.jaist.ac.jp (8.7.5); id BAA27701; Thu, 30 Jan 1997 01:29:55 +0900 (JST)
Received: by is18e0s01.jaist.ac.jp (4.1/JE-C); Thu, 30 Jan 97 01:29:55 JST
Sender: morioka@is18e0s01.jaist.ac.jp
To: Carsten Leonhardt <leo@arioch.tng.oche.de>
Cc: xemacs-beta@xemacs.org
Subject: Re: rmail broken in 20b92 with mule
References: <m3wwsx4y02.fsf@arioch.tng.oche.de>
From: morioka@jaist.ac.jp (=?ISO-2022-JP?B?GyRCPGkyLBsoQiAbJEJDTkknGyhC?= /
 MORIOKA Tomohiko)
Organization: JAIST, Hokuriku / =?ISO-2022-JP?B?GyRCS0xOJkBoQzwySjNYGyhC?=
  =?ISO-2022-JP?B?GyRCNTs9UUJnM1gxIUJnM1gbKEI=?=
X-Emacs: Mule 3.0 =?ISO-2022-JP?B?KBskQjlITVUybBsoQik=?=
X-Mua: gnus-mime 0.14, tm-view 7.79
X-Face: %yc?f+O/cVKlH*K(H2X/6-d''suf|"1{S:Y0}_9$t@0G3:5M2:-Ck^[8+4^iSLeGc[Ey[WP
 PF]2M#Q9C'u~[=7TJP72J`PZdWvP=s-'-/LhFneC->=ILc~H#$lf2%hLL5U8?psIp`<[>d&@$Pm%~(
 A'"CJ.zuX@TXh\Ra4,b7M&`f"hexU-a4,#X\]Bfp'JI+MGUDRA%_$&UnWAem4}1R"4%uivgn;xFZ%"
 NS>)eCuFYNHc/:W^:{7H>bGQS],x5z[Cy~C;7j#:8y9q|"~9~UWjE<Vm_;)o<Q4S5NweLc(cl7-suY
 NF|_O*xodbmQavM
Mime-Version: 1.0 (generated by tm-edit 7.101)
Content-Type: multipart/signed; protocol="application/pgp-signature";
 boundary="pgp-sign-Multipart_Thu_Jan_30_01:29:34_1997-1"; micalg=pgp-md5
Content-Transfer-Encoding: 7bit
Date: 30 Jan 1997 01:29:53 +0900
In-Reply-To: Carsten Leonhardt's message of 28 Jan 1997 16:31:41 +0100
Message-Id: <s1cybdczbpa.fsf@is18e0s01.jaist.ac.jp>
Lines: 509
X-Mailer: Gnus v5.4.3/Emacs 19.34

--pgp-sign-Multipart_Thu_Jan_30_01:29:34_1997-1
Content-Type: multipart/mixed;
 boundary="Multipart_Thu_Jan_30_01:29:34_1997-1"
Content-Transfer-Encoding: 7bit

--Multipart_Thu_Jan_30_01:29:34_1997-1
Content-Type: text/plain; charset=US-ASCII

>>>>> In <m3wwsx4y02.fsf@arioch.tng.oche.de> 
>>>>>	"Carsten" = Carsten Leonhardt <leo@arioch.tng.oche.de> wrote:

Carsten> Rmail in 20.0b92 with mule uses the following functions which
Carsten> are not defined:

Carsten> code-detect-region, get-code, code-convert

Carsten> (Which means that rmail doesn't appear to be used much any
Carsten> more, or else somebody should have noticed it before...)

;; I'v pointed out to Steven and Martin, but there are no response...

  I'v tried to write "radical RMAIL", which supports MIME charset.  It
is designed for XEmacs/mule.  It is not beautiful and depended on tm
and maybe it is not complete, but if you are interested in please try
following as is.


--Multipart_Thu_Jan_30_01:29:34_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="rmail-mime.patch"
Content-Transfer-Encoding: 7bit

--- rmail.el-orig	Sun Oct 20 21:47:55 1996
+++ rmail.el	Tue Dec 10 22:16:50 1996
@@ -193,6 +193,104 @@
 		(set-buffer rmail-summary-buffer)
 		(progn (,@ body))))
 	    (rmail-maybe-display-summary))))
+
+
+;;; 1996/12/9 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
+
+;;; @ for mule and MIME
+;;;
+
+(require 'tm-view)
+
+(defconst rmail-support-mime t)
+(defvar rmail-show-mime t)
+(defvar rmail-show-mime-method (function rmail-show-mime-message))
+
+(defun rmail-show-all-header ()
+  (rmail-maybe-set-message-counters)
+  (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
+  (let ((buffer-read-only nil))
+    (goto-char (point-min))
+    (forward-line 1)
+    (if (= (following-char) ?1)
+	(progn
+	  (delete-char 1)
+	  (insert ?0)
+	  (forward-line 1)
+	  (let ((case-fold-search t))
+	    (while (looking-at "Summary-Line:\\|Mail-From:")
+	      (forward-line 1)))
+	  (insert "*** EOOH ***\n")
+	  (forward-char -1)
+	  (search-forward "\n*** EOOH ***\n")
+	  (forward-line -1)
+	  (let ((temp (point)))
+	    (and (search-forward "\n\n" nil t)
+		 (delete-region temp (point))))
+	  (goto-char (point-min))
+	  (search-forward "\n*** EOOH ***\n")
+	  (narrow-to-region (point) (point-max)))
+      )))
+
+(defun rmail-show-mime-message ()
+  (rmail-show-all-header)
+  (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 nil nil nil buf-name rmail-mode-map)
+      (or buf
+	  (setq buf (current-buffer))
+	  )
+      )
+    (set-window-buffer win buf)
+    ))
+
+(set-alist 'mime-viewer/code-converter-alist
+	   'rmail-mode
+	   (function mime-charset/decode-buffer))
+
+(set-alist 'mime-viewer/quitting-method-alist
+	   'rmail-mode
+	   (function rmail-quit)
+	   )
+
+(set-alist 'mime-viewer/over-to-previous-method-alist
+	   'rmail-mode
+	   (function
+	    (lambda ()
+	      (rmail-previous-undeleted-message 1)
+	      )))
+
+(set-alist 'mime-viewer/over-to-next-method-alist
+	   'rmail-mode
+	   (function
+	    (lambda ()
+	      (rmail-next-undeleted-message 1)
+	      )))
+
+(set-alist 'mime-viewer/show-summary-method
+	   'rmail-mode
+	   (function rmail-summary))
+
 
 ;;;; *** Rmail Mode ***
 
@@ -633,7 +731,16 @@
 (defun rmail-quit ()
   "Quit out of RMAIL."
   (interactive)
-  (rmail-expunge-and-save)
+  (if (eq major-mode 'mime/viewer-mode)
+      (let ((buf mime::preview/article-buffer)
+	    (pbuf (current-buffer))
+	    )
+	(switch-to-buffer buf)
+	(bury-buffer pbuf)
+	))
+  (let (rmail-show-mime)
+    (rmail-expunge-and-save)
+    )
   ;; Don't switch to the summary buffer even if it was recently visible.
   (if (rmail-summary-exists)
       (bury-buffer rmail-summary-buffer))
@@ -843,30 +950,33 @@
 	      ;; At first, read the file without converting coding-system.
 	      (setq size (nth 1 (let (file-coding-system-for-read)
 				  (insert-file-contents tofile))))
+	      ;; 1996/12/9 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
+	      ;;	Don't code-convert for RMAIL file
 	      ;; Then, convert the contents if necessary.
-	      (if (> size 0)
-		  (cond
-		   ((looking-at "^From ")
-		    ;; New mails.  Since the contents may be a mixture
-		    ;; of various coding-systems, we must decode one
-		    ;; mail by one.
-		    (while (null (eobp))
-		      (let ((from (point)))
-			(re-search-forward "^From " nil 'mv)
-			(rmail-decode-coding-system from (point)))))
-		   ((looking-at "BABYL OPTIONS:\\|\^L")
-		    ;; Babyl format, i.e. not a new mail.  We had better
-		    ;; not to convert large region at once.
-		    (while (null (eobp))
-		      (let ((max-size (* 1024 1024))
-			    (from (point)))
-			(goto-char (+ from max-size))
-			(re-search-forward "\^_" nil 'mv)
-			(rmail-decode-coding-system from (point)))))
-		   (t
-		    ;; Perhaps, MMDF format.  Since I don't know how to
-		    ;; deal with it, convert all data at once.
-		    (rmail-decode-coding-system (point) (point-max))))))
+              ;; (if (> size 0)
+              ;;     (cond
+              ;;      ((looking-at "^From ")
+              ;;       ;; New mails.  Since the contents may be a mixture
+              ;;       ;; of various coding-systems, we must decode one
+              ;;       ;; mail by one.
+              ;;       (while (null (eobp))
+              ;;         (let ((from (point)))
+              ;;           (re-search-forward "^From " nil 'mv)
+              ;;           (rmail-decode-coding-system from (point)))))
+              ;;      ((looking-at "BABYL OPTIONS:\\|\^L")
+              ;;       ;; Babyl format, i.e. not a new mail.  We had better
+              ;;       ;; not to convert large region at once.
+              ;;       (while (null (eobp))
+              ;;         (let ((max-size (* 1024 1024))
+              ;;               (from (point)))
+              ;;           (goto-char (+ from max-size))
+              ;;           (re-search-forward "\^_" nil 'mv)
+              ;;           (rmail-decode-coding-system from (point)))))
+              ;;      (t
+              ;;       ;; Perhaps, MMDF format.  Since I don't know how to
+              ;;       ;; deal with it, convert all data at once.
+              ;;       (rmail-decode-coding-system (point) (point-max)))))
+	      )
 	    (goto-char (point-max))
 	    (or (= (preceding-char) ?\n)
 		(zerop size)
@@ -876,35 +986,35 @@
       (setq files (cdr files)))
     delete-files))
 
-(if (not (featurep 'mule)) nil
-
-(defvar mail-coding-system '*junet*)
+;; (if (not (featurep 'mule)) nil
+;; 
+;; (defvar mail-coding-system '*junet*)
+;; 
+;; (defun rmail-decode-coding-system (from to)
+;;   (let (coding-system)
+;;     ;; At first, detect the coding-system of the region and set it to
+;;     ;; `coding-sytem'.
+;;     (let ((detected-coding-system (code-detect-region from to))
+;;           (coding (get-code mail-coding-system)))
+;;       (if (listp detected-coding-system)
+;;           ;; Something other than ASCII was found.  If a coding-system
+;;           ;; of which information is same as `mail-coding-system' is
+;;           ;; in the list of detected coding-systems, use it, else use
+;;           ;; the coding-system of the highest priority in the list.
+;;           (let ((l detected-coding-system))
+;;             (while (and l
+;;                         (null (eq (get-code (car l)) coding)))
+;;               (setq l (cdr l)))
+;;             (setq coding-system (car (or l detected-coding-system))))))
+;;     ;; Then, decode the region.
+;;     (if coding-system
+;;         (save-restriction
+;;           (narrow-to-region from to)
+;;           (code-convert from to coding-system '*internal*)
+;;           (goto-char (point-max))))))
+;; 
+;; ) ; (featurep 'mule)
 
-(defun rmail-decode-coding-system (from to)
-  (let (coding-system)
-    ;; At first, detect the coding-system of the region and set it to
-    ;; `coding-sytem'.
-    (let ((detected-coding-system (code-detect-region from to))
-	  (coding (get-code mail-coding-system)))
-      (if (listp detected-coding-system)
-	  ;; Something other than ASCII was found.  If a coding-system
-	  ;; of which information is same as `mail-coding-system' is
-	  ;; in the list of detected coding-systems, use it, else use
-	  ;; the coding-system of the highest priority in the list.
-	  (let ((l detected-coding-system))
-	    (while (and l
-			(null (eq (get-code (car l)) coding)))
-	      (setq l (cdr l)))
-	    (setq coding-system (car (or l detected-coding-system))))))
-    ;; Then, decode the region.
-    (if coding-system
-	(save-restriction
-	  (narrow-to-region from to)
-	  (code-convert from to coding-system '*internal*)
-	  (goto-char (point-max))))))
-
-) ; (featurep 'mule)
-
 ;; the  rmail-break-forwarded-messages  feature is not implemented
 (defun rmail-convert-to-babyl-format ()
   (let ((count 0) start
@@ -1184,35 +1294,43 @@
 ;; ATTR is the name of the attribute, as a string.
 ;; MSGNUM is message number to change; nil means current message.
 (defun rmail-set-attribute (attr state &optional msgnum)
-  (let ((omax (point-max-marker))
-	(omin (point-min-marker))
-	(buffer-read-only nil))
-    (or msgnum (setq msgnum rmail-current-message))
-    (if (> msgnum 0)
-	(unwind-protect
-	    (save-excursion
-	      (widen)
-	      (goto-char (+ 3 (rmail-msgbeg msgnum)))
-	      (let ((curstate
-		     (not
-		      (null (search-backward (concat ", " attr ",")
-					     (prog1 (point) (end-of-line)) t)))))
-		(or (eq curstate (not (not state)))
-		    (if curstate
-			(delete-region (point) (1- (match-end 0)))
-		      (beginning-of-line)
-		      (forward-char 2)
-		      (insert " " attr ","))))
-	      (if (string= attr "deleted")
-		  (rmail-set-message-deleted-p msgnum state)))
-	  ;; Note: we don't use save-restriction because that does not work right
-	  ;; if changes are made outside the saved restriction
-	  ;; before that restriction is restored.
-	  (narrow-to-region omin omax)
-	  (set-marker omin nil)
-	  (set-marker omax nil)
-	  (if (= msgnum rmail-current-message)
-	      (rmail-display-labels))))))
+  (let ((the-buf (current-buffer)))
+    (if (eq major-mode 'mime/viewer-mode)
+	(switch-to-buffer mime::preview/article-buffer)
+      )
+    (let ((omax (point-max-marker))
+	  (omin (point-min-marker))
+	  (buffer-read-only nil))
+      (or msgnum (setq msgnum rmail-current-message))
+      (if (> msgnum 0)
+	  (unwind-protect
+	      (save-excursion
+		(widen)
+		(goto-char (+ 3 (rmail-msgbeg msgnum)))
+		(let ((curstate
+		       (not
+			(null (search-backward (concat ", " attr ",")
+					       (prog1 (point)
+						 (end-of-line)) t)))))
+		  (or (eq curstate (not (not state)))
+		      (if curstate
+			  (delete-region (point) (1- (match-end 0)))
+			(beginning-of-line)
+			(forward-char 2)
+			(insert " " attr ","))))
+		(if (string= attr "deleted")
+		    (rmail-set-message-deleted-p msgnum state)))
+	    ;; Note: we don't use save-restriction
+	    ;;	because that does not work right
+	    ;; if changes are made outside the saved restriction
+	    ;; before that restriction is restored.
+	    (narrow-to-region omin omax)
+	    (set-marker omin nil)
+	    (set-marker omax nil)
+	    (if (= msgnum rmail-current-message)
+		(rmail-display-labels)))))
+    (switch-to-buffer the-buf)
+    ))
 
 ;; Return t if the attributes/keywords line of msg number MSG
 ;; contains a match for the regexp LABELS.
@@ -1358,6 +1476,9 @@
   "Show message number N (prefix argument), counting from start of file.
 If summary buffer is currently displayed, update current message there also."
   (interactive "p")
+  (if (eq major-mode 'mime/viewer-mode)
+      (switch-to-buffer mime::preview/article-buffer)
+    )
   (rmail-maybe-set-message-counters)
   (widen)
   (if (zerop rmail-total-messages)
@@ -1389,6 +1510,9 @@
 	  (narrow-to-region (point) end))
 	(goto-char (point-min))
 	(rmail-display-labels)
+	(if rmail-show-mime
+	    (funcall rmail-show-mime-method)
+	  )
 	(run-hooks 'rmail-show-message-hook)
 	;; If there is a summary buffer, try to move to this message
 	;; in that buffer.  But don't complain if this message
@@ -1404,6 +1528,9 @@
   "Show following message whether deleted or not.
 With prefix arg N, moves forward N messages, or backward if N is negative."
   (interactive "p")
+  (if (eq major-mode 'mime/viewer-mode)
+      (switch-to-buffer mime::preview/article-buffer)
+    )
   (rmail-maybe-set-message-counters)
   (rmail-show-message (+ rmail-current-message n)))
 
@@ -1411,7 +1538,7 @@
   "Show previous message whether deleted or not.
 With prefix arg N, moves backward N messages, or forward if N is negative."
   (interactive "p")
-  (rmail-next-message (- n)))  
+  (rmail-next-message (- n)))
 
 (defun rmail-next-undeleted-message (n)
   "Show following non-deleted message.
@@ -1420,25 +1547,30 @@
 
 Returns t if a new message is being shown, nil otherwise."
   (interactive "p")
-  (rmail-maybe-set-message-counters)
-  (let ((lastwin rmail-current-message)
-	(current rmail-current-message))
-    (while (and (> n 0) (< current rmail-total-messages))
-      (setq current (1+ current))
-      (if (not (rmail-message-deleted-p current))
-	  (setq lastwin current n (1- n))))
-    (while (and (< n 0) (> current 1))
-      (setq current (1- current))
-      (if (not (rmail-message-deleted-p current))
-	  (setq lastwin current n (1+ n))))
-    (if (/= lastwin rmail-current-message)
- 	(progn (rmail-show-message lastwin)
- 	       t)
-      (if (< n 0)
-	  (message "No previous nondeleted message"))
-      (if (> n 0)
-	  (message "No following nondeleted message"))
-      nil)))
+  (let ((the-buf (current-buffer)))
+    (if (eq major-mode 'mime/viewer-mode)
+	(switch-to-buffer mime::preview/article-buffer)
+      )
+    (rmail-maybe-set-message-counters)
+    (let ((lastwin rmail-current-message)
+	  (current rmail-current-message))
+      (while (and (> n 0) (< current rmail-total-messages))
+	(setq current (1+ current))
+	(if (not (rmail-message-deleted-p current))
+	    (setq lastwin current n (1- n))))
+      (while (and (< n 0) (> current 1))
+	(setq current (1- current))
+	(if (not (rmail-message-deleted-p current))
+	    (setq lastwin current n (1+ n))))
+      (if (/= lastwin rmail-current-message)
+	  (progn (rmail-show-message lastwin)
+		 t)
+	(if (< n 0)
+	    (message "No previous nondeleted message"))
+	(if (> n 0)
+	    (message "No following nondeleted message"))
+	(switch-to-buffer the-buf)
+	nil))))
 
 (defun rmail-previous-undeleted-message (n)
   "Show previous non-deleted message.
@@ -1743,7 +1875,12 @@
 	  (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
       (rmail-show-message
        (if (zerop rmail-current-message) 1 nil))
-      (forward-char opoint))))
+      ;; 1996/12/9 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
+      ;;	to avoid error but it is quit bad way
+      (if (> (+ (point) opoint)(point-max))
+	  (goto-char (point-max))
+	(forward-char opoint)
+	))))
 
 (defun rmail-expunge ()
   "Erase deleted messages from Rmail file and summary buffer."
--- rmailsum.el-orig	Sun Oct 20 21:48:49 1996
+++ rmailsum.el	Wed Dec 11 02:05:40 1996
@@ -141,6 +141,13 @@
 For each message, FUNCTION is applied to the message number and ARGS...
 and if the result is non-nil, that message is included.
 nil for FUNCTION means all messages."
+  (if (eq major-mode 'mime/viewer-mode)
+      (let ((buf mime::preview/article-buffer)
+	    (pbuf (current-buffer))
+	    )
+	(switch-to-buffer buf)
+	(bury-buffer pbuf)
+	))
   (message "Computing summary lines...")
   (let (sumbuf mesg was-in-summary)
     (save-excursion

--Multipart_Thu_Jan_30_01:29:34_1997-1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


  Conservative way is to rewrite following:

code-detect-region=09-> detect-coding-region
get-code=09=09-> (maybe) char-int
code-convert=09=09-> {decode|encode}-coding-region
=09:

  Thanks,
-- 
----------------------------------------------------------------------
MORIOKA Tomohiko <morioka@jaist.ac.jp>
        Japan advanced Institute of Science and Technology, Hokuriku
                Asahi-dai, Tatsu-no-kuchi ch=F4, Nomi, Ishikawa, Japan
------------------------------------------ Frisch, Frei, Fr=F6hlich! ---

--Multipart_Thu_Jan_30_01:29:34_1997-1--

--pgp-sign-Multipart_Thu_Jan_30_01:29:34_1997-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP MESSAGE-----
Version: 2.6.3ia
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBMu96/RnuUGV7wuH5AQEIPAP6ArXsXUywLGpZjjv2y7kRNnFh0EXt81DC
J46KblN1s2B8OHjanoXFD7AbG1U6c1SASxTL29qFaPicpFTJDj8INsl01/htjcWD
qnH5Rf+OXHfcjf8ElsFuUrPfxrM1Xg4rgM9mqaL+EbAhoSRUuj81yymfwfsLbSnz
iDan2cAOK+4=
=fg6k
-----END PGP MESSAGE-----

--pgp-sign-Multipart_Thu_Jan_30_01:29:34_1997-1--

