From xemacs-m  Sat Mar 15 02:21:51 1997
Received: from gol1.gol.com (gol1.gol.com [202.243.48.4])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id CAA15738
	for <xemacs-beta@xemacs.org>; Sat, 15 Mar 1997 02:21:47 -0600 (CST)
Received: from Pentagana.sonic.jp (jhod@pm-5-182.tokyo.gol.com [202.243.51.182])
	by gol1.gol.com (8.8.5/8.8.5) with ESMTP id RAA22598;
	Sat, 15 Mar 1997 17:21:05 +0900 (JST)
Received: (from jhod@localhost) by Pentagana.sonic.jp (8.7.2/8.7.2) id RAA25459; Sat, 15 Mar 1997 17:18:43 +0900
Date: Sat, 15 Mar 1997 17:18:43 +0900
Message-Id: <199703150818.RAA25459@Pentagana.sonic.jp>
From: P E Jareth Hein <jhod@po.iijnet.or.jp>
To: "Steven L. Baur" <steve@miranova.com>,
        XEmacs Beta Mailing List <xemacs-beta@xemacs.org>
Subject: XEmacs patches for i18n (1/2)
Mime-Version: 1.0 (split by tm-edit 7.105)
Content-Type: message/partial; id="Sat_Mar_15_17:18:42_1997@Pentagana.sonic.jp"; number=1; total=2

To: "Steven L. Baur" <steve@miranova.com>,
    XEmacs Beta Mailing List <xemacs-beta@xemacs.org>
Subject: XEmacs patches for i18n
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: multipart/mixed;
 boundary="Multipart_Sat_Mar_15_17:18:42_1997-1"
Content-Transfer-Encoding: 7bit

--Multipart_Sat_Mar_15_17:18:42_1997-1
Content-Type: text/plain; charset=US-ASCII

Here is a boodle of stuff, including kinsoku processing, and a hack
that enables minibuffer pre-promts (which are used to relay state info
on input methods when entering text in the minibuffer). The kinsoku
stuff works[1] but I need everyone to really pound on the auto-fill
stuff to make sure I didn't break anything anywhere else. Especially
for people who don't compile with mule.

I'm probably going to rewrite the preprompt stuff, as it could be lots
cleaner...

[1] do-auto-fill works fine, but paragraph filling suffers from the
same randomness discussed earlier on this list. If no one else is
working on that, I guess I'll pick it up, as I'm digging in there
anyways.

Have phun.

--Jareth

--Multipart_Sat_Mar_15_17:18:42_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="xemacs.patch"
Content-Transfer-Encoding: 7bit

