RCS file: RCS/mew.el,v
retrieving revision 1.1
diff -u -r1.1 mew.el
--- mew.el	1996/10/01 11:24:26	1.1
+++ mew.el	1996/10/09 08:19:18
@@ -25,7 +25,8 @@
 
 (defvar mew-emacs18-p (string-match "^18" emacs-version))
 (defvar mew-emacs19-p (string< "19" emacs-version))
-(defvar mew-mule-p    (boundp 'MULE))
+(defvar mew-mule-p    (featurep 'mule))
+(defvar mew-mule24-p   (and mew-mule-p (string< "2.4" mule-version)))
 (defvar mew-xemacs-p  (string-match "XEmacs\\|Lucid" emacs-version))
 (defvar mew-os2-p     nil)
 
@@ -256,6 +257,13 @@
 ;; Character code
 
 (cond
+ (mew-mule24-p
+  ;; Set your local charset
+  (defvar mew-mule-charset-local     'coding-system-iso-2022-jp)
+  (defvar mew-mule-charset-integrity 'coding-system-iso-2022-jp)
+  (defvar mew-mule-charset-virtual   'coding-system-iso-2022-int-unix)
+  ;; include ^M as it is.
+  )
  (mew-mule-p
   (defvar mew-mule-charset-local     *iso-2022-jp*) ;; Set your local charset
   (defvar mew-mule-charset-integrity *iso-2022-jp*)
@@ -616,8 +624,38 @@
 ;;;
 ;;;
 
-(if mew-mule-p
-    (defvar mew-mule-character-set
+(cond
+ (mew-mule24-p
+  (defvar mew-mule-character-set
+    (list
+     (if (coding-system-p 'coding-system-iso-8859-1)
+	 (list charset-latin-1  'coding-system-iso-8859-1 "iso-8859-1"))
+     (if (coding-system-p 'coding-system-iso-8859-2)
+	 (list charset-latin-2  'coding-system-iso-8859-2 "iso-8859-2"))
+     (if (coding-system-p 'coding-system-iso-8859-3)
+	 (list charset-latin-3  'coding-system-iso-8859-3 "iso-8859-3"))
+     (if (coding-system-p 'coding-system-iso-8859-4)
+	 (list charset-latin-4  'coding-system-iso-8859-4 "iso-8859-4"))
+     (if (coding-system-p 'coding-system-iso-8859-5)
+	 (list charset-cyrillic 'coding-system-iso-8859-5 "iso-8859-5"))
+     (if (coding-system-p 'coding-system-iso-8859-6)
+	 (list charset-arabic   'coding-system-iso-8859-6 "iso-8859-6"))
+     (if (coding-system-p 'coding-system-iso-8859-7)
+	 (list charset-greek    'coding-system-iso-8859-7 "iso-8859-7"))
+     (if (coding-system-p 'coding-system-iso-8859-8)
+	 (list charset-hebrew   'coding-system-iso-8859-8 "iso-8859-8"))
+     (if (coding-system-p 'coding-system-iso-8859-9)
+	 (list charset-latin-5  'coding-system-iso-8859-9 "iso-8859-9"))
+     (if (coding-system-p 'coding-system-iso-2022-jp)
+	 (list charset-japanese-jisx0208 'coding-system-iso-2022-jp "iso-2022-jp"))
+     (if (coding-system-p 'coding-system-iso-2022-kr)
+	 (list charset-korean-ksc5601 'coding-system-iso-2022-kr "iso-2022-kr"))
+     (if (coding-system-p 'coding-system-iso-2022-ss2-7)
+	 (list t              'coding-system-iso-2022-ss2-7 "iso-2022-jp-2"))
+     )))
+ 
+ (mew-mule-p
+     (defvar mew-mule-character-set
       (list 
        (if (boundp '*iso-8859-1*)	;; Latin-1
 	   (list lc-ltn1	*iso-8859-1*		"iso-8859-1")
@@ -650,6 +688,7 @@
        )
       )
   )
+ )
 
 (defmacro mew-mule-lc-attr (lc alist)
   (` (mew-assoc (, lc) (, alist) 0 nil)))
@@ -1274,6 +1313,16 @@
   )
 
 (cond 
+ (mew-mule24-p
+  (set-coding-system-alist mew-prog-inc  'start-process mew-mule-charset-local)
+  (set-coding-system-alist mew-prog-scan 'start-process mew-mule-charset-local)
+  (set-coding-system-alist mew-prog-send 'start-process mew-mule-charset-local)
+  (set-coding-system-alist mew-prog-send 'call-process  mew-mule-charset-local)
+  (set-coding-system-alist mew-prog-mime-encode 'call-process 'no-conversion)
+  (set-coding-system-alist mew-prog-mime-decode 'call-process 'no-conversion)
+  (set-coding-system-alist mew-prog-vscan
+			   'start-process mew-mule-charset-local)
+  )
  (mew-mule-p
   (define-program-coding-system nil mew-prog-inc  mew-mule-charset-local)
   (define-program-coding-system nil mew-prog-scan mew-mule-charset-local)
@@ -3491,7 +3540,9 @@
 	  (let ((pro nil)
 		(tmp (make-temp-name mew-temp-file))
 		(mc-flag nil)
-		(file-coding-system (if mew-mule-p *noconv*)))
+		(file-coding-system (if (and mew-mule-p (not mew-mule24-p))
+					*noconv*))
+		(coding-system-for-write (if mew-mule24-p 'no-conversion)))
 	    (write-region begin end tmp)
 	    (message "Starting %s ..." program)
 	    (setq pro (apply (function start-process)
@@ -3518,7 +3569,8 @@
   (if (mew-which program exec-path)
       (if (mew-y-or-n-p (format "Call %s? " program))
 	  (let ((mc-flag nil)
-		(file-coding-system (if mew-mule-p *noconv*)))
+		(file-coding-system
+		 (if (and mew-mule-p (not mew-mule24-p)) *noconv*)))
 	    (message "Calling %s ..." program)
 	    (apply (function call-process-region) 
 		   begin end program nil nil nil options)
@@ -4437,20 +4489,38 @@
 	      (set-buffer (get-buffer-create mew-buffer-tmp))
 	      (widen)
 	      (erase-buffer)
-	      (let ((mc-flag nil)
-		    (file-coding-system-for-read (if mew-mule-p *noconv*))
-		    (file-coding-system (if mew-mule-p *noconv*)))
+	      (cond
+	       (mew-mule24-p
+		(let ((coding-system-for-read 'no-conversion)
+		      (coding-system-for-write 'no-conversion))
+		  (insert-file-contents (mew-expand-file-name msg cbuf))
+		  (if (and user-coding-system (not append-p))
+		      (progn
+			(decode-coding-region (point-min) (point-max)
+					      'automatic-conversion)
+			(encode-coding-region (point-min) (point-max)
+					      user-coding-system)))
+		  (write-region (point-min) (point-max) file append-p nil nil))
+		)
+	       (mew-mule-p
+		(let ((mc-flag nil)
+		      (file-coding-system-for-read *noconv*)
+		      (file-coding-system *noconv*))
+		  (insert-file-contents (mew-expand-file-name msg cbuf))
+		  (if (and user-coding-system (not append-p))
+		      (progn
+			(if (stringp user-coding-system)  ;; for mule 1.x
+			    (setq user-coding-system
+				  (intern-soft user-coding-system)))
+			(code-convert-region (point-min) (point-max)
+					     *autoconv* *internal*)
+			(code-convert-region (point-min) (point-max)
+					     *internal* user-coding-system)))
+		  (write-region (point-min) (point-max) file append-p nil nil))
+		)
+	       (t
 		(insert-file-contents (mew-expand-file-name msg cbuf))
-		(if (and mew-mule-p user-coding-system (not append-p))
-		    (progn
-		      (if (stringp user-coding-system)  ;; for mule 1.x
-			  (setq user-coding-system
-				(intern-soft user-coding-system)))
-		      (code-convert-region (point-min) (point-max)
-					   *autoconv* *internal*)
-		      (code-convert-region (point-min) (point-max)
-					   *internal* user-coding-system)))
-		(write-region (point-min) (point-max) file append-p nil nil))
+		(write-region (point-min) (point-max) file append-p nil nil)))
 	      (message "Wrote to %s" file)
 	      )
 	  )
@@ -4471,10 +4541,15 @@
 			       (mew-message-get-part syntax))))
 		(if (mew-member-match type mew-mime-content-type-binary)
 		    (let ((mc-flag nil)
-			  (file-coding-system (if mew-mule-p *noconv*)))
+			  (file-coding-system
+			   (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+			  (coding-system-for-write
+			   (if mew-mule24-p 'no-conversion)))
 		      (write-region begin end file append-p))
 		  (let ((file-coding-system
-			(if mew-mule-p mew-mule-charset-local)))
+			 (if (and mew-mule-p (not mew-mule24-p)) mew-mule-charset-local))
+			(coding-system-for-write
+			 (if mew-mule24-p mew-mule-charset-local)))
 		    (write-region begin end file append-p)
 		    ))
 		)
@@ -4507,8 +4582,12 @@
 	(erase-buffer)
 	(let ((selective-display nil)
 	      (mc-flag nil)
-	      (file-coding-system-for-read (if mew-mule-p *noconv*))
-	      (file-coding-system (if mew-mule-p *noconv*))
+	      (file-coding-system-for-read
+	       (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+	      (file-coding-system
+	       (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+	      (coding-system-for-read (if mew-mule24-p 'no-conversion))
+	      (coding-system-for-write (if mew-mule24-p 'no-conversion))
 	      (syntax) (n 1))
 	  (insert-file-contents target)
 	  (setq syntax (mew-mime-syntax))
@@ -5031,8 +5110,10 @@
 	      (forward-line 1)
 	      ))
 	(let ((buffer-read-only nil))
-	  (code-convert-region (point) (point-max) 
-			       mew-mule-charset-local *internal*)
+	  (if mew-mule24-p
+	      (decode-coding-region (point) (point-max) mew-mule-charset-local)
+	    (code-convert-region (point) (point-max)
+				 mew-mule-charset-local *internal*))
 	  )
 	))
   )
@@ -5098,8 +5179,9 @@
 	(let ((selective-display nil)
 	      (mc-flag nil)
 	      (call-process-hook nil)
-	      (default-process-coding-system 
-		(if mew-mule-p (cons *noconv* *noconv*)))
+	      (default-process-coding-system
+		(if mew-mule24-p (cons 'no-conversion 'no-conversion)
+		  (if mew-mule-p (cons *noconv* *noconv*))))
 	      (filters mew-x-face-filter))
 	  (while filters
 	    (call-process-region (point-min) (point-max) 
@@ -5695,9 +5777,9 @@
   ;; in cache buffer
   (widen)
   (erase-buffer)
-  (if mew-mule-p
-      (let ((file-coding-system-for-read *noconv*))
-	(insert-file-contents file))
+  (let ((file-coding-system-for-read
+	 (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+	(coding-system-for-read (if mew-mule24-p 'no-conversion)))
     (insert-file-contents file))
   (if mew-debug
       (let ((debug-on-error t))
@@ -5843,15 +5925,24 @@
 	     mew-prog-mime-decode t t nil option)
       )
     (if (and mew-mule-p charset (not (string-match "us-ascii" charset)))
-	(code-convert-region 
-	 beg
-	 (if boundary
-	     (1- (marker-position mew-decode-marker)) ;; tricky
-	   (point-max)) ;; singlepart stuff
-	 (mew-mule-content-coding
-	  (mew-mule-content-attr charset mew-mule-character-set))
-	 *internal*
-	 )
+	(if mew-mule24-p
+	    (decode-coding-region 
+	     beg
+	     (if boundary
+		 (1- (marker-position mew-decode-marker)) ;; tricky
+	       (point-max)) ;; singlepart stuff
+	     (mew-mule-content-coding
+	      (mew-mule-content-attr charset mew-mule-character-set))
+	     )
+	  (code-convert-region 
+	   beg
+	   (if boundary
+	       (1- (marker-position mew-decode-marker)) ;; tricky
+	     (point-max)) ;; singlepart stuff
+	   (mew-mule-content-coding
+	    (mew-mule-content-attr charset mew-mule-character-set))
+	   *internal*
+	   ))
       )
     ))
 
@@ -5867,12 +5958,17 @@
 
 (defun mew-mime-localform ()
   (if (null (mew-field-get-value "Mime-Version:"))
-      (if mew-mule-p
-	  (progn
-	    (code-convert-region (point-min) (point-max)
-				 mew-mule-charset-local *internal*)
-	    (goto-char (point-min))
-	    (mew-header-mime-decode))) ;; RFC1522
+      (cond
+       (mew-mule24-p
+	(decode-coding-region (point-min) (point-max)
+			      mew-mule-charset-local)
+	(goto-char (point-min))
+	(mew-header-mime-decode)) ;; RFC1522
+       (mew-mule-p
+	(code-convert-region (point-min) (point-max)
+			     mew-mule-charset-local *internal*)
+	(goto-char (point-min))
+	(mew-header-mime-decode))) ;; RFC1522
     (goto-char (point-min))
     ;; message/rfc822
     (mew-mime-localform-singlepart))
@@ -5911,7 +6007,9 @@
 		   "access-type" (mew-part-get-params part))))
       (let ((file-name 
 	     (mew-part-get-params-member "name" (mew-part-get-params part)))
-	    (file-coding-system-for-read *noconv*))
+	    (file-coding-system-for-read
+	     (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+	    (coding-system-for-read (if mew-mule24-p 'no-conversion)))
 	(if boundary
 	    (mew-cache-delete-content-fields begin 'mime)
 	  (delete-region (point-min) (point-max)))
@@ -6616,7 +6714,7 @@
     (redraw-display))
   ;; xxx how about xemacs ?
   (cond
-   (mew-mule-p
+   ((and mew-mule-p (not mew-mule24-p))
     (make-local-variable 'file-coding-system)
     (make-local-variable 'file-coding-system-for-read)
     (make-local-variable 'default-process-coding-system)
@@ -7330,8 +7428,8 @@
     ;; the files as local charset to let users see the contents.
     ;; On UNIX file system, how is the charset guessed? There are few
     ;; chances to use charset other than local charset and US-ASCII.
-    (let ((file-coding-system-for-read
-	   (if mew-mule-p mew-mule-charset-local))) 
+    (let ((file-coding-system-for-read (if mew-mule-p mew-mule-charset-local))
+	  (coding-system-for-read (if mew-mule-p mew-mule-charset-local)))
       (insert-file-contents file)
       )
     (setq charset (mew-draft-charset-guess-region (point) (point-max)))
@@ -7444,6 +7542,12 @@
   (interactive "r")
   "Guess minimum character set name."
   (cond 
+   (mew-mule24-p
+    (let ((lc (apply 'max (find-charset-region beg end))))
+      (if (= lc 0)
+	  "us-ascii"
+	(mew-mule-lc-content (mew-mule-lc-attr lc mew-mule-character-set))
+	)))
    (mew-mule-p
     (let ((lc (car (find-charset-region beg end))))
       (if (null lc)
@@ -7890,8 +7994,12 @@
 	  (widen)
 	  (erase-buffer)
 	  (let ((mc-flag nil)
-		(file-coding-system-for-read (if mew-mule-p *noconv*))
-		(file-coding-system (if mew-mule-p *noconv*)))
+		(file-coding-system-for-read
+		 (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+		(file-coding-system
+		 (if (and mew-mule-p (not mew-mule24-p)) *noconv*))
+		(coding-system-for-read (if mew-mule24-p 'no-conversion))
+		(coding-system-for-write (if mew-mule24-p 'no-conversion)))
 	    (insert-file-contents fromfile)
 	    (write-region (point-min) (point-max)
 			  (expand-file-name efile mimedir))
@@ -8378,8 +8486,9 @@
 	    (let ((selective-display nil)
 		  (mc-flag nil)
 		  (call-process-hook nil)
-		  (default-process-coding-system 
-		    (if mew-mule-p (cons *noconv* *noconv*))))
+		  (default-process-coding-system
+		    (if mew-mule24-p (cons 'no-conversion 'no-conversion)
+		      (if mew-mule-p (cons *noconv* *noconv*)))))
 	      (while (not (mew-y-or-n-p "Are you ready? ")) ())
 	      (message "Type C-g to finish recording...")
 	      (apply 'call-process mew-prog-audio)
@@ -9065,15 +9174,20 @@
 	     (mew-decode-func-func
 	      (mew-decode-func-attr encode mew-decode-switch))
 	     enstr))
-      (if mew-mule-p
-	  (setq destr
-		(code-convert-string
-		 destr
-		 (mew-mule-content-coding
-		  (mew-mule-content-attr charset mew-mule-character-set))
-		 *internal*
-		 ))
-	)
+      (cond
+       (mew-mule24-p
+	(setq destr
+	      (decode-coding-string
+	       destr
+	       (mew-mule-content-coding
+		(mew-mule-content-attr charset mew-mule-character-set)))))
+       (mew-mule-p
+	(setq destr
+	      (code-convert-string
+	       destr
+	       (mew-mule-content-coding
+		(mew-mule-content-attr charset mew-mule-character-set))
+	       *internal*))))
       (setq str (concat head destr tail))
       ))
   str
@@ -9246,7 +9360,10 @@
 	  (let* ((attr (mew-mule-lc-attr lc mew-mule-character-set))
 		 (charset (mew-mule-lc-content attr))
 		 (symbol (mew-mule-lc-symbol attr))
-		 (txstr (code-convert-string str *internal* symbol)))
+		 (txstr
+		  (if mew-mule24-p
+		      (encode-coding-string str symbol)
+		    (code-convert-string str *internal* symbol))))
 	    (concat "=?" charset "?" encode "?" (funcall fun txstr) "?=")
 	    )
 	str


