+ (goto-char start)))
+
+(defun egg-separate-languages (start end)
+ (let (lang last-lang last-chinese p l c cset)
+ (goto-char start)
+ (while (< (point) end)
+ (setq p (next-single-property-change (point) 'its-lang nil end))
+ (cond
+ ((get-text-property (point) 'its-lang)
+ (goto-char p))
+ ((setq l (egg-chinese-syllable (buffer-substring (point) p)))
+ (setq p (point))
+ (goto-char (+ (point) l))
+ (put-text-property p (point) 'its-lang "Chinese"))
+ ((progn
+ (setq c (following-char)
+ cset (char-charset c))
+ (eq cset 'chinese-sisheng))
+ (setq p (point))
+ (forward-char)
+ (put-text-property p (point) 'its-lang "Chinese"))
+ ((eq cset 'ascii)
+ (forward-char))
+ (t
+ (setq p (point))
+ (forward-char)
+ (put-text-property p (point) 'its-lang (egg-char-to-language c)))))
+ (goto-char start)
+ (while (< (point) end)
+ (setq lang (get-text-property (point) 'its-lang))
+ (cond
+ ((null lang)
+ (setq lang (or last-lang
+ (egg-next-part-lang end))))
+ ((equal lang "Chinese")
+ (setq lang (or last-chinese
+ (egg-next-chinese-lang end)))))
+ (setq last-lang lang)
+ (if (or (equal lang "Chinese-GB") (equal lang "Chinese-CNS"))
+ (setq last-chinese lang))
+ (setq p (point))
+ (goto-char (next-single-property-change (point) 'its-lang nil end))
+ (set-text-properties p (point) (list 'egg-lang lang)))))
+
+(defun egg-char-to-language (c)
+ (let ((charset (char-charset c))
+ (list language-info-alist))
+ (while (and list
+ (null (memq charset (assq 'charset (car list)))))
+ (setq list (cdr list)))
+ (car (car list))))
+
+(defun egg-next-part-lang (end)
+ (let* ((p (next-single-property-change (point) 'its-lang nil end))
+ (lang (get-text-property p 'its-lang)))
+ (if (equal lang "Chinese")
+ (egg-next-chinese-lang end)
+ (or lang
+ its-current-language
+ egg-default-language))))