Index: XEmacs/lisp/egg/egg.el
diff -u XEmacs/lisp/egg/egg.el:1.1.1.1 XEmacs/lisp/egg/egg.el:1.2
--- XEmacs/lisp/egg/egg.el:1.1.1.1	Sat Mar 15 00:55:15 1997
+++ XEmacs/lisp/egg/egg.el	Sat Mar 15 16:55:55 1997
@@ -403,12 +403,12 @@
 ;; 97.2.4 Created by J.Hein to simulate Mule-2.3
 (defun read-event ()
   "Cheap 'n cheesy event filter to facilitate translation from Mule-2.3"
-  (setq event (make-event))
-  (while (progn
-	   (next-event event)
-	   (not (key-press-event-p event)))
-	    (dispatch-event event))
-  (event-key event))
+  (let ((event (make-event)))
+    (while (progn
+	     (next-event event)
+	     (not (key-press-event-p event)))
+      (dispatch-event event))
+    (event-key event)))
 
 (eval-when-compile (require 'egg-jsymbol))
 
@@ -880,36 +880,6 @@
 ;;;
 ;;;----------------------------------------------------------------------
 
-(defvar ascii-char "[\40-\176]")
-
-(defvar ascii-space "[ \t]")
-(defvar ascii-symbols "[\40-\57\72-\100\133-\140\173-\176]")
-(defvar ascii-numeric "[\60-\71]")
-(defvar ascii-English-Upper "[\101-\132]")
-(defvar ascii-English-Lower "[\141-\172]")
-
-(defvar ascii-alphanumeric "[\60-\71\101-\132\141-\172]")
-
-(defvar kanji-char "\\cj")
-(defvar kanji-space "$B!!(B")
-(defvar kanji-symbols "\\cS")
-(defvar kanji-numeric "[$B#0(B-$B#9(B]")
-(defvar kanji-English-Upper "[$B#A(B-$B#Z(B]")
-(defvar kanji-English-Lower  "[$B#a(B-$B#z(B]")
-;;; Bug fixed by Yoshida@CSK on 88-AUG-24
-(defvar kanji-hiragana "\\cH")
-(defvar kanji-katakana "\\cK")
-;;;
-(defvar kanji-Greek-Upper "[$B&!(B-$B&8(B]")
-(defvar kanji-Greek-Lower "[$B&A(B-$B&X(B]")
-(defvar kanji-Russian-Upper "[$B'!(B-$B'A(B]")
-(defvar kanji-Russian-Lower "[$B'Q(B-$B'q(B]")
-(defvar kanji-Kanji-1st-Level  "[$B0!(B-$BOS(B]")
-(defvar kanji-Kanji-2nd-Level  "[$BP!(B-$Bt$(B]")
-
-(defvar kanji-kanji-char "\\(\\cH\\|\\cK\\|\\cC\\)")
-
-(defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)"))
 
 ;;;
 ;;; $B$R$i$,$JJQ49(B
@@ -1680,13 +1650,13 @@
     
 (defun fence-self-insert-command ()
   (interactive)
-  (setq ch (event-to-character last-command-event))
-  (cond((or (not egg:*input-mode*)
-	    (null (get-next-map its:*current-map* ch)))
-	(insert ch))
-       (t
-	(insert ch)
-	(its:translate-region (1- (point)) (point) t))))
+  (let ((ch (event-to-character last-command-event)))
+    (cond((or (not egg:*input-mode*)
+	      (null (get-next-map its:*current-map* ch)))
+	  (insert ch))
+	 (t
+	  (insert ch)
+	  (its:translate-region (1- (point)) (point) t)))))
 
 ;;;
 ;;; its: completing-read system
@@ -2193,15 +2163,31 @@
            (not (eq new (minibuffer-window))))
       (save-excursion
 	(set-buffer (window-buffer (minibuffer-window)))
-	(setq minibuffer-preprompt nil
-	      egg:*mode-on* (default-value 'egg:*mode-on*)
+	(set-minibuffer-preprompt nil)
+	(setq egg:*mode-on* (default-value 'egg:*mode-on*)
 	      egg:*input-mode* (default-value 'egg:*input-mode*)
 	      egg:*in-fence-mode* (default-value 'egg:*in-fence-mode*))))
   (if (eq new (minibuffer-window))
       (setq minibuffer-window-selected t)
     (setq minibuffer-window-selected nil)))
 
-(setq select-window-hook 'egg:select-window-hook)
+(defun egg:minibuffer-entry-hook ()
+  (setq minibuffer-window-selected t))
+
+(defun egg:minibuffer-exit-hook ()
+  "Call upon exit from minibufffer"
+  (set-minibuffer-preprompt nil)
+  (setq minibuffer-window-selected nil)
+  (save-excursion
+    (set-buffer (window-buffer (minibuffer-window)))
+    (setq egg:*mode-on* (default-value 'egg:*mode-on*)
+	  egg:*input-mode* (default-value 'egg:*input-mode*)
+	  egg:*in-fence-mode* (default-value 'egg:*in-fence-mode*))))
+  
+(if (boundp 'select-window-hook)
+    (add-hook 'select-window-hook 'egg:select-window-hook)
+  (add-hook 'minibuffer-exit-hook 'egg:minibuffer-exit-hook)
+  (add-hook 'minibuffer-entry-hook 'egg:minibuffer-entry-hook))
 
 ;;;
 ;;;
@@ -2257,8 +2243,10 @@
 		    str)
 	    (aset (nth 2 egg:minibuffer-preprompt) 0
 		  (if its:*previous-map* ?\> ?\]))
-	    (setq minibuffer-preprompt
-		  egg:minibuffer-preprompt))
+	    (set-minibuffer-preprompt (concat
+				   (car egg:minibuffer-preprompt)
+				   (car (nthcdr 1 egg:minibuffer-preprompt))
+				   (car (nthcdr 2 egg:minibuffer-preprompt)))))
 	(setq display-minibuffer-mode t
 	      mode-line-egg-mode-in-minibuffer str))
     (setq display-minibuffer-mode nil
Index: XEmacs/lisp/mule/japanese-hooks.el
diff -u XEmacs/lisp/mule/japanese-hooks.el:1.1.1.1 XEmacs/lisp/mule/japanese-hooks.el:1.2
--- XEmacs/lisp/mule/japanese-hooks.el:1.1.1.1	Sat Mar 15 00:55:27 1997
+++ XEmacs/lisp/mule/japanese-hooks.el	Sat Mar 15 16:55:56 1997
@@ -194,3 +194,18 @@
     ))
 
 (set-coding-category-system 'shift-jis 'shift-jis)
+
+;; stuff for providing gramatic processing of Japanese text
+;; something like this should probably be created for all environments...
+
+(defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)"))
+(defvar kanji-space-insertable (concat 
+	   "$B!"(B" aletter                   "\\|"
+	   "$B!#(B" aletter                   "\\|"
+	   aletter "$B!J(B"                   "\\|"
+	   "$B!K(B" aletter                   "\\|"
+	   ascii-alphanumeric  kanji-kanji-char "\\|"
+	   kanji-kanji-char    ascii-alphanumeric ))
+
+(defvar space-insertable (concat " " aletter "\\|" kanji-space-insertable)
+ "Regexp for finding points that can have spaces inserted into them for justification")
Index: XEmacs/lisp/mule/kinsoku.el
diff -u /dev/null XEmacs/lisp/mule/kinsoku.el:1.1
--- /dev/null	Sat Mar 15 17:07:32 1997
+++ XEmacs/lisp/mule/kinsoku.el	Sat Mar 15 16:55:56 1997
@@ -0,0 +1,281 @@
+;; kinsoku.el -- Kinsoku (line wrap) processing for XEmacs/Mule
+
+;; Copyright (C) 1997 Free Software Foundation, Inc.
+;; This file is part of Mule (MULtilingual Enhancement of XEmacs).
+;; This file contains Japanese and Chinese characters.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Written by Jareth Hein (jhod@po.iijnet.or.jp) based off of
+;; code by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp) from
+;; Mule-2.3
+
+;;;    Special characters for JIS code
+;;;     "$B!!!"!#!$!%!&!'!'!(!)!*!+!,!-!.!/(B"
+;;;   "$B!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>!?(B"
+;;;   "$B!@!A!B!C!D!E!F!G!H!I!J!K!L!M!N!O(B"
+;;;   "$B!P!Q!R!S!T!U!V!W!X!Y!Z![!\!]!^!_(B"
+;;;   "$B!`!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o(B"
+;;;   "$B!p!q!r!s!t!u!v!w!x!y!z!{!|!}!~(B"
+;;;     "$B"!"""#"$"%"&"'"(")"*"+","-".(B "
+;;;     "$B&!&"&#&$&%&&&'&(&)&*&+&,&-&.&/(B"
+;;;   "$B&0&1&2&3&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-$.$/(B
+;;;$(0$0$1$2$3$4$5$6$7$8$9$:$;$<$=$>$?(B
+;;;$(0$@$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O(B
+;;;$(0$P$Q$R$S$T$U$V$W$X$Y$Z$[$\$]$^$_(B
+;;;$(0$`$a$b$c$d$e$f$g$h$i$j$k$l$m$n$o(B
+;;;$(0$p$q$r$s$t$u$v$w$x$y$z${$|$}$~(B
+;;;  $(0%!%"%#%$%%%&%'%(%)%*%+%,%-%.%/(B
+;;;$(0%0%1%2%3%4%5%6%7%8%9%:%;%<%=%>%?(B
+
+(defvar kinsoku-ascii nil "Do kinsoku-processing for ASCII.")
+(make-variable-buffer-local 'kinsoku-ascii)
+(set-default 'kinsoku-ascii nil)
+(defvar kinsoku-jis t "Do kinsoku-processing for JISX0208.")
+(make-variable-buffer-local 'kinsoku-jis)
+(set-default 'kinsoku-jis t)
+(defvar kinsoku-gb t "Do kinsoku-processing for GB2312.")
+(make-variable-buffer-local 'kinsoku-gb)
+(set-default 'kinsoku-gb t)
+(defvar kinsoku-big5 t "Do kinsoku-processing for Big5..")
+(make-variable-buffer-local 'kinsoku-big5)
+(set-default 'kinsoku-big5 t)
+
+(defvar kinsoku-ascii-bol "!)-_~}]:;',.?" "BOL kinsoku for ASCII.")
+(defvar kinsoku-ascii-eol "({[" "EOL kinsoku for ASCII.")
+(defvar kinsoku-jis-bol
+  (concat  "$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>(B"
+	   "$B!?!@!A!B!C!D!E!G!I!K!M!O!Q!S!U!W!Y![!k!l!m!n(B"
+	   "$B$!$#$%$'$)$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v(B")
+  "BOL kinsoku for JISX0208.")
+(defvar kinsoku-jis-eol
+  "$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!n!w!x(B"
+  "EOL kinsoku for JISX0208.")
+(defvar kinsoku-gb-bol
+  (concat  "$A!"!##.#,!$!%!&!'!(!)!*!+!,!-!/!1#)!3!5!7!9!;!=(B"
+	   "$A!?#;#:#?#!!@!A!B!C!c!d!e!f#/#\#"#_#~#|(e(B")
+  "BOL kinsoku for GB2312.")
+(defvar kinsoku-gb-eol
+  (concat "$A!.!0#"#(!2!4!6!8!:!<!>!c!d!e#@!f!l(B"
+	  "$A(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(h(B")
+  "EOL kinsoku for GB2312.")
+(defvar kinsoku-big5-bol
+  (concat  "$(0!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2(B"
+ 	   "$(0!3!4!5!6!7!8!9!:!;!<!=!?!A!C!E!G!I!K(B"
+ 	   "$(0!M!O!Q(B	$(0!S!U!W!Y![!]!_!a!c!e!g!i!k!q(B"
+ 	   "$(0"#"$"%"&"'"(")"*"+","2"3"4"j"k"l"x%7(B")
+  "BOL kinsoku for BIG5.")
+(defvar kinsoku-big5-eol
+  (concat "$(0!>!@!B!D!F!H!J!L!N!P!R!T!V!X!Z!\!^!`!b(B"
+ 	  "$(0!d!f!h!j!k!q!p"i"j"k"n"x$u$v$w$x$y$z${(B"
+ 	  "$(0$|$}$~%!%"%#%$%%%&%'%(%)%*%+%:(B")
+  "EOL kinsoku for BIG5.")
+
+(define-category ?s "Kinsoku forbidden start of line characters")
+(define-category ?e "Kinsoku forbidden end of line characters")
+
+;; kinsoku ascii
+(loop for char in (string-to-char-list kinsoku-ascii-bol)
+      do (modify-category-entry char ?s))
+(loop for char in kinsoku-ascii-eol
+      do (modify-category-entry char ?e))
+;; kinsoku-jis
+(loop for char in (string-to-char-list kinsoku-jis-bol)
+      do (modify-category-entry char ?s))
+(loop for char in (string-to-char-list kinsoku-jis-eol)
+      do (modify-category-entry char ?e))
+;; kinsoku-gb
+(loop for char in kinsoku-gb-bol
+      do (modify-category-entry char ?s))
+(loop for char in kinsoku-gb-eol
+      do (modify-category-entry char ?e))
+;; kinsoku-big5
+(loop for char in kinsoku-big5-bol
+      do (modify-category-entry char ?s))
+(loop for char in kinsoku-big5-eol
+      do (modify-category-entry char ?e))
+
+(defun kinsoku-bol-p ()
+  "Check if point would break forbidden beginning-of-line rules
+Uses category \'s\' to check.
+point$B$G2~9T$9$k$H9TF,6XB'$K?($l$k$+$I$&$+$r$+$($9!#(B
+$B9TF,6XB'J8;z$O(B\'s\'$B$N(Bcategory$B$G;XDj$9$k!#(B"
+  (let ((ch (following-char)))
+    (if (or
+	 (and kinsoku-ascii (char-in-category-p ch ?a))
+	 (and kinsoku-jis (char-in-category-p ch ?j))
+	 (and kinsoku-gb (char-in-category-p ch ?c))
+	 (and kinsoku-big5 (char-in-category-p ch ?t)))
+	(char-in-category-p ch ?s)
+      nil)))
+
+(defun kinsoku-eol-p ()
+  "Check if point would break forbidden end-of-line rules
+Uses category \'e\' to check.
+point$B$G2~9T$9$k$H9TKv6XB'$K?($l$k$+$I$&$+$r$+$($9!#(B
+$B9TKv6XB'J8;z$O(B\'s\'$B$N(Bcategory$B$G;XDj$9$k!#(B"
+  (let ((ch (preceding-char)))
+    (if (or
+	 (and kinsoku-ascii (char-in-category-p ch ?a))
+	 (and kinsoku-jis (char-in-category-p ch ?j))
+	 (and kinsoku-gb (char-in-category-p ch ?c))
+	 (and kinsoku-big5 (char-in-category-p ch ?t)))
+	(char-in-category-p ch ?e)
+      nil)))
+
+(defvar kinsoku-extend-limit nil
+  "Defines how many characters kinsoku will search forward before giving up.
+A value of nil equates to infinity.
+$B6XB'=hM}$G9T$r?-$P$7$FNI$$H>3QJ8;z?t$r;XDj$9$k!#(B
+$BHsIi@0?t0J30$N>l9g$OL58BBg$r0UL#$9$k!#(B")
+
+(defun kinsoku-process ()
+  "Move to a point that will not break forbidden line break rules.
+$B6XB'$K?($l$J$$E@$X0\F0$9$k!#(B
+point$B$,9TF,6XB'$K?($l$k>l9g$O9T$r?-$P$7$F!"6XB'$K?($l$J$$E@$rC5$9!#(B
+point$B$,9TKv6XB'$K?($l$k>l9g$O9T$r=L$a$F!"6XB'$K?($l$J$$E@$rC5$9!#(B
+$B$?$@$7!"9T?-$P$7H>3QJ8;z?t$,(Bkinsoku-extend-limit$B$r1[$($k$H!"(B
+$B9T$r=L$a$F6XB'$K?($l$J$$E@$rC5$9!#(B"
+  (let ((bol-kin nil) (eol-kin nil))
+    (if (and (not (bolp))
+	     (not (eolp))
+	     (or (setq bol-kin (kinsoku-bol-p))
+		 (setq eol-kin (kinsoku-eol-p))))
+	(cond(bol-kin (kinsoku-process-extend))
+	     (eol-kin (kinsoku-process-shrink))))))
+
+(defun kinsoku-process-extend ()
+  "Move point forward to a permissable for line-breaking.
+$B9T$r?-$P$7$F6XB'$K?($l$J$$E@$X0\F0$9$k!#(B"
+  (let ((max-column (+ fill-column 
+		       (if (and (numberp kinsoku-extend-limit)
+				(>= kinsoku-extend-limit 0))
+			   kinsoku-extend-limit
+			 10000)))  ;;; 10000 is deliberatly unreasonably large
+	ch1 ch2)
+    (while (and (<= (+ (current-column)
+		       (char-width (setq ch1 (following-char))))
+		    max-column)
+		(not (bolp))
+		(not (eolp))
+		(or (kinsoku-eol-p)
+		    (kinsoku-bol-p)
+	            ;;; don't break in the middle of an English word
+		    (and (char-in-category-p ch1 ?a)
+			 (char-in-category-p (setq ch2 (preceding-char)) ?a)
+			 (= ?w (char-syntax ch2))
+			 (= ?w (char-syntax ch1)))))
+      (forward-char))
+    (if (or (kinsoku-eol-p) (kinsoku-bol-p))
+	(kinsoku-process-shrink))))
+
+(defun kinsoku-process-shrink ()
+  "Move point backward to a point permissable for line-breaking.
+$B9T$r=L$a$F6XB'$K?($l$J$$E@$X0\F0$9$k!#(B"
+  (let (ch1 ch2)
+    (while (and (not (bolp))
+		(not (eolp))
+		(or (kinsoku-bol-p)
+		    (kinsoku-eol-p)
+		;;; don't break in the middle of an English word
+		    (and
+		     (char-in-category-p (setq ch1 (following-char)) ?a)
+		     (char-in-category-p (setq ch2 (preceding-char)) ?a)
+		     (= ?w (char-syntax ch2))
+		     (= ?w (char-syntax ch1)))))
+      (backward-char))))
Index: XEmacs/lisp/mule/mule-category.el
diff -u XEmacs/lisp/mule/mule-category.el:1.1.1.1 XEmacs/lisp/mule/mule-category.el:1.2
--- XEmacs/lisp/mule/mule-category.el:1.1.1.1	Sat Mar 15 00:55:27 1997
+++ XEmacs/lisp/mule/mule-category.el	Sat Mar 15 16:55:56 1997
@@ -119,16 +119,17 @@
 	  (setq a (1+ a)))
 	(nreverse list)))))
 
-(defun char-in-category-p (char category &optional table)
-  "Return non-nil if CHAR is in CATEGORY.
-TABLE defaults to the current buffer's category table.
-Categories are specified by their designators."
-  (or table (setq table (category-table)))
-  (check-argument-type 'category-table-p table)
-  (check-argument-type 'category-designator-p category)
-  (let ((vec (get-char-table char table)))
-    (if (null vec) nil
-      (= 1 (aref vec (- category 32))))))
+;; implimented in c, file chartab.c (97/3/14 jhod@po.iijnet.or.jp)
+;(defun char-in-category-p (char category &optional table)
+;  "Return non-nil if CHAR is in CATEGORY.
+;TABLE defaults to the current buffer's category table.
+;Categories are specified by their designators."
+;  (or table (setq table (category-table)))
+;  (check-argument-type 'category-table-p table)
+;  (check-argument-type 'category-designator-p category)
+;  (let ((vec (get-char-table char table)))
+;    (if (null vec) nil
+;      (= 1 (aref vec (- category 32))))))
 
 (defun describe-category ()
   "Describe the category specifications in the category table.
@@ -173,7 +174,7 @@
 		 (and (characterp range)
 		      (characterp first-char)
 		      (eq (char-charset range) (char-charset first-char))
-		      (= (char-int last-char) (1- (char-int range))))
+		      (= (char-to-int last-char) (1- (char-to-int range))))
 		 (and (vectorp range)
 		      (vectorp first-char)
 		      (eq (aref range 0) (aref first-char 0))
@@ -203,7 +204,7 @@
 		(if (not already-matched)
 		    (setq already-matched t)
 		  (princ " "))
-		(princ (int-char (+ 32 i)))))
+		(princ (int-to-char (+ 32 i)))))
 	  (setq i (1+ i)))
 	(if (not already-matched)
 	    (princ "(none)")))
@@ -211,7 +212,7 @@
 	(while (< i 95)
 	  (if (= 1 (aref code i))
 	      (princ (format "\n\t\tmeaning: %s"
-			    (category-doc-string (int-char (+ 32 i))))))
+			    (category-doc-string (int-to-char (+ 32 i))))))
 	  (setq i (1+ i)))))
     (terpri)))
 
@@ -258,3 +259,28 @@
 ;;; break line at any point under a restriction of 'kinsoku'.
 (defvar word-across-newline "\\(\\cj\\|\\cc\\|\\ct\\)"
   "Regular expression of such characters which can be a word across newline.")
+
+(defvar ascii-char "[\40-\176]")
+(defvar ascii-space "[ \t]")
+(defvar ascii-symbols "[\40-\57\72-\100\133-\140\173-\176]")
+(defvar ascii-numeric "[\60-\71]")
+(defvar ascii-English-Upper "[\101-\132]")
+(defvar ascii-English-Lower "[\141-\172]")
+(defvar ascii-alphanumeric "[\60-\71\101-\132\141-\172]")
+
+(defvar kanji-char "\\cj")
+(defvar kanji-space "$B!!(B")
+(defvar kanji-symbols "\\cS")
+(defvar kanji-numeric "[$B#0(B-$B#9(B]")
+(defvar kanji-English-Upper "[$B#A(B-$B#Z(B]")
+(defvar kanji-English-Lower  "[$B#a(B-$B#z(B]")
+(defvar kanji-hiragana "\\cH")
+(defvar kanji-katakana "\\cK")
+(defvar kanji-Greek-Upper "[$B&!(B-$B&8(B]")
+(defvar kanji-Greek-Lower "[$B&A(B-$B&X(B]")
+(defvar kanji-Russian-Upper "[$B'!(B-$B'A(B]")
+(defvar kanji-Russian-Lower "[$B'Q(B-$B'q(B]")
+(defvar kanji-Kanji-1st-Level  "[$B0!(B-$BOS(B]")
+(defvar kanji-Kanji-2nd-Level  "[$BP!(B-$Bt$(B]")
+
+(defvar kanji-kanji-char "\\(\\cH\\|\\cK\\|\\cC\\)")
Index: XEmacs/lisp/mule/mule-load.el
diff -u XEmacs/lisp/mule/mule-load.el:1.1.1.1 XEmacs/lisp/mule/mule-load.el:1.2
--- XEmacs/lisp/mule/mule-load.el:1.1.1.1	Sat Mar 15 00:55:28 1997
+++ XEmacs/lisp/mule/mule-load.el	Sat Mar 15 16:55:56 1997
@@ -30,6 +30,7 @@
 ;;(load-gc "mule-process")
 (load-gc "mule-ccl")
 (load-gc "mule-misc")
+(load-gc "kinsoku")
 (when (featurep 'x)
   (load-gc "mule-x-init"))
 
Index: XEmacs/lisp/prim/fill.el
diff -u XEmacs/lisp/prim/fill.el:1.1.1.1 XEmacs/lisp/prim/fill.el:1.2
--- XEmacs/lisp/prim/fill.el:1.1.1.1	Sat Mar 15 00:55:35 1997
+++ XEmacs/lisp/prim/fill.el	Sat Mar 15 16:55:58 1997
@@ -28,6 +28,9 @@
 ;; All the commands for filling text.  These are documented in the XEmacs
 ;; Reference Manual.
 
+;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added functions for kinsoku (asian text
+;; line break processing)
+
 ;;; Code:
 
 (defconst fill-individual-varying-indent nil
@@ -77,6 +80,38 @@
   "*Function to call to choose a fill prefix for a paragraph.
 This function is used when `adaptive-fill-regexp' does not match.")
 
+;; Added for kinsoku processing. Use this instead of 
+;; (skip-chars-backward "^ \t\n")
+;; (skip-chars-backward "^ \n" linebeg)
+(defun fill-move-backward-to-break-point (regexp &optional lim)
+  (let ((opoint (point)))
+    ;; 93.8.23 by kawamoto@ics.es.osaka-u.ac.jp
+    ;;  case of first 'word' being longer than fill-column
+    (if (not (re-search-backward regexp lim 'move))
+	nil
+      ;; we have skipped backward SPC or WAN (word-across-newline).  So move point forward again.
+      (forward-char)
+      (if (<= opoint (point))
+	  (forward-char -1)))))
+
+;; Added for kinsoku processing. Use instead of
+;; (re-search-forward "[ \t]" opoint t)
+;; (skip-chars-forward "^ \n")
+;; (skip-chars-forward "^ \n")
+(defun fill-move-forward-to-break-point (regexp &optional lim)
+  (let ((opoint (point)))
+    (if (not (re-search-forward regexp lim 'move))
+	nil
+      (forward-char -1)
+      (if (<= (point) opoint)
+	  (forward-char))))
+  (if (featurep 'mule) (kinsoku-process-extend)))
+
+(defun fill-end-of-sentence-p ()
+  (save-excursion
+    (skip-chars-backward " ]})\"'")
+    (memq (preceding-char) '(?. ?? ?!))))
+
 (defun current-fill-column ()
   "Return the fill-column to use for this line.
 The fill-column to use for a buffer is stored in the variable `fill-column',
@@ -106,9 +141,10 @@
 (defun canonically-space-region (beg end)
   "Remove extra spaces between words in region.
 Leave one space between words, two at end of sentences or after colons
-(depending on values of `sentence-end-double-space' and `colon-double-space').
- Remove indentation from each line."
+\(depending on values of `sentence-end-double-space' and `colon-double-space').
+Remove indentation from each line."
   (interactive "r")
+  ;;;### 97/3/14 jhod: Do I have to add anything here for kinsoku?
   (save-excursion
     (goto-char beg)
     ;; XEmacs - (ENE/stig from fa-extras.el): Skip the start of a comment.
@@ -149,6 +185,7 @@
 ;; XEmacs -- added DONT-SKIP-FIRST.  Port of older code changes by Stig.
 ;; #### probably this junk is broken -- do-auto-fill doesn't actually use
 ;; it.  If so, it should be removed.
+
 (defun fill-context-prefix (from to &optional first-line-regexp
 				 dont-skip-first)
   "Compute a fill prefix from the text between FROM and TO.
@@ -172,7 +209,9 @@
       (move-to-left-margin)
       ;; XEmacs change
       (let ((start (point))
-	    (eol (save-excursion (end-of-line) (point))))
+	    ; jhod: no longer used?
+	    ;(eol (save-excursion (end-of-line) (point)))
+	    )
 	(setq result
 	      (if (not (looking-at paragraph-start))
 		  (cond ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp))
@@ -319,8 +358,40 @@
 	  (goto-char from)
 	  (skip-chars-forward " \t")
 	  ;; Then change all newlines to spaces.
-	  (subst-char-in-region from (point-max) ?\n ?\ )
-	  (if (and nosqueeze (not (eq justify 'full)))
+	  ;;; 97/3/14 jhod: Kinsoku change
+	  ;; Spacing is not necessary for charcters of no word-separater.
+	  ;; The regexp word-across-newline is used for this check.
+	  (if (not (and (featurep 'mule)
+			(stringp word-across-newline)))
+	      (subst-char-in-region from (point-max) ?\n ?\ )
+	    ;;
+	    ;; WAN     +NL+WAN       --> WAN            + WAN
+	    ;; not(WAN)+NL+WAN       --> not(WAN)       + WAN
+	    ;; WAN     +NL+not(WAN)  --> WAN            + not(WAN)
+	    ;; SPC     +NL+not(WAN)  --> SPC            + not(WAN)
+	    ;; not(WAN)+NL+not(WAN)  --> not(WAN) + SPC + not(WAN)
+	    ;;
+	    (goto-char from)
+	    (end-of-line)
+	    (while (not (eobp))
+	      ;; Insert SPC only when point is between nonWAN.  Insert
+	      ;; before deleting to preserve marker if possible.
+	      (if (or (prog2		; check following char.
+			  (forward-char)	; skip newline
+			  (or (eobp)
+			      (looking-at word-across-newline))
+			(forward-char -1))
+		      (prog2		; check previous char.
+			  (forward-char -1)
+			  (or (eq (following-char) ?\ )
+			      (looking-at word-across-newline))
+			(forward-char)))
+		  nil
+		(insert ?\ ))
+	      (delete-char 1)		; delete newline
+	      (end-of-line)))
+	  ;; end patch
+ 	  (if (and nosqueeze (not (eq justify 'full)))
 	      nil
 	    (canonically-space-region (or squeeze-after (point)) (point-max))
 	    (goto-char (point-max))
@@ -330,14 +401,20 @@
 	  (goto-char (point-min))
 
 	  ;; This is the actual filling loop.
-	  (let ((prefixcol 0) linebeg)
+	  (let ((prefixcol 0) linebeg
+		(re-break-point (if (featurep 'mule)
+				    (concat "[ \n\t]\\|" word-across-newline)
+				  "[ \n\t]")))
 	    (while (not (eobp))
 	      (setq linebeg (point))
 	      (move-to-column (1+ (current-fill-column)))
 	      (if (eobp)
 		  (or nosqueeze (delete-horizontal-space))
 		;; Move back to start of word.
-		(skip-chars-backward "^ \n" linebeg)
+		;; 97/3/14 jhod: Kinsoku
+		;(skip-chars-backward "^ \n" linebeg)
+		(fill-move-backward-to-break-point re-break-point linebeg)
+		;; end patch
 		;; Don't break after a period followed by just one space.
 		;; Move back to the previous place to break.
 		;; The reason is that if a period ends up at the end of a line,
@@ -350,7 +427,12 @@
 				(not (eq (following-char) ?\ ))
 				(eq (char-after (- (point) 2)) ?\.))
 		      (forward-char -2)
-		      (skip-chars-backward "^ \n" linebeg)))
+		      ;; 97/3/14 jhod: Kinsoku
+		      ;(skip-chars-backward "^ \n" linebeg)))
+		      (fill-move-backward-to-break-point re-break-point linebeg)))
+		(if (featurep 'mule) (kinsoku-process))
+		;end patch
+
 		;; If the left margin and fill prefix by themselves
 		;; pass the fill-column. or if they are zero
 		;; but we have no room for even one word,
@@ -373,7 +455,10 @@
 							   (and (looking-at "\\. ")
 								(not (looking-at "\\.  ")))))))
 			(skip-chars-forward " \t")
-			(skip-chars-forward "^ \n\t")
+			;; 94/3/14 jhod: Kinsoku
+			;(skip-chars-forward "^ \n\t")
+			(fill-move-forward-to-break-point re-break-point)
+			;; end patch
 			(setq first nil)))
 		  ;; Normally, move back over the single space between the words.
 		  (forward-char -1))
@@ -401,7 +486,10 @@
 							   (and (looking-at "\\. ")
 								(not (looking-at "\\.  ")))))))
 			(skip-chars-forward " \t")
-			(skip-chars-forward "^ \t\n")
+			;; 97/3/14 jhod: Kinsoku
+			;(skip-chars-forward "^ \t\n")
+			(fill-move-forward-to-break-point re-break-point)
+			;; end patch
 			(setq first nil))))
 		;; Check again to see if we got to the end of the paragraph.
 		(if (save-excursion (skip-chars-forward " \t") (eobp))
@@ -409,6 +497,43 @@
 		  ;; Replace whitespace here with one newline, then indent to left
 		  ;; margin.
 		  (skip-chars-backward " \t")
+		  ;; 97/3/14 jhod: More kinsoku stuff
+		  (if (featurep 'mule)
+		      ;; WAN means chars which match word-across-newline.
+		      ;; (0)     | SPC + SPC* <EOB>	--> NL
+		      ;; (1) WAN | SPC + SPC*		--> WAN + SPC + NL
+		      ;; (2)     | SPC + SPC* + WAN	--> SPC + NL  + WAN
+		      ;; (3) '.' | SPC + nonSPC		--> '.' + SPC + NL + nonSPC
+		      ;; (4) '.' | SPC + SPC		--> '.' + NL
+		      ;; (5)     | SPC*			--> NL
+		      (let ((start (point))	; 92.6.30 by K.Handa
+			    (ch (following-char)))
+			(if (and (= ch ? )
+				 (progn		; not case (0) -- 92.6.30 by K.Handa
+				   (skip-chars-forward " \t")
+				   (not (eobp)))
+				 (or
+				  (progn	; case (1)
+				    (goto-char start)
+				    (forward-char -1)
+				    (looking-at word-across-newline))
+				  (progn	; case (2)
+				    (goto-char start)
+				    (skip-chars-forward " \t")
+				    (and (not (eobp))
+					 (looking-at word-across-newline)
+					 ;; never leave space after the end of sentence
+					 (not (fill-end-of-sentence-p))))
+				  (progn	; case (3)
+				    (goto-char (1+ start))
+				    (and (not (eobp))
+					 (/= (following-char) ? )
+					 (fill-end-of-sentence-p)))))
+			    ;; We should keep one SPACE before NEWLINE. (1),(2),(3)
+			    (goto-char (1+ start))
+			  ;; We should delete all SPACES around break point. (4),(5)
+			  (goto-char start))))
+		  ;; end of patch
 		  (insert ?\n)
 		  ;; Give newline the properties of the space(s) it replaces
 		  (set-text-properties (1- (point)) (point)
@@ -627,6 +752,16 @@
 		     (if (region-active-p) (region-end) (point))))
   (set-justification b e 'center t))
 
+;; 97/3/14 jhod: This functions are added for Kinsoku support
+(defun find-space-insertable-point ()
+ "Search backward for a permissable point for inserting justification spaces"
+ (if (boundp 'space-insertable)
+     (if (re-search-backward space-insertable nil t)
+	 (progn (forward-char 1)
+		t)
+       nil)
+   (search-backward " " nil t)))
+
 ;; A line has up to six parts:
 ;;
 ;;           >>>                    hello.  		       
@@ -754,14 +889,15 @@
 		   ;; Ncols is number of additional spaces needed
 		   (if (> ncols 0)
 		       (if (and (not eop)
-				(search-backward " " nil t))
+				;; 97/3/14 jhod: Kinsoku
+				(find-space-insertable-point)) ;(search-backward " " nil t))
 			   (while (> ncols 0)
 			     (let ((nmove (+ 3 (random 3))))
 			       (while (> nmove 0)
-				 (or (search-backward " " nil t)
+				 (or (find-space-insertable-point) ;(search-backward " " nil t)
 				     (progn
 				       (goto-char (point-max))
-				       (search-backward " ")))
+				       (find-space-insertable-point))) ;(search-backward " ")))
 				 (skip-chars-backward " ")
 				 (setq nmove (1- nmove))))
 			     ;; XEmacs change
Index: XEmacs/lisp/prim/simple.el
diff -u XEmacs/lisp/prim/simple.el:1.1.1.1 XEmacs/lisp/prim/simple.el:1.2
--- XEmacs/lisp/prim/simple.el:1.1.1.1	Sat Mar 15 00:55:36 1997
+++ XEmacs/lisp/prim/simple.el	Sat Mar 15 16:55:58 1997
@@ -52,6 +52,11 @@
 ;; this isn't a user-visible change.  These functions have also been altered
 ;; to use (mark t) for the same reason.
 
+;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added kinsoku processing (support
+;; for filling of Asian text) into the fill code. This was ripped bleeding from
+;; Mule-2.3, and could probably use some feature additions (like additional wrap
+;; styles, etc)
+
 ;;; Code:
 
 (defun newline (&optional arg)
@@ -2213,6 +2218,11 @@
 		(fill-point
 		 (let ((opoint (point))
 		       bounce
+		       ;; 97/3/14 jhod: Kinsoku
+		       (re-break-point (if (featurep 'mule)
+					    (concat "[ \t\n]\\|" word-across-newline)
+					"[ \t\n]"))
+		       ;; end patch
 		       (first t))
 		   (save-excursion
 		     (move-to-column (1+ fill-column))
@@ -2229,15 +2239,24 @@
 						     (and (looking-at "\\. ")
 							  (not (looking-at "\\.  "))))))
 		       (setq first nil)
-		       (skip-chars-backward "^ \t\n")
+		       ;; 97/3/14 jhod: Kinsoku
+		       ; (skip-chars-backward "^ \t\n"))
+		       (fill-move-backward-to-break-point re-break-point)
+		       ;; end patch
 		       ;; If we find nowhere on the line to break it,
 		       ;; break after one word.  Set bounce to t
 		       ;; so we will not keep going in this while loop.
 		       (if (bolp)
 			   (progn
-			     (re-search-forward "[ \t]" opoint t)
+			     ;; 97/3/14 jhod: Kinsoku
+			     ; (re-search-forward "[ \t]" opoint t)
+			     (fill-move-forward-to-break-point re-break-point
+							       opoint)
+			     ;; end patch
 			     (setq bounce t)))
 		       (skip-chars-backward " \t"))
+		     (if (and (featurep 'mule)
+			      (or bounce (bolp))) (kinsoku-process)) ;; 97/3/14 jhod: Kinsoku
 		     ;; Let fill-point be set to the place where we end up.
 		     (point)))))
 
@@ -2256,7 +2275,7 @@
 	    ;; break the line there.
 	    (if (save-excursion
 		  (goto-char fill-point)
-		  (not (bolp)))
+		  (not (or (bolp) (eolp)))) ; 97/3/14 jhod: during kinsoku processing it is possible to move beyond
 		(let ((prev-column (current-column)))
 		  ;; If point is at the fill-point, do not `save-excursion'.
 		  ;; Otherwise, if a comment prefix or fill-prefix is inserted,
@@ -2264,7 +2283,20 @@
 		  (if (save-excursion
 			(skip-chars-backward " \t")
 			(= (point) fill-point))
-		      (indent-new-comment-line)
+		      ;; 97/3/14 jhod: Kinsoku processing
+		      ;(indent-new-comment-line)
+		      (let ((spacep (memq (preceding-char) '(?\  ?\t))))
+			(indent-new-comment-line)
+			;; if user type space explicitly, leave SPC
+			;; even if there is no WAN.
+			(if spacep
+			    (save-excursion
+			      (goto-char fill-point)
+			      ;; put SPC except that there is SPC
+			      ;; already or there is sentence end.
+			      (or (memq (following-char) '(?\  ?\t))
+				  (fill-end-of-sentence-p)
+				  (insert ?\ )))))
 		    (save-excursion
 		      (goto-char fill-point)
 		      (indent-new-comment-line)))
@@ -2435,6 +2467,9 @@
   (interactive)
   (let (comcol comstart)
     (skip-chars-backward " \t")
+    ;; 97/3/14 jhod: Kinsoku processing
+    (if (featurep 'mule)
+	(kinsoku-process))
     (delete-region (point)
 		   (progn (skip-chars-forward " \t")
 			  (point)))
@@ -2447,6 +2482,7 @@
     ;; fa-extras, which I'm not gonna do.  His changes are to (1) execute
     ;; the save-excursion below unconditionally, and (2) uncomment the check
     ;; for (not comment-multi-line) further below.  --Stig 
+      ;;### jhod: probably need to fix this for kinsoku processing
       (if (not comment-multi-line)
 	  (save-excursion
 	    (if (and comment-start-skip
Index: XEmacs/src/Makefile.in.in
diff -u XEmacs/src/Makefile.in.in:1.1.1.1 XEmacs/src/Makefile.in.in:1.2
--- XEmacs/src/Makefile.in.in:1.1.1.1	Sat Mar 15 00:55:59 1997
+++ XEmacs/src/Makefile.in.in	Sat Mar 15 16:56:00 1997
@@ -1110,6 +1110,7 @@
 	${lispdir}mule/mule-charset.elc ${lispdir}mule/mule-files.elc \
 	${lispdir}mule/mule-category.elc ${lispdir}mule/mule-misc.elc \
 	${lispdir}mule/mule-ccl.elc ${lispdir}mule/mule-init.elc \
+	${lispdir}mule/kinsoku.elc \
 	MULE_X11_LISP \
 	${lispdir}mule/arabic-hooks.elc \
 	${lispdir}mule/chinese-hooks.elc \
Index: XEmacs/src/chartab.c
diff -u XEmacs/src/chartab.c:1.1.1.1 XEmacs/src/chartab.c:1.2
--- XEmacs/src/chartab.c:1.1.1.1	Sat Mar 15 00:56:00 1997
+++ XEmacs/src/chartab.c	Sat Mar 15 16:56:00 1997
@@ -1647,12 +1647,12 @@
 }   
 
 int
-check_category_at(Emchar ch, Lisp_Object table,
-		  unsigned int designator, unsigned int not)
+check_category_char(Emchar ch, Lisp_Object table,
+		    unsigned int designator, unsigned int not)
 {
   register Lisp_Object temp;
   struct Lisp_Char_Table *ctbl;  
-#if 1 /* ifdef ERROR_CHECK_TYPECHECK */
+#ifdef ERROR_CHECK_TYPECHECK
   if (NILP (Fcategory_table_p (table)))
     signal_simple_error("Expected category table", table);
 #endif
@@ -1665,7 +1665,7 @@
 }
 
 DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /*
-Return t if category of a character at POS includes DESIGNATIOR,
+Return t if category of a character at POS includes DESIGNATOR,
 else return nil. Optional third arg specifies which buffer
 (defaulting to current), and fourth specifies the CATEGORY-TABLE,
 (defaulting to the buffer's category table).
@@ -1682,10 +1682,30 @@
   des = XREALINT(designator);
   ctbl = check_category_table (category_table, Vstandard_category_table);
   ch = BUF_FETCH_CHAR (buf, XINT(pos));
-  return (check_category_at(ch, ctbl, des, 0)
+  return (check_category_char(ch, ctbl, des, 0)
 	  ? Qt : Qnil);
 }
 
+DEFUN ("char-in-category-p", Fchar_in_category_p, 2, 3, 0, /*
+Return t if category of character CHR includes DESIGNATOR, else
+return nil. Optional third arg specifies the CATEGORY-TABLE to use,

