Anonymous avatar Anonymous committed 2766777

Update to SKK 10.60.

Comments (0)

Files changed (26)

 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.15
-AUTHOR_VERSION = 10.38
-MAINTAINER = SL Baur <steve@xemacs.org>
+AUTHOR_VERSION = 10.60
+MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = skk
 PKG_TYPE = regular
-REQUIRES = viper mule-base elib xemacs-base
+REQUIRES = viper mule-base elib xemacs-base apel
 CATEGORY = mule
 
-ELCS = skk-foreword.elc skk-attr.elc skk-auto.elc skk-comp.elc \
-	skk-gadget.elc skk-isearch.elc skk-kakasi.elc skk-kcode.elc \
-	skk-leim.elc skk-menu.elc skk-num.elc skk-server.elc skk-tree.elc \
-	skk-tut.elc skk-vars.elc skk-vip.elc skk-viper.elc skk.elc
+ELCS = skk-foreword.elc skk-auto.elc skk-comp.elc \
+	skk-cursor.elc skk-develop.elc skk-gadget.elc skk-isearch.elc \
+	skk-kakasi.elc skk-kcode.elc skk-leim.elc skk-look.elc \
+	skk-num.elc skk-obsolete.elc skk-server.elc skk-tut.elc \
+	skk-vars.elc skk-viper.elc skk.elc
 
 DATA_FILES = $(wildcard etc/[RS]*)
 DATA_DEST = $(PACKAGE)
 texi:
 	$(MAKE) EMACS=$(XEMACS) -C texi info
 
-skk-vars.el:
-	rm -f skk-vars.el
-	$(XEMACS) -no-autoloads -batch -l ./make-vars.el -f make-skk-vars
+# skk-vars.el:
+# 	rm -f skk-vars.el
+# 	$(XEMACS) -no-autoloads -batch -l ./make-vars.el -f make-skk-vars
 
 srckit: srckit-std
 

Makefile-sm

-# Generated automatically from Makefile.in by configure.
-# Makefile for compiling SKK 10.x
-# $Id$
-# 
-SHELL = /bin/sh
-
-
-srcdir = .
-top_srcdir = ..
-
-INSTALL = /usr/bin/ginstall -c
-INSTALL_DATA = ${INSTALL} -m 644
-
-prefix = /usr/local
-datadir = ${prefix}/share
-
-EMACS = /usr/src/XEmacs/xemacs-20.3-pre1/src/xemacs
-ELISPDIR = $(datadir)/emacs/site-lisp
-
-SOURCES = stack-m.el queue-m.el string.el \
-	  skk-foreword.el skk.el skk-num.el skk-gadget.el skk-auto.el \
-          skk-comp.el skk-vip.el skk-viper.el skk-kakasi.el skk-kcode.el \
-          skk-server.el skk-tree.el skk-tut.el skk-isearch.el skk-menu.el \
-          skk-attr.el skk-leim.el
-
-COMPILED = stack-m.elc queue-m.elc string.elc \
-           skk-foreword.elc skk.elc skk-num.elc skk-gadget.elc skk-auto.elc \
-           skk-comp.elc skk-vip.elc skk-viper.elc skk-kakasi.elc skk-kcode.elc \
-           skk-server.elc skk-tree.elc skk-tut.elc skk-isearch.elc skk-menu.elc \
-           skk-attr.elc skk-leim.elc
-
-all: skk-vars.elc auto-autoloads.elc $(COMPILED)
-
-.SUFFIXES: .el .elc
-
-.el.elc:
-	$(EMACS) -batch -vanilla -f batch-byte-compile $<
-
-skk-vars.el:
-	rm -f skk-vars.el
-	$(EMACS) -batch -q -no-site-file -l ./make-vars.el -f make-skk-vars
-
-install: skk-vars.elc $(COMPILED)
-	$(top_srcdir)/mkinstalldirs $(ELISPDIR)
-	@list="$(SOURCES) skk-vars.el $(COMPILED) skk-vars.elc"; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo " $(INSTALL_DATA) $$p $(ELISPDIR)/"; \
-             $(INSTALL_DATA) $$p $(ELISPDIR)/; \
-          else :; fi; \
-        done
-
-TAGS: $(SOURCES)
-	etags $(SOURCES)
-
-.PHONY: clean
-clean:
-	-rm -f *~ $(COMPILED) skk-vars.el skk-vars.elc
-stack-m.elc: stack-m.el
-queue-m.elc: queue-m.el
-string.elc: string.el queue-m.el
-skk.elc: string.el queue-m.el skk-foreword.el
-skk-comp.elc: skk-comp.el skk-foreword.el skk.el stack-m.el
-skk-auto.elc: skk-auto.el skk-foreword.el skk.el
-skk-gadget.elc: skk-gadget.el skk-foreword.el skk.el
-skk-kakasi.elc: skk-kakasi.el skk-foreword.el skk.el
-skk-kcode.elc: skk-kcode.el skk-foreword.el skk.el
-skk-num.elc: skk-num.el skk-foreword.el skk.el
-skk-server.elc: skk-server.el skk-foreword.el skk.el
-skk-tree.elc: skk-tree.el skk-foreword.el skk.el
-skk-tut.elc: skk-tut.el skk-foreword.el skk.el
-skk-vip.elc: skk-vip.el skk-foreword.el skk.el
-skk-isearch.elc: skk-isearch.el skk-foreword.el skk.el
-skk-menu.elc: skk-menu.el skk.el
-skk-attr.elc: skk-attr.el skk.el
-skk-vars.el: stack-m.el queue-m.el string.el \
-             skk-foreword.el skk.el skk-num.el skk-gadget.el skk-auto.el \
-             skk-comp.el skk-vip.el skk-viper.el skk-kakasi.el skk-kcode.el \
-             skk-server.el skk-tree.el skk-tut.el skk-isearch.el skk-menu.el

make-vars.el

-;;
-;; make-vars.el -- make skk-vars.el
-;;
-
-(require 'autoload)
-
-(defvar skk-foreword-file "skk-foreword.el")
-(defvar skk-variable-file "skk-vars.el")
-(defvar skk-autoload-cookie ";;;###skk-autoload")
-
-(defvar skk-files
-  '("skk.el"
-    "skk-auto.el"
-    "skk-comp.el"
-    "skk-gadget.el"
-    "skk-isearch.el"
-    "skk-kakasi.el"
-    "skk-kcode.el"
-    "skk-menu.el"
-    "skk-num.el"
-    "skk-server.el"
-    "skk-tree.el"
-    "skk-vip.el"
-    "skk-viper.el" ))
-
-(defun make-skk-vars ()
-  (interactive)
-  (let* ((generated-autoload-file skk-variable-file)
-	 (buf (find-file-noselect generated-autoload-file))
-	 (generate-autoload-cookie skk-autoload-cookie)
-	 (coding-system-for-write 'junet)
-	 (file-coding-system '*junet*) )
-    (set-buffer buf)
-    (delete-region (point-min) (point-max))
-    (insert-string (format "(require '%s)\n"
-			   (file-name-sans-extension skk-foreword-file) ))
-    (mapcar
-     (function
-      (lambda (file)
-	(generate-file-autoloads file)))
-     skk-files)
-    (goto-char (point-max))
-    (insert-string (format "(provide '%s)\n"
-			   (file-name-sans-extension skk-variable-file) ))
-    (save-buffer)))

skk-attr.el

-;; -*-byte-compile-dynamic: t;-*-
-;;; skk-attr.el --- SKK $BC18lB0@-%a%s%F%J%s%9%W%m%0%i%`(B
-;; Copyright (C) 1997 Mikio Nakajima <minakaji@osaka.email.ne.jp>
-
-;; Author: Mikio Nakajima <minakaji@osaka.email.ne.jp>
-;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
-;; Version: $Id$
-;; Keywords: japanese
-;; Last Modified: $Date$
-
-;; This program 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 versions 2, or (at your option)
-;; any later version.
-
-;; This program 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 SKK, see the file COPYING.  If not, write to the Free
-;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
-;; MA 02111-1307, USA.
-
-;;; Commentary:
-
-;; Following people contributed modifications to skk.el (Alphabetical order):
-
-;;; Change log:
-
-;;; Code:
-(eval-when-compile (require 'skk))
-
-;;;###skk-autoload
-(defvar skk-attr-file (if (eq system-type 'ms-dos) "~/_skk-attr" "~/.skk-attr")
-  "*SKK $B$NC18l$NB0@-$rJ]B8$9$k%U%!%$%k!#(B")
-
-;;;###skk-autoload
-(defvar skk-attr-backup-file
-  (if (eq system-type 'ms-dos) "~/_skk-attr.BAK" "~/.skk-attr.BAK" )
-  "*SKK $B$NC18l$NB0@-$rJ]B8$9$k%U%!%$%k!#(B")
-
-;;;###skk-autoload
-(defvar skk-attr-search-function nil
-  "*skk-search-jisyo-file $B$,8uJd$r8+$D$1$?$H$-$K%3!<%k$5$l$k4X?t!#(B
-$B8+=P$78l!"Aw$j2>L>!"%(%s%H%j!<$N(B 3 $B0z?t$rH<$J$C$F!"(B
-skk-attr-default-update-function $B$,%3!<%k$5$l$?8e$K%3!<%k$5$l$k!#(B" )
-
-;;;###skk-autoload
-(defvar skk-attr-default-update-function
-  (function (lambda (midasi okurigana word purge)
-              (or skk-attr-alist (skk-attr-read))
-              (if purge
-                  (skk-attr-purge midasi okurigana word)
-                ;; time $BB0@-$K(B current-time $B$NJV$jCM$rJ]B8$9$k!#(B                
-                (skk-attr-put midasi okurigana word 'time (current-time)) )))
-  "*skk-search-jisyo-file $B$,8uJd$r8+$D$1$?$H$-$K%3!<%k$5$l$k4X?t!#(B
-$B8+=P$78l!"Aw$j2>L>!"%(%s%H%j!<$N(B 3 $B0z?t$rH<$J$C$F!"(B
-skk-attr-default-update-function $B$,%3!<%k$5$l$kA0$K%3!<%k$5$l$k!#(B" )
-
-;;;###skk-autoload
-(defvar skk-attr-update-function nil
-  "*skk-update-jisyo $B$NCf$G%3!<%k$5$l$k4X?t!#(B
-$B8+=P$78l!"Aw$j2>L>!"%(%s%H%j!<!"%Q!<%8$N(B 4 $B0z?t$rH<$J$C$F%3!<%k$5$l$k!#(B" )
-
-;;;###skk-autoload
-(defvar skk-attr-alist nil
-  "SKK $BB0@-$rE83+$9$k%(!<%j%9%H!#(B" )
-
-;; data structure
-;; $B$H$j$"$($:!"3FJQ49Kh$KB0@-$N99?7$r9T$J$$0W$$$h$&$K!"8+=P$78l$+$i3FB0@-$r0z(B
-;; $B=P$70W$$$h$&$K$9$k!#$3$&$d$C$F$7$^$&$H!"$"$kB0@-$r;}$DC18l$rH4$-=P$9$N$,LL(B
-;; $BE]$K$J$k$,!";_$`$rF@$J$$$+(B...$B!#(B
-;;
-;; $B9bB.2=$N$?$a$K(B 2 $B$D$N%O%C%7%e%-!<$r;}$D$h$&$K$9$k!#(B1 $B$D$O(B okuri-ari $B$+(B
-;; okuri-nasi $B$+!#(B2 $B$D$a$O8+=P$78l$N@hF,$NJ8;z!#(B
-;;
-;; '((okuri-ari . (("$B$"(B" . ("$B$"(Bt" .
-;;                          ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B"))
-;;                                  (time . (13321 10887 982100))
-;;                                  (anything . ...) )
-;;                          ("$B9g(B" . (okurigana . ("$B$C$F(B" "$B$C$?(B"))
-;;                                  (time . (13321 10953 982323)
-;;                                  (anything . ...) )
-;;                          ("$B2q(B" . (okurigana . ("$B$C$F(B"))
-;;                                  (time . (13321 10977 312335))
-;;                                  (anything . ...) ))
-;;                         ("$B$"$D$+(Bw" . ...) )
-;;                 ("$B$$(B" . ...) )
-;;   (okuri-nasi . (("$B$"(B" . ...) ("$B$$(B" . ...))) )
-;; 
-;; $B$7$+$7!"$3$&$$$&$b$N$r:n$k$H!"(B.skk-jisyo $B$H(B .skk-attr $B$NN>J}$r;}$D0UL#$,Gv(B
-;; $B$l$F$7$^$&$s$@$h$M(B...$B!#>e<j$/F0$1$P(B .skk-attr $B$KE}9g$7$F$bNI$$$1$I!"<-=q$N(B
-;; $B%a%s%F%J%s%9$,LLE]$K$J$k$+(B...$B!#(B
-
-(defsubst skk-attr-get-table (okuri-ari)
-  (assq (if okuri-ari 'okuri-ari 'okuri-nasi) skk-attr-alist) )
-
-(defsubst skk-attr-get-table-for-midasi (midasi okurigana)
-  ;; get all entries for MIDASI.
-  ;; e.g.
-  ;;  ("$B$"(Bt" . ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B"))
-  ;;                   (time . (13321 10887 982100))
-  ;;                   (anything . ...) )
-  ;;           ("$B9g(B" . (okurigana . ("$B$C$F(B" "$B$C$?(B"))
-  ;;                   (time . (13321 10953 982323)
-  ;;                   (anything . ...) )
-  ;;           ("$B2q(B" . (okurigana . ("$B$C$F(B"))
-  ;;                   (time . (13321 10977 312335))
-  ;;                   (anything . ...) ))
-  (assoc midasi (cdr (assoc (skk-substring-head-character midasi)
-                            (cdr (skk-attr-get-table okurigana)) ))))
-
-(defsubst skk-attr-get-table-for-word (midasi okurigana word)
-  ;; get a table for WORD.
-  ;; e.g.
-  ;;  ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B")) (time . (13321 10887 982100))
-  ;;          (anything . ...) )
-  (assoc word (cdr (skk-attr-get-table-for-midasi midasi okurigana))) )
-
-(defsubst skk-attr-get-all-attrs (midasi okurigana word)
-  ;; get all attributes for MIDASI and WORD.
-  ;; e.g.
-  ;; ((okurigana . "$B$?(B" "$B$F(B") (time . (13321 10887 982100)) (anything . ...))
-  (cdr (skk-attr-get-table-for-word midasi okurigana word)) )
-
-(defsubst skk-attr-get (midasi okurigana word name)
-  (assq name (skk-attr-get-all-attrs midasi okurigana word)) )
-  
-(defun skk-attr-put (midasi okurigana word name attr)
-  ;; add attribute ATTR for MIDASI, WORD and NAME.
-  ;; e.g.
-  ;; table := ("$B$"(Bt" . ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B"))
-  ;;                           (time . (13321 10887 982100))
-  ;;                           (anything . ...) )
-  ;;                   ("$B9g(B" . (okurigana . (("$B$C$F(B" "$B$C$?(B"))
-  ;;                           (time . (13321 10953 982323))
-  ;;                           (anything . ...) )
-  ;;                   ("$B2q(B" . (okurigana . ("$B$C$F(B"))
-  ;;                           (time . (13321 10977 312335))
-  ;;                           (anything . ...) ))
-  ;; entry := ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B")) (time . (13321 10887 982100))
-  ;;                  (anything . ...) )
-  ;; oldattr := (time . (13321 10887 982100))
-  ;;
-  (let* ((table (skk-attr-get-table-for-midasi midasi okurigana))
-         (entry (assoc word (cdr table)))
-         (oldattr (assq name (cdr entry))) )
-    (cond (oldattr
-           (cond ((eq name 'okurigana) ; anything else?
-                  (setcdr oldattr (cons attr (delete attr (nth 1 oldattr)))) )
-                 (t (setcdr oldattr attr)) ))
-          (entry (setcdr entry (cons (cons name attr) (cdr entry))))
-          ;; new entry
-          (t (skk-attr-put-1 midasi okurigana word name attr) ))))
-
-(defun skk-attr-put-1 (midasi okurigana word name attr)
-  ;; header := "$B$"(B"
-  ;; table := ((okuri-ari . (("$B$"(B" . ("$B$"(Bt" .
-  ;;                            ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B"))
-  ;;                                    (time . (13321 10887 982100))
-  ;;                                    (anything . ...) )
-  ;;                            ("$B9g(B" . (okurigana . ("$B$C$F(B" "$B$C$?(B"))
-  ;;                                    (time . (13321 10953 982323))
-  ;;                                    (anything . ...) )
-  ;;                            ("$B2q(B" . (okurigana . ("$B$C$F(B"))
-  ;;                                    (time . (13321 10977 312335))
-  ;;                                    (anything . ...) )))
-  ;; table2 := ("$B$"(B" . ("$B$"(Bt" .
-  ;;                            ("$BEv(B" . (okurigana . ("$B$?(B" "$B$F(B"))
-  ;;                                    (time . (13321 10887 982100))
-  ;;                                    (anything . ...) )
-  ;;                            ("$B9g(B" . (okurigana . ("$B$C$F(B" "$B$C$?(B"))
-  ;;                                    (time . (13321 10953 982323)
-  ;;                                    (anything . ...) )
-  ;;                            ("$B2q(B" . (okurigana . ("$B$C$F(B"))
-  ;;                                    (time . (13321 10977 312335))
-  ;;                                    (anything . ...) )))
-  (let* ((table (skk-attr-get-table okurigana))
-         (header (skk-substring-head-character midasi))
-         (table2 (assoc header (cdr table)))
-         (add (cons midasi (list
-                            (cons word
-                                  (if okurigana
-                                      ;; default attribute for okuri-ari
-                                      (list (cons 'okurigana (list okurigana))
-                                            ;; default attribute
-                                            ;;(cons 'midasi midasi)
-                                            ;; and new one
-                                            (cons name attr) )
-                                    (list
-                                     ;; default attribute
-                                     ;;(cons 'midasi midasi)
-                                     ;; and new one
-                                     (cons name attr) )))))))
-    (cond (table2
-           ;; header $B$"$j(B
-           (setcdr table2 (cons add (cdr table2))) )
-          ;; header $B$J$7(B
-          ((cdr table)
-           (setcdr table (cons (cons header (list add)) (cdr table))) )
-          (t (setcdr table (list (cons header (list add))))) )))
-
-(defun skk-attr-remove (midasi okurigana word name)
-  ;; delete attribute ATTR for MIDASI, WORD and NAME.
-  ;; e.g.
-  ;; attrs := ((okurigana . ("$B$?(B" "$B$F(B")) (time . (13321 10887 982100))
-  ;;           (anything . ...) )
-  ;; del := (time . (13321 10887 982100))
-  ;;
-  (let* ((table (skk-attr-get-all-attrs midasi okurigana word))
-         (del (assq name table)) )
-    (and del (setq table (delq del table))) ))
-
-;;;###skk-autoload
-(defun skk-attr-purge (midasi okurigana word)
-  ;; purge a whole entry for MIDASI and WORD.
-  (let* ((table (cdr (skk-attr-get-table-for-midasi midasi okurigana)))
-         (del (assoc word table)) )
-    (and del (setq del (delq del table))) ))
-    
-;;;###skk-autoload
-(defun skk-attr-read (&optional nomsg)
-  "skk-attr-file $B$+$iB0@-$rFI$_9~$`!#(B"
-  (interactive "P")
-  (skk-create-file
-   skk-attr-file
-   (if (not nomsg)
-       (if skk-japanese-message-and-error
-           "SKK $B$NB0@-%U%!%$%k$r:n$j$^$7$?(B"
-         "I have created an SKK attributes file for you" )))
-  (if (or (null skk-attr-alist)
-          (skk-yes-or-no-p (format "%s $B$r:FFI$_9~$_$7$^$9$+!)(B" skk-attr-file)
-                           (format "Reread %s?" skk-attr-file) ))
-      (let (;;(coding-system-for-read 'euc-japan)
-            enable-character-unification )
-        (save-excursion
-          (unwind-protect
-              (progn
-                (set-buffer (get-buffer-create " *SKK attr*"))
-                (erase-buffer)
-                (if (= (nth 1 (insert-file-contents skk-attr-file)) 0)
-                    ;; bare alist
-                    (insert "((okuri-ari) (okuri-nasi))") )
-                (goto-char (point-min))
-                (or nomsg
-                    (skk-message "%s $B$N(B SKK $BB0@-$rE83+$7$F$$$^$9(B..."
-                                 "Expanding attributes of %s ..."
-                                 (file-name-nondirectory skk-attr-file) ))
-                (setq skk-attr-alist (read (current-buffer)))
-                (or nomsg
-                    (skk-message
-                     "%s $B$N(B SKK $BB0@-$rE83+$7$F$$$^$9(B...$B40N;!*(B"
-                     "Expanding attributes of %s ...done"
-                     (file-name-nondirectory skk-attr-file) )))
-	    (message "%S" (current-buffer))
-	    ;; Why?  Without this line, Emacs 20 deletes the
-	    ;; buffer other than skk-attr's buffer.
-            (kill-buffer (current-buffer)) ))
-        skk-attr-alist )))
-
-;;;###skk-autoload
-(defun skk-attr-save (&optional nomsg)
-  "skk-attr-file $B$KB0@-$rJ]B8$9$k(B."
-  (interactive "P")
-  (if (and (null skk-attr-alist) (not nomsg))
-      (progn
-        (skk-message "SKK $BB0@-$r%;!<%V$9$kI,MW$O$"$j$^$;$s(B"
-                     "No SKK attributes need saving" )
-        (sit-for 1) )
-    (save-excursion
-      (if (not nomsg)
-          (skk-message "%s $B$K(B SKK $BB0@-$r%;!<%V$7$F$$$^$9(B..."
-                       "Saving SKK attributes to %s..." skk-attr-file ))
-      (and skk-attr-backup-file
-           (copy-file skk-attr-file skk-attr-backup-file
-                      'ok-if-already-exists 'keep-date ))
-      (set-buffer (find-file-noselect skk-attr-file))
-      (if skk-mule3
-          (progn
-            (if (not (coding-system-p 'iso-2022-7bit-short))
-                (make-coding-system
-                 'iso-2022-7bit-short
-                 2 ?J
-                 "Like `iso-2022-7bit' but no ASCII designation before SPC."
-                 '(ascii nil nil nil t t nil t) ))
-            (set-buffer-file-coding-system 'iso-2022-7bit-short) ))
-      (delete-region 1 (point-max))
-      ;; This makes slow down when we have a long attributes alist, but good
-      ;; for debugging.
-      (if skk-debug (pp skk-attr-alist (current-buffer))
-	(prin1 skk-attr-alist (current-buffer)) )
-      (write-file skk-attr-file)
-      (kill-buffer (current-buffer))
-      (if (not nomsg)
-          (skk-message "%s $B$K(B SKK $BB0@-$r%;!<%V$7$F$$$^$9(B...$B40N;!*(B"
-                       "Saving attributes to %s...done" skk-attr-file )))))
-
-;;(defun skk-attr-mapc (func seq)
-;;  ;; funcall FUNC every element of SEQ.
-;;  (let (e)
-;;    (while (setq e (car seq))
-;;      (setq seq (cdr seq))
-;;      (funcall func e) )))
-;;
-;;(defun skk-attr-get-all-entries (okuri-ari)
-;;  ;; remove hash tables of which key are headchar and midasi, and return all
-;;  ;; entries.
-;;  (let ((table (skk-attr-get-table okuri-ari))
-;;        minitable val entry )
-;;    (while table
-;;      (setq minitable (cdr (car table)))
-;;      (while minitable
-;;        (setq val (cons (car (cdr minitable)) val)
-;;              minitable (cdr minitable) ))
-;;      (setq table (cdr table)) )
-;;    val ))
-    
-;;;###skk-autoload
-(defun skk-attr-purge-old-entries ()
-  "$BD>6a$N(B 30 $BF|4V%"%/%;%9$,$J$+$C$?%(%s%H%j$r8D?M<-=q$+$i%Q!<%8$9$k!#(B"
-  (interactive)
-  (let ((table (cdr (skk-attr-get-table 'okuri-ari)))
-        (oldday (skk-attr-relative-time (current-time) -2592000)) )
-    (skk-attr-purge-old-entries-1 table oldday)
-    (setq table (cdr (skk-attr-get-table nil)))
-    (skk-attr-purge-old-entries-1 table oldday) ))
-
-(defun skk-attr-purge-old-entries-1 (table oldday)
-  ;; 30 days old
-  (let (skk-henkan-okuri-strictly
-        skk-henkan-strict-okuri-precedence
-        skk-henkan-key
-        skk-henkan-okurigana ;; have to bind it to nil
-        skk-okuri-char
-        skk-search-prog-list ;; not to work skk-public-jisyo-contains-p.
-        minitable )
-    ;; $B$3$&$$$&$N$r$b$C$H0lHLE*$K=hM}$G$-$k%^%/%m(B ($B4X?t$G$bNI$$$1$I(B) $B$G$b9M$((B
-    ;; $B$J$-$c$J$i$s$J(B...
-    (while table
-      (setq minitable (cdr (car table)))
-      (while minitable
-        (setq minimini (cdr (car minitable)))
-        (while minimini
-          (setq e (car minimini))
-          (if (skk-attr-time-lessp (cdr (assq 'time (cdr e))) oldday)
-              (progn
-                (setq skk-henkan-key (car (car minitable))
-                      skk-okuri-char (substring skk-henkan-key -1)
-                      ;; $B$3$l$8$c>C$($J$$$_$?$$$M(B...$B!#(B
-                      minimini (delq e minimini) )
-                (skk-update-jisyo (car e) 'purge) )
-            (setq minimini (cdr minimini)) ))
-        (setq minitable (cdr minitable)) )
-      (setq table (cdr table)) )))
-
-;; time utilities...
-;;  from ls-lisp.el.  Welcome!
-(defun skk-attr-time-lessp (time0 time1)
-  (let ((hi0 (car time0))
-	(hi1 (car time1))
-	(lo0 (nth 1 time0))
-	(lo1 (nth 1 time1)) )
-    (or (< hi0 hi1) (and (= hi0 hi1) (< lo0 lo1))) ))
-
-;; from timer.el.  Welcome!
-(defun skk-attr-relative-time (time secs &optional usecs)
-  ;; Advance TIME by SECS seconds and optionally USECS microseconds.
-  ;; SECS may be a fraction.
-  (let ((high (car time))
-	(low (if (consp (cdr time)) (nth 1 time) (cdr time)))
-	(micro (if (numberp (car-safe (cdr-safe (cdr time))))
-		   (nth 2 time)
-		 0)))
-    ;; Add
-    (if usecs (setq micro (+ micro usecs)))
-    (if (floatp secs)
-	(setq micro (+ micro (floor (* 1000000 (- secs (floor secs)))))))
-    (setq low (+ low (floor secs)))
-
-    ;; Normalize
-    (setq low (+ low (/ micro 1000000)))
-    (setq micro (mod micro 1000000))
-    (setq high (+ high (/ low 65536)))
-    (setq low (logand low 65535))
-
-    (list high low (and (/= micro 0) micro))))
-
-;; from type-break.el.  Welcome!
-(defun skk-attr-time-difference (a b)
-  ;; Compute the difference, in seconds, between a and b, two structures
-  ;; similar to those returned by `current-time'.
-  ;; Use addition rather than logand since that is more robust; the low 16
-  ;; bits of the seconds might have been incremented, making it more than 16
-  ;; bits wide.
-  ;;
-  ;; elp.el version...maybe more precisely.
-  ;;(+ (* (- (car end) (car start)) 65536.0)
-  ;;   (- (nth 1 end) (nth 1 start))
-  ;;   (/ (- (nth 2 end) (nth 2 start)) 1000000.0) )
-  ;;
-  (+ (lsh (- (car b) (car a)) 16)
-     (- (nth 1 b) (nth 1 a)) ))
-
-(add-hook 'skk-before-kill-emacs-hook 'skk-attr-save)
-
-(provide 'skk-attr)
-;;; skk-attr.el ends here
 ;;; skk-auto.el --- $BAw$j2>L>$N<+F0=hM}$N$?$a$N%W%m%0%i%`(B
-;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+;;               1999
 ;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
 
 ;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
 ;; Keywords: japanese
 ;; Last Modified: $Date$
 
-;; This program is free software; you can redistribute it and/or modify
+;; This file is part of SKK.
+
+;; SKK 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 versions 2, or (at your option)
 ;; any later version.
 
-;; This program is distributed in the hope that it will be useful
+;; SKK 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.
 ;; MA 02111-1307, USA.
 
 ;;; Commentary:
-;; Following people contributed modifications to skk-server.el (Alphabetic
-;; order):
-;;
-;;      Mikio Nakajima <minakaji@osaka.email.ne.jp>
-
-;;; Change log:
-;; version 1.0.6 released 1997.2.18 (derived from the skk.el 8.6)
 
 ;;; Code:
+(eval-when-compile (require 'skk))
 (require 'skk-foreword)
-(require 'skk-vars)
+
+;;;###autoload
+(defgroup skk-auto nil "SKK auto okuri process related customization."
+  :prefix "skk-"
+  :group 'skk )
 
 ;;; user variables
-(defvar skk-kana-rom-vector
-  ["x" "a" "x" "i" "x" "u" "x" "e" "x" "o" "k" "g" "k" "g" "k" "g"
-   "k" "g" "k" "g" "s" "z" "s" "j" "s" "z" "s" "z" "s" "z" "t" "d"
-   "t" "d" "x" "t" "d" "t" "d" "t" "d" "n" "n" "n" "n" "n" "h" "b"
-   "p" "h" "b" "p" "h" "b" "p" "h" "b" "p" "h" "b" "p" "m" "m" "m"
-   "m" "m" "x" "y" "x" "y" "x" "y" "r" "r" "r" "r" "r" "x" "w" "x"
-   "x" "w" "n"]
-  "*skk-remove-common $B$G;HMQ$9$k$+$JJ8;z$+$i%m!<%^;z$X$NJQ49%k!<%k!#(B
-$B2<5-$N3:Ev$9$k$+$JJ8;z$r$=$NJ8;z$N%m!<%^;z%W%l%U%#%C%/%9$G8=$o$7$?$b$N!#(B
-    $B$!(B  $B$"(B  $B$#(B  $B$$(B  $B$%(B  $B$&(B  $B$'(B  $B$((B  $B$)(B  $B$*(B  $B$+(B  $B$,(B  $B$-(B  $B$.(B  $B$/(B  $B$0(B
-    $B$1(B  $B$2(B  $B$3(B  $B$4(B  $B$5(B  $B$6(B  $B$7(B  $B$8(B  $B$9(B  $B$:(B  $B$;(B  $B$<(B  $B$=(B  $B$>(B  $B$?(B  $B$@(B
-    $B$A(B  $B$B(B  $B$C(B  $B$D(B  $B$E(B  $B$F(B  $B$G(B  $B$H(B  $B$I(B  $B$J(B  $B$K(B  $B$L(B  $B$M(B  $B$N(B  $B$O(B  $B$P(B
-    $B$Q(B  $B$R(B  $B$S(B  $B$T(B  $B$U(B  $B$V(B  $B$W(B  $B$X(B  $B$Y(B  $B$Z(B  $B$[(B  $B$\(B  $B$](B  $B$^(B  $B$_(B  $B$`(B
-    $B$a(B  $B$b(B  $B$c(B  $B$d(B  $B$e(B  $B$f(B  $B$g(B  $B$h(B  $B$i(B  $B$j(B  $B$k(B  $B$l(B  $B$m(B  $B$n(B  $B$o(B  $B$p(B
-    $B$q(B  $B$r(B  $B$s(B
-$B$=$l$>$l$N$+$JJ8;z$,Aw$j2>L>$G$"$k>l9g$K$I$N%m!<%^;z%W%l%U%#%C%/%9$rBP1~$5$;$k(B
-$B$N$+$r;XDj$9$k$3$H$,$G$-$k!#!V$8!W!"!V$A!W!"!V$U!W$NJ8;z$K$D$$$F!"BP1~$9$k%m!<(B
-$B%^;z%W%l%U%#%C%/%9$r(B \"z\", \"c\",\"f\" $B$KJQ99$r4uK>$9$k>l9g$b$"$k$G$"$m$&!#(B
-skk-auto-okuri-process $B$NCM$,(B non-nil $B$N$H$-$N$_;2>H$5$l$k!#(B" )
+(defcustom skk-okuri-search-function 'skk-okuri-search-subr-original
+  "*skk-okuri-search $B$G;HMQ$9$k4X?t!#(B"
+  :type 'function
+  :group 'skk-auto )
 
-(defvar skk-auto-load-hook nil
-  "*skk-auto.el $B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#(B" )
+(defcustom skk-auto-load-hook nil
+  "*skk-auto.el $B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#(B"
+  :type 'hook
+  :group 'skk-auto )
 
-;; internal valriables
-;;;###skk-autoload
-(skk-deflocalvar skk-henkan-in-minibuff-flag nil
-  "$B%_%K%P%C%U%!$G<-=qEPO?$r9T$C$?$H$-$K$3$N%U%i%0$,N)$D!#(B
-skk-remove-common $B$G;2>H$5$l$k!#(B" )
-
-(skk-deflocalvar skk-okuri-index-min -1
-  "skk-henkan-list $B$N%$%s%G%/%9$G<+F0Aw$j=hM}$G8!:w$7$?:G=i$N8uJd$r;X$9$b$N!#(B" )
-
-(skk-deflocalvar skk-okuri-index-max -1
-  "skk-henkan-list $B$N%$%s%G%/%9$G<+F0Aw$j=hM}$G8!:w$7$?:G8e$N8uJd$r;X$9$b$N!#(B" )
-
+;;;###autoload
 (defun skk-okuri-search ()
   ;; skk-auto-okuri-process $B$,(B non-nil $B$J$i$P(B "Uresii" $B$N$h$&$KAw$j2>L>$b4^$a(B
   ;; $B$F%?%$%W$7$F$bAw$j$"$j$N(B "$B4r$7$$(B" $B$rC5$7=P$9!#(B
            (> (length skk-henkan-key) skk-kanji-len) )
       (let (l)
         (setq skk-okuri-index-min (length skk-henkan-list)
-              l (skk-okuri-search-subr)
+              l (funcall skk-okuri-search-function)
               skk-okuri-index-max (+ skk-okuri-index-min (length l)) )
         l )))
 
-(defun skk-okuri-search-subr ()
+(defun skk-okuri-search-subr-original ()
   ;; skk-okuri-search $B$N%5%V%k!<%A%s!#8+$D$1$?%(%s%H%j$N%j%9%H$rJV$9!#(B
   (let* ((henkan-key skk-henkan-key)
          (key (substring henkan-key 0 skk-kanji-len))
          (len (length henkan-key))
          (key1 (concat "\n" key))
          key2 len2 key3 len3 okuri3
-         ;; $B8zN($,NI$$$h$&$K(B kanji-flag, mc-flag, enable-multibyte-characters
-         ;; $B$r(B nil $B$K$7$F$*$/!#(B
-         mc-flag
-         ;; enable-multibyte-characters
          ;; case-fold-search $B$O!"<-=q%P%C%U%!$G$O>o$K(B nil$B!#(B
          ;;case-fold-search
          (inhibit-quit t)
-         key-cand-alist p q r s )
+         key-cand-alist p q r )
     (save-match-data
       (with-current-buffer (skk-get-jisyo-buffer skk-jisyo)
         (goto-char skk-okuri-ari-min)
         (while (search-forward key1 skk-okuri-ari-max t)
           (setq p (point)
-                key2 (concat key (skk-buffer-substring
+                key2 (concat key (buffer-substring-no-properties
                                   p (- (search-forward " ") 2) ))
                 len2 (length key2) )
           (if (not (and (<= len2 len)
                (setq q (point)) )
               (while (and cont (search-forward "/[" q t))
                 (setq r (point))
-                (setq okuri3 (skk-buffer-substring r (1- (search-forward "/")))
+                (setq okuri3 (buffer-substring-no-properties
+			      r
+			      (1- (search-forward "/")) )
                       key3 (concat key2 okuri3)
                       len3 (length key3) )
                 (if (not (and (<= len3 len)
                     (while (not (eq (following-char) ?\]))
                       (setq cand
                             (concat
-                             (skk-buffer-substring
+                             (buffer-substring-no-properties
                               (point)
                               (1- (search-forward "/" skk-okuri-ari-max t)) )
                              okuri ))
                       (function (lambda (x y)
                                   (string< (car y) (car x)) ))))))))
 
-;;;###skk-autoload
-(defun skk-remove-common (word)
-  ;; skk-henkan-key $B$H(B word $B$N4V$K6&DL$NAw$j2>L>$r<h$j=|$-!"Aw$j2>L>0J30$NItJ,(B
-  ;; $B$NJ8;zNs$rJV$9!#(Bskk-henkan-key $B$H(B skk-henkan-okurigana $B$NCM$r%;%C%H$9$k!#(B
-  ;; $BNc$($P!"(Bword == $B;}$C$F$-$?(B $B$G$"$l$P!"(Bskk-henkan-key := "$B$b(Bt",
-  ;; skk-henkan-okurigana := "$B$C$F(B", word := "$B;}(B" $B$N$h$&$KJ,2r$7!"(Bword $B$rJV$9!#(B
-  ;; skk-auto-okuri-process $B$NCM$,(B non-nil $B$G$"$k$H$-$K$3$N4X?t$r;HMQ$9$k!#(B
-  (if (and (not (skk-numeric-p)) (not skk-abbrev-mode)
-           (or skk-henkan-in-minibuff-flag
-               (and (<= skk-okuri-index-min skk-henkan-count)
-                    (<= skk-henkan-count skk-okuri-index-max) )))
-      (let ((midasi skk-henkan-key)
-            (midasi-len (length skk-henkan-key))
-            (word-len (length word))
-            (kanji-len2 (* 2 skk-kanji-len))
-            (mc-flag t)
-            (enable-multibyte-characters t)
-            (cont t)
-            char pos pos2 midasi-tail word-tail new-word okuri-first
-            new-skk-henkan-key )
-        (if (not (and (>= midasi-len kanji-len2) (>= word-len kanji-len2)))
-            nil
-          ;; check if both midasi and word end with the same ascii char.
-          (if (and (eq (aref midasi (1- midasi-len)) (aref word (1- word-len)))
-                   (skk-alpha-char-p (aref midasi (1- midasi-len))) )
-              ;; if so chop off the char from midasi and word
-              (setq midasi (substring midasi 0 -1)
-                    midasi-len (1- midasi-len)
-                    word (substring word 0 -1)
-                    word-len (1- word-len) ))
-          (setq midasi-tail (substring midasi (- midasi-len skk-kanji-len)
-                                       midasi-len )
-                word-tail (substring word (- word-len skk-kanji-len)
-                                     word-len ))
-          ;; $B$b$&>/$7E83+$G$-$=$&$@$,!"%P%$%H%3%s%Q%$%i!<$,%*%W%F%#%^%$%:$7$d(B
-          ;; $B$9$$$h$&$K(B not $B$rIU$1$k$@$1$K$7$F$*$/!#(B
-          (if (not (and (string= midasi-tail word-tail)
-                        (or (and (skk-string<= "$B$!(B" midasi-tail)
-                                 (skk-string<= midasi-tail "$B$s(B") )
-                            (member midasi-tail '("$B!"(B" "$B!#(B" "$B!$(B" "$B!%(B")) )))
-              nil
-            (setq pos (- word-len skk-kanji-len)
-                  new-word new-skk-henkan-key )
-            (while (and cont (> pos 0))
-              (setq char (substring word (- pos skk-kanji-len) pos))
-              (if (and (skk-string<= "$B0!(B" char) (skk-string<= char "$Bt$(B"))
-                  ;; char is the right-most Kanji
-                  (setq cont nil)
-                (setq pos (- pos skk-kanji-len)) ))
-            (setq pos2 (- midasi-len (- word-len pos)))
-            ;; check if midasi and word has the same tail of length
-            (if (not (string= (substring midasi pos2 midasi-len)
-                              (substring word pos word-len) ))
-                nil
-              (setq okuri-first (substring word pos (+ pos skk-kanji-len)))
-              (setq skk-henkan-okurigana
-                    (if (and (string= okuri-first "$B$C(B")
-                             (<= (+ pos kanji-len2) word-len) )
-                        ;; in this case okuriga consits of two
-                        ;; characters, e.g., $B!V;D$C$?!W(B
-                        (substring word pos (+ pos kanji-len2))
-                      okuri-first ))
-              (setq new-word (substring word 0 pos))
-              (setq new-skk-henkan-key
-                    (concat
-                     (substring midasi 0 pos2)
-                     (cond ((string= okuri-first "$B$s(B")
-                            "n" )
-                           ((string= okuri-first "$B$C(B")
-                            (aref skk-kana-rom-vector
-                                  (- (string-to-char
-                                      (substring
-                                       skk-henkan-okurigana
-                                       (1- kanji-len2) kanji-len2 ))
-                                     161 )))
-                           (t (aref skk-kana-rom-vector
-                                    (- (string-to-char
-                                        (substring
-                                         skk-henkan-okurigana
-                                         (1- skk-kanji-len)
-                                         skk-kanji-len ))
-                                       161 ))))))
-              (if (not skk-henkan-in-minibuff-flag)
-                  (setq word new-word
-                        skk-henkan-key new-skk-henkan-key )
-                ;; ask if register as okuri-ari word.
-                (let (inhibit-quit) ; allow keyboard quit
-                  (if (y-or-n-p
-                       (format
-                        (if skk-japanese-message-and-error
-                            "%s /%s/ $B$rAw$j$"$j%(%s%H%j$H$7$FEPO?$7$^$9$+!)(B"
-                          "Shall I register this as okuri-ari entry: %s /%s/ ? " )
-                        new-skk-henkan-key new-word ))
-                      (setq word new-word
-                            skk-henkan-key new-skk-henkan-key )
-                    (setq skk-henkan-okurigana nil
-                          skk-okuri-char nil )
-                    (message "") ))))))))
-  ;; $BJ,2r$7$?(B word ($BAw$j2>L>ItJ,$r=|$$$?$b$N(B) $B$rJV$9!#(B
-  word )
-
-;;;###skk-autoload
-(defun skk-init-auto-okuri-variables ()
-  ;; skk-auto.el $B$NFbItJQ?t$r=i4|2=$9$k!#(B
-  (setq skk-henkan-in-minibuff-flag nil
-        skk-okuri-index-min -1
-        skk-okuri-index-max -1 ))
-
-;;;###skk-autoload
+;;;###autoload
 (defun skk-adjust-search-prog-list-for-auto-okuri ()
-  ;; skk-auto-okuri-process $B$,(B nil $B$G$"$l$P!"(Bskk-search-prog-list $B$+$i(B 
+  ;; skk-auto-okuri-process $B$,(B nil $B$G$"$l$P!"(Bskk-search-prog-list $B$+$i(B
   ;; '(skk-okuri-search) $B$r>C$7!"(Bnon-nil $B$G$"$l$P2C$($k!#(B
   ;;
   ;; '(skk-okuri-search) $B$r2C$($k0LCV$K$D$$$F$O!"(Bskk-jisyo $B$N8e$,:GNI$+$I$&$+(B
   (if (not skk-auto-okuri-process)
       (setq skk-search-prog-list
             (delete '(skk-okuri-search) skk-search-prog-list) )
-      (if (null (member '(skk-okuri-search) skk-search-prog-list))
-          (let ((pl skk-search-prog-list)
-                (n 0) dic mark )
-            (while pl
-              (setq dic (car pl))
-              (if (eq (nth 1 dic) 'skk-jisyo)
-                  (setq mark n
-                        pl nil)
-                (setq pl (cdr pl)
-                      n (1+ n) )))
-            (skk-middle-list skk-search-prog-list
-                             (1+ mark) '((skk-okuri-search)) )))))
+    (if (null (member '(skk-okuri-search) skk-search-prog-list))
+	(let ((pl skk-search-prog-list)
+	      (n 0) dic mark )
+	  (while pl
+	    (setq dic (car pl))
+	    (if (memq (nth 1 dic) '(skk-jisyo skk-rdbms-private-jisyo-table))
+		(setq mark n
+		      pl nil)
+	      (setq pl (cdr pl)
+		    n (1+ n) )))
+	  (skk-splice-in skk-search-prog-list (1+ mark)
+			 '((skk-okuri-search)) )))))
 
 ;;(add-hook 'skk-mode-hook 'skk-adjust-search-prog-list-for-auto-okuri)
 
 ;;; skk-comp.el --- $BJd40$N$?$a$N%W%m%0%i%`(B
 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+;;               1999
 ;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
 
 ;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
 ;; Keywords: japanese
 ;; Last Modified: $Date$
 
-;; This program is free software; you can redistribute it and/or modify
+;; This file is part of SKK.
+
+;; SKK 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 versions 2, or (at your option)
 ;; any later version.
 
-;; This program is distributed in the hope that it will be useful
+;; SKK 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.
 ;; MA 02111-1307, USA.
 
 ;;; Commentary:
-;; Following people contributed modifications to skk.el (Alphabetic order):
-;;      Hitoshi SUZUKI <h-suzuki@ael.fujitsu.co.jp>
-;;      Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; $B"&$5(B (TAB) -> $B"&$5$H$&(B (.) -> $B"&$5$$$H$&(B (,) -> $B"&$5$H$&(B(.) -> $B"&$5$$$H$&(B
 
-;;; Change log:
-;; version 1.2.1 released 1997.2.2 (derived from the skk.el 8.6)
-
 ;;; Code:
+(eval-when-compile (require 'skk))
 (require 'skk-foreword)
-(require 'skk-vars)
-;; Elib version 1.0 required.
-(require 'stack-m)
+
+;;;###autoload
+(defgroup skk-comp nil "SKK completion related customization."
+  :prefix "skk-"
+  :group 'skk )
 
 ;;; -- user variables
-(defvar skk-dabbrev-like-completion nil
-  "*Non-nil $B$G$"$l$P!"(Bdabbrev-expand $B$K;w$?8+=P$78l$NJd40$r9T$&!#(B
-$B$D$^$j!"(Bskk-insert-period $B$d(B skk-abbrev-period $B$GJd40$r9T$C$?>l9g$K!":G8e$KJd(B
-$B40$5$l$?8l$K$D$$$F99$KJd40$,9T$o$l$k!#(B
+(defcustom skk-dabbrev-like-completion nil
+  "*Non-nil $B$G$"$l$P!"8+=P$78l$NJd40$K$*$$$F!":G8e$KJd40$5$l$?8l$K$D$$$F99$KJd40$,9T$o$l$k!#(B
 $BNc$($P!"(B
 
-  \"$B$5(B\" -> \"$B$5$H$&(B\" -> \"$B$5$H$&$;$s$;$$(B\"
+  \"$B$5(B\" (,) -> \"$B$5$H$&(B\" (,) -> \"$B$5$H$&$;$s$;$$(B\"
 
 nil $B$G$"$l$P!"@hF,$NJ8;z$r6&DL$K$9$kJ8;zNs$K$D$$$FJd40$,9T$J$o$l$k!#(B
 $BNc$($P!"(B
 
-  \"$B$5(B\" -> \"$B$5$H$&(B\" -> \"$B$5$$$H$&(B\" -> \"$B$5$/$i(B\"" )
+  \"$B$5(B\" (,) -> \"$B$5$H$&(B\" (,) -> \"$B$5$$$H$&(B\" (,) -> \"$B$5$/$i(B\""
+  :type 'boolean
+  :group 'skk-comp )
 
-(defvar skk-comp-load-hook nil
-  "*skk-comp.el $B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#(B" )
+(defcustom skk-completion-function 'skk-completion-original
+  "*skk-completion $B$G;HMQ$9$k4X?t!#(B
+skk-comp.el $B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r(B funcall $B$9$k7A$K$7$F$*$/!#(B"
+  :type 'function
+  :group 'skk-comp )
+
+(defcustom skk-previous-completion-function 'skk-previous-completion-original
+  "*skk-previous-completion $B$G;HMQ$9$k4X?t!#(B
+skk-comp.el $B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r(B funcall $B$9$k7A$K$7$F$*$/!#(B"
+  :type 'function
+  :group 'skk-comp )
+
+(defcustom skk-comp-load-hook nil
+  "*skk-comp.el $B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#(B"
+  :type 'hook
+  :group 'skk-comp )
 
 ;;; -- internal variables
 ;; ---- buffer local variables
   "$BJd40$9$Y$-8+=P$78l!#(B
 skk-dabbrev-like-completion $B$,(B non-nil $B$N>l9g$O!">o$K:G8e$KJd40$7$?8+=P$78l$,(B
 $BBeF~$5$l$k!#(B" )
-;; $B<-=qEPO?;~%_%K%P%C%U%!$GJd40$7$?>l9g!"85$N%P%C%U%!$KLa$C$?$H$-$K(B 
+;; $B<-=qEPO?;~%_%K%P%C%U%!$GJd40$7$?>l9g!"85$N%P%C%U%!$KLa$C$?$H$-$K(B
 ;; skk-completion-word $B$NCM$,GK2u$5$l$F$$$J$$J}$,%Y%?!<!#(B
 
-;; skk-completion-stack $B$O%P%C%U%!%m!<%+%kCM$G$"$j!"$7$+$b(B stack-m.el $B$G$OGK2u(B
-;; $BE*$K%j%9%H$rA`:n$9$k$N$G=i4|CM$O(B nil $B$K$7$F$*$/I,MW$,$"$k!#(B
 (skk-deflocalvar skk-completion-stack nil
-  "$BJd40$7$?8l$rJ]B8$7$F$*$/%9%?%C%/!#(B
-skk-previous-completion $B$G$O!"%9%?%C%/$+$i%]%C%W$7$F0JA0$KJd40$7$?8l$KLa$k!#(B" )
+  "$BJd40$7$?8l$rJ]B8$7$F$*$/%9%?%C%/!#(B" )
 
-;;;###skk-autoload
+(skk-deflocalvar skk-completion-depth 0
+  "$BJd40$7$?8l$r(B skk-completion-stack $B$+$i<h$j=P$90LCV!#(B" )
+
+;;;###autoload
 (defun skk-start-henkan-with-completion (arg)
   "$B"&%b!<%I$GFI$_$NJd40$r9T$J$C$?8e!"JQ49$9$k!#(B
 $B$=$l0J30$N%b!<%I$G$O%*%j%8%J%k$N%-!<%^%C%W$K3d$jIU$1$i$l$?%3%^%s%I$r%(%_%e%l!<(B
         (skk-start-henkan arg) )
     (skk-emulate-original-map arg) ))
 
-;;;###skk-autoload
+;;;###autoload
 (defun skk-completion (first)
   ;; skk-try-completion $B$N%5%V%k!<%A%s!#(B
+  ;; skk-comp.el $B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r(B funcall $B$9$k7A$K$7$F$*$/!#(B
+  (funcall skk-completion-function first) )
+
+(defun skk-completion-original (first)
+  ;; default $B$N(B skk-completion-function.
   (let ((inhibit-quit t)
+	;; skk-num $B$,(B require $B$5$l$F$J$$$H(B buffer-local $BCM$r2u$962$l$"$j!#(B
         skk-num-list
         completion-word c-word )
-    (if first
-        (setq skk-completion-word
-              (skk-buffer-substring skk-henkan-start-point (point))
-              skk-completion-stack (stack-create) )
-      (if skk-dabbrev-like-completion
-          (setq skk-completion-word
-                (skk-buffer-substring skk-henkan-start-point (point)) )))
-    (if (string= skk-completion-word "")
-        (skk-error "$B6uJ8;z$+$iJd40$9$k$3$H$O$G$-$^$;$s!*(B"
-                   "Cannot complete an empty string!" ))
-    ;; skk-completion-word $B$O%P%C%U%!%m!<%+%kCM$J$N$G!"<-=q%P%C%U%!$K0\$kA0$K(B
-    ;; $B0l;~JQ?t$K0\$7JQ$($F$*$/!#(B
-    (setq completion-word skk-completion-word)
-    (with-current-buffer (skk-get-jisyo-buffer skk-jisyo)
-      (if first (goto-char skk-okuri-nasi-min))
-      (save-match-data
-        ;; $B8zN($,NI$$$h$&$K(B kanji-flag, mc-flag, enable-multibyte-characters
-        ;; $B$r(B nil $B$K$7$F$*$/!#(B
-        ;; case-fold-search $B$O!"<-=q%P%C%U%!$G$O>o$K(B nil$B!#(B
-        (let (mc-flag)
-          ;;enable-multibyte-characters)
-          (while
-              (and (not c-word)
-                   (search-forward
-                    (concat "\n" 
-                            (if skk-use-numeric-conversion
-                                (skk-compute-numeric-henkan-key completion-word)
-                              completion-word ))
-                    nil t ))
-            (if (eq (following-char) 32) ;SPC                      
-                nil
-              (setq c-word (concat completion-word
-                                   (skk-buffer-substring
-                                    ;; $B8+=P$78l$K6uGr$O4^$^$l$J$$!#(B" /" $B$r%5!<(B
-                                    ;; $B%A$9$kI,MW$O$J$$!#(B
-                                    (point) (1- (search-forward " ")) ))))))))
+    (skk-kana-cleanup 'force)
+    (and first (setq skk-completion-stack nil skk-completion-depth 0))
+    (and (or first skk-dabbrev-like-completion)
+	 (setq skk-completion-word
+	       (buffer-substring-no-properties skk-henkan-start-point (point)) ))
+    (and (string= skk-completion-word "")
+	 (skk-error "$B6uJ8;z$+$iJd40$9$k$3$H$O$G$-$^$;$s!*(B"
+		    "Cannot complete an empty string!" ))
+    (if (> skk-completion-depth 0)
+	;; ($B2a5n$KC5:w:Q$_$NFI$_$r%"%/%;%9Cf(B)
+	(setq skk-completion-depth (1- skk-completion-depth)
+	      c-word (nth skk-completion-depth skk-completion-stack))
+      ;; ($B?75,$NFI$_$r<-=q%P%C%U%!$+$iC5:w(B)
+      ;; skk-completion-word $B$O%P%C%U%!%m!<%+%kCM$J$N$G!"<-=q%P%C%U%!$K0\$kA0$K(B
+      ;; $B0l;~JQ?t$K0\$7JQ$($F$*$/!#(B
+      (setq completion-word skk-completion-word)
+      (with-current-buffer (skk-get-jisyo-buffer skk-jisyo)
+	(if first (goto-char skk-okuri-nasi-min))
+	(save-match-data
+	  ;; case-fold-search $B$O!"<-=q%P%C%U%!$G$O>o$K(B nil$B!#(B
+	  (while
+	      (and (not c-word)
+		   (search-forward
+		    (concat "\n"
+			    (if skk-use-numeric-conversion
+				(skk-num-compute-henkan-key completion-word)
+			      completion-word ))
+		    nil t ))
+	    (if (eq (following-char) ?\040) ;SPC
+		nil
+	      (setq c-word (concat completion-word
+				   (buffer-substring-no-properties
+				    ;; $B8+=P$78l$K6uGr$O4^$^$l$J$$!#(B" /" $B$r%5!<(B
+				    ;; $B%A$9$kI,MW$O$J$$!#(B
+				    (point) (1- (search-forward " ")) )))))))
+      (and (not c-word) skk-abbrev-mode skk-use-look
+	   (setq c-word (skk-look-completion)) )
+      ;; $B?75,$K8+$D$1$?$H$-$@$1(B cons $B$9$k!#(B
+      (setq skk-completion-stack (cons c-word skk-completion-stack)) )
     ;; $B<-=q%P%C%U%!$N30!#(B
     (if (not c-word)
-        (if skk-japanese-message-and-error
-            (error "\"%s\" $B$GJd40$9$Y$-8+=P$78l$O(B%s$B$"$j$^$;$s(B"
-                   skk-completion-word (if first "" "$BB>$K(B") )
-          (error "No %scompletions for \"%s\""
-                 (if first "" "more ") skk-completion-word ))
-      (stack-push skk-completion-stack c-word)
+	(progn
+	  (setq skk-completion-depth (1+ skk-completion-depth))
+	  (if skk-japanese-message-and-error
+	      (error "\"%s\" $B$GJd40$9$Y$-8+=P$78l$O(B%s$B$"$j$^$;$s(B"
+		     skk-completion-word (if first "" "$BB>$K(B") )
+	    (error "No %scompletions for \"%s\""
+		   (if first "" "more ") skk-completion-word )) )
       (delete-region skk-henkan-start-point (point))
       (insert c-word) )))
 
-;;;###skk-autoload
+;;;###autoload
 (defun skk-previous-completion ()
   ;; skk-abbrev-comma, skk-insert-comma $B$N%5%V%k!<%A%s!#D>A0$KJd40$r9T$C$?8+(B
   ;; $B=P$7$rA^F~$9$k!#(B
+  ;; skk-comp.el $B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r(B funcall $B$9$k7A$K$7$F$*$/!#(B
+  (funcall skk-previous-completion-function) )
+
+(defun skk-previous-completion-original ()
+  ;; default $B$N(B skk-previous-completion-function.
   (let ((inhibit-quit t)
-        c-word )
-    (setq c-word (stack-pop skk-completion-stack))
-    (if (string= c-word
-                 (skk-buffer-substring skk-henkan-start-point (point)) )
-        ;;(null (memq last-command '(skk-abbrev-comma skk-insert-comma)))
-        ;; $B%]%C%W$7$?8l$,%P%C%U%!$N%]%$%s%HD>A0$K$"$kJ8;zNs$HF1$8$@$C$?$i(B 1 $B$D(B
-        ;; $B<N$F$k!#(B
-        (setq c-word (stack-pop skk-completion-stack)) )
-    (delete-region skk-henkan-start-point (point))
+        (c-word 
+	 (progn
+	   (setq skk-completion-depth (1+ skk-completion-depth))
+	   (nth skk-completion-depth skk-completion-stack) )))
     (if c-word
-        (insert c-word)
-      (insert skk-completion-word)
+	(progn
+	  (delete-region skk-henkan-start-point (point))
+	  (insert c-word) )
+      (setq skk-completion-depth (1- skk-completion-depth))
       (skk-error "\"%s\"$B$GJd40$9$Y$-8+=P$78l$OB>$K$"$j$^$;$s(B"
                  "No more previous completions for \"%s\""
-                 skk-completion-word ))
-    (setq this-command 'skk-completion) ))
+                 skk-completion-word ))))
 
 (run-hooks 'skk-comp-load-hook)
 
 (provide 'skk-comp)
+;;; Local Variables:
+;;; End:
 ;;; skk-comp.el ends here
+;;; skk-cursor.el --- SKK cursor control.
+;; Copyright (C) 1996, 1997, 1998, 1999
+;; Masatake YAMATO <jet@airlab.cs.ritsumei.ac.jp>
+
+;; Author: Masatake YAMATO <jet@airlab.cs.ritsumei.ac.jp>
+;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Version: $Id$
+;; Keywords: japanese
+;; Last Modified: $Date$
+
+;; This file is part of SKK.
+
+;; SKK 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 versions 2, or (at your option) any later
+;; version.
+
+;; SKK 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 SKK, see the file COPYING.  If not, write to the Free
+;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
+;; MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; [Todo] Use `skk-cursor-' prefix for all variables and functions.
+;;   skk-default-cursor-color -> skk-cursor-default-color
+;;   skk-jisx0208-latin-cursor-color -> skk-cursor-jisx0208-latin-color
+;;   skk-katakana-cursor-color -> skk-cursor-katakana-color
+;;   skk-hiragana-cursor-color -> skk-cursor-hiragana-color
+;;   skk-latin-cursor-color -> skk-cursor-latin-color
+
+;;; Code:
+(eval-when-compile (require 'static) (require 'skk-foreword))
+
+;; User variables.
+;; $BJQ?tL>$N(B prefix $B$r(B skk-cursor- $B$KE}0l$9$l$P$3$N%0%k!<%W$,@8$-$F$/$k$s$@$,(B...
+;; 10.x $B$O$3$l0J>eJQ?tL>$rJQ99$7$J$$J}$,NI$$$H;W$&$N$G!"$3$N$^$^$K$7$F$*$/!#(B
+;;(defgroup skk-cursor nil "SKK cursor related customization."
+;;  :prefix "skk-"
+;;  :group 'skk)
+
+(defcustom skk-default-cursor-color
+  (if (eq skk-emacs-type 'xemacs)
+      (frame-property (selected-frame) 'cursor-color)
+    (cdr (assq 'cursor-color (frame-parameters (selected-frame)))))
+  "*SKK $B$N%*%U$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :group 'skk)
+
+(defcustom skk-hiragana-cursor-color (if (eq skk-background-mode 'light)
+					 "coral4"
+				       "pink" )
+  "*$B$+$J%b!<%I$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :type 'string
+  :group 'skk)
+
+(defcustom skk-katakana-cursor-color (if (eq skk-background-mode 'light)
+					 "forestgreen"
+				       "green" )
+  "*$B%+%?%+%J%b!<%I$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :type 'string
+  :group 'skk)
+
+(defcustom skk-jisx0208-latin-cursor-color "gold"
+  "*$BA43Q1Q;z%b!<%I$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :type 'string
+  :group 'skk)
+
+(defcustom skk-latin-cursor-color (if (eq skk-background-mode 'light)
+				      "ivory4"
+				    "gray" )
+  "*$B%"%9%-!<%b!<%I$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :type 'string
+  :group 'skk)
+
+(defcustom skk-abbrev-cursor-color "royalblue"
+  "*abbrev $B%b!<%I$r<($9%+!<%=%k?'!#(B
+skk-use-color-cursor $B$,(B non-nil $B$N$H$-$K;HMQ$5$l$k!#(B" 
+  :type 'string
+  :group 'skk)
+
+(defcustom skk-report-set-cursor-error t
+  "*Non-nil $B$G$"$l$P!"%+%i!<%^%C%W@Z$l$,5/$-$?>l9g!"%(%i!<%a%C%;!<%8$rI=<($9$k!#(B
+nil $B$G$"$l$P!"I=<($7$J$$!#(B" 
+  :type 'boolean
+  :group 'skk)
+
+;; functions.
+(defun skk-cursor-set-color (color)
+  ;; $B%+!<%=%k$N?'$r(B COLOR $B$KJQ99$9$k!#(B
+  (condition-case nil
+      (set-cursor-color color)
+    (error
+     (set-cursor-color skk-default-cursor-color)
+     (and skk-cursor-report-set-error
+	  (skk-message
+	   "$B%+%i!<%^%C%W@Z$l$G$9!#%G%#%U%)%k%H$N%+%i!<$r;H$$$^$9!#(B"
+	   "Color map is exhausting, use default cursor color" )))))
+
+(defun skk-cursor-change-when-ovwrt ()
+  (static-cond
+   ((eq skk-emacs-type 'xemacs) (setq bar-cursor overwrite-mode))
+   (t (if overwrite-mode
+	  (modify-frame-parameters (selected-frame) '((cursor-type bar . 3)))
+	(modify-frame-parameters (selected-frame) '((cursor-type . box)))))))
+
+(defun skk-cursor-set-properly (&optional color)
+  ;; $B%+%l%s%H%P%C%U%!$N(B SKK $B$N%b!<%I$K=>$$!"%+!<%=%k$N?'$rJQ99$9$k!#(B
+  ;; $B%*%W%7%g%J%k0z?t$N(B COLOR $B$,;XDj$5$l$?$H$-$O!"$=$N%+!<%=%k?'$r;H$&!#(B
+  ;; OVWRT $B%b!<%I$N$H$-$O%+!<%=%k$NI}$r>.$5$/$9$k!#(B
+   (if (not (get-buffer-window (current-buffer)))
+      nil
+    (if skk-use-color-cursor 
+	(skk-cursor-set-color 
+	 (cond (color)
+	       ((not skk-mode) skk-default-cursor-color)
+	       (skk-jisx0208-latin-mode
+		skk-jisx0208-latin-cursor-color)
+	       (skk-katakana skk-katakana-cursor-color)
+	       (skk-j-mode skk-hiragana-cursor-color)
+	       (t skk-latin-cursor-color))))
+    (and skk-use-cursor-change (skk-cursor-change-when-ovwrt))))
+
+;;; advices.
+(let ((funcs '(
+	       ;; cover to original Emacs functions.
+	       bury-buffer
+	       delete-frame
+	       delete-window
+	       execute-extended-command 
+	       kill-buffer
+	       other-window
+	       overwrite-mode
+	       pop-to-buffer
+	       select-frame
+	       select-window
+	       switch-to-buffer
+	       ;; cover to SKK functions.
+	       skk-auto-fill-mode 
+	       skk-gyakubiki-katakana-message 
+	       skk-gyakubiki-katakana-region 
+	       skk-gyakubiki-message 
+	       skk-hiragana-region 
+	       skk-hurigana-katakana-region 
+	       skk-hurigana-message 
+	       skk-hurigana-region 
+	       skk-jisx0201-region 
+	       skk-jisx0208-latin-region 
+	       skk-katakana-region 
+	       skk-latin-region 
+	       skk-mode 
+	       skk-romaji-message 
+	       skk-romaji-region 
+	       skk-save-jisyo 
+	       skk-toggle-kana)))
+  (while funcs
+    (eval
+     (`
+      (defadvice (, (intern (symbol-name (car funcs))))
+	(after skk-cursor-ad activate)
+	"$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+	;; $BJL$N%P%C%U%!$XHt$V%3%^%s%I$O(B skk-mode $B$,(B nil $B$G$b%+!<%=%k?'$rD4@0$9$kI,MW$,(B
+	;; $B$"$k!#(B
+	;; CLASS $B$O(B after.
+	(skk-cursor-set-properly))))
+    (setq funcs (cdr funcs))))
+
+(let ((funcs '(
+	       goto-line 
+	       insert-file 
+	       recenter 
+	       yank
+	       yank-pop 
+	       ;; cover to hilit functions.
+	       hilit-recenter 
+	       hilit-yank 
+	       hilit-yank-pop 
+	       ;; cover to VIP/Viper functions.
+	       vip-Append
+	       vip-Insert
+	       vip-insert
+	       vip-intercept-ESC-key 
+	       vip-open-line
+	       viper-Append
+	       viper-Insert
+	       viper-hide-replace-overlay 
+	       viper-insert
+	       viper-intercept-ESC-key
+	       viper-open-line
+	       )))
+  (while funcs
+    (eval
+     (`
+      (defadvice (, (intern (symbol-name (car funcs))))
+	(after skk-cursor-ad activate)
+	"$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+	;; skk-mode $B$,(B nil $B$+(B non-nil $B$+$NH=DjIU$-!#(B
+	;; CLASS $B$O(B after.
+	(and skk-mode (skk-cursor-set-properly)))))
+    (setq funcs (cdr funcs))))
+
+(let ((funcs '(abort-recursive-edit exit-minibuffer)))
+  (if (eq skk-emacs-type 'xemacs)
+      (setq funcs (cons 'minibuffer-keyboard-quit funcs)))
+  (while funcs
+    (eval
+     (`
+      (defadvice (, (intern (symbol-name (car funcs))))
+	(before skk-cursor-ad activate)
+	"$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+	;; $B%_%K%P%C%U%!$+$i85$N%+%l%s%H%P%C%U%!$rC5$7=P$7!"%+!<%=%k$r%;%C%H!#(B
+	;; CLASS $B$O(B before.
+	(with-current-buffer (skk-minibuffer-origin) (skk-cursor-set-properly)))))
+    (setq funcs (cdr funcs))))
+
+(defadvice skk-latin-mode (after skk-cursor-ad activate)
+  "$B%+!<%=%k?'$r(B skk-latin-cursor-color $B$KJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (skk-cursor-set-properly skk-latin-cursor-color))
+
+(defadvice skk-jisx0208-latin-mode (after skk-cursor-ad activate)
+  "$B%+!<%=%k?'$r(B skk-jisx0208-latin-cursor-color $B$KJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (skk-cursor-set-properly skk-jisx0208-latin-cursor-color))
+ 
+(defadvice skk-abbrev-mode (after skk-cursor-ad activate)
+  "$B1~$8%+!<%=%k?'$r(B skk-abbrev-cursor-color $B$KJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (skk-cursor-set-properly skk-abbrev-cursor-color))
+
+(defadvice skk-kakutei (after skk-cursor-ad activate)
+  "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (if (interactive-p) (skk-cursor-set-properly)))
+
+;; VIP/Viper related
+(defadvice skk-mode (after skk-viper-ad activate)
+  (add-hook 'viper-post-command-hooks
+	    (function (lambda () (and skk-mode (skk-set-cursor-properly))))
+	    'append 'local))
+
+;;; Hooks.
+(add-hook 'after-make-frame-hook 'skk-cursor-set-properly)
+(add-hook 'minibuffer-setup-hook 'skk-cursor-set-properly)
+(add-hook 'minibuffer-exit-hook 'skk-cursor-set-properly 'append)
+
+(defalias 'skk-set-cursor-color 'skk-cursor-set-color)
+(defalias 'skk-change-cursor-when-ovwrt 'skk-cursor-change-when-ovwrt)
+(defalias 'skk-set-cursor-properly 'skk-cursor-set-properly)
+
+;; $B:G=i$K(B load $B$5$l$?$H$-$O!"(Bskk-cursor adviced function $B$K$J$kA0$N4X?t$K$h$C$F(B
+;; $B8F$P$l$F$*$j!"(Badvice $B$,8z$$$F$J$$$N$G!"%H%C%W%l%Y%k$G%+!<%=%k$r9g$o$;$F$*$/!#(B
+(and (get-buffer-window (current-buffer))
+     ;; only first time when this file loaded.
+     ;;(not skk-mode-invoked)
+     (skk-cursor-set-properly skk-hiragana-cursor-color))
+
+;;; Hooks
+(add-hook 'isearch-mode-end-hook 'skk-cursor-set-properly 'append)
+
+(provide 'skk-cursor)
+;;; Local Variables:
+;;; End:
+;;; skk-cursor.el ends here
+;;; skk-develop.el --- support SKK developper.
+;; Copyright (C) 1999 Mikio Nakajima <minakaji@osaka.email.ne.jp>
+
+;; Author: Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Version: $Id$
+;; Keywords: japanese
+;; Last Modified: $Date$
+
+;; This file is not part of SKK yet.
+
+;; SKK 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 versions 2, or (at your option)
+;; any later version.
+
+;; SKK 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 SKK, see the file COPYING.  If not, write to the Free
+;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
+;; MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;; Code:
+(require 'skk)
+
+(defconst skk-ml-address "skk-develop@kuis.kyoto-u.ac.jp")
+
+;;;###autoload
+(defun skk-submit-bug-report ()
+  "SKK $B$N%P%0%l%]!<%H$r=q$/%a!<%k%P%C%U%!$rMQ0U$9$k!#(B
+mail-user-agent $B$r@_Dj$9$k$3$H$K$h$j9%$_$N%a!<%k%$%s%?!<%U%'%$%9$r;HMQ$9$k$3$H(B
+$B$,$G$-$k!#Nc$($P!"(BWanderlust $B$r;HMQ$7$?$$>l9g$O2<5-$N$h$&$K@_Dj$9$k!#(B
+
+    \(setq mail-user-agent 'wl-user-agent\) "
+  (interactive)
+  (require 'reporter)
+  (if (not (skk-y-or-n-p
+	    "SKK $B$K$D$$$F$N%P%0%l%]!<%H$r=q$-$^$9$+!)(B "
+	    "Do you really want to write a bug report on SKK? " ))
+      nil
+    (reporter-submit-bug-report
+     skk-ml-address
+     (concat "skk.el " (skk-version)
+	     (if (or (and (boundp 'skk-servers-list) skk-servers-list)
+		     (or (and (boundp 'skk-server-host) skk-server-host)
+			 (getenv "SKKSERVER") )
+		     ;; refer to DEFAULT_JISYO when skk-server-jisyo is nil.
+		     ;;(or (and (boundp 'skk-server-jisyo) skk-server-jisyo)
+		     ;;    (getenv "SKK_JISYO") )))
+		     )
+		 (progn
+		   (require 'skk-server)
+		   (concat ", skkserv; " (skk-server-version)
+			   (if (getenv "SKKSERVER")
+			       (concat ",\nSKKSERVER; "
+				       (getenv "SKKSERVER") ))
+			   (if (getenv "SKKSERV")
+			       (concat ", SKKSERV; "
+				       (getenv "SKKSERV") ))))))
+     (let ((base (list 'window-system
+		       'skk-auto-okuri-process
+		       'skk-auto-start-henkan
+		       'skk-egg-like-newline
+		       'skk-henkan-okuri-strictly
+		       'skk-henkan-strict-okuri-precedence
+		       'skk-kakutei-early
+		       'skk-process-okuri-early
+		       'skk-search-prog-list
+		       'skk-use-face
+		       'skk-use-viper )))
+       (and (boundp 'skk-henkan-face)
+	    (setq base (append base '(skk-henkan-face))) )
+       (and (boundp 'skk-server-host)
+	    (setq base (append base '(skk-server-host))) )
+       (and (boundp 'skk-server-prog)
+	    (setq base (append base '(skk-server-prog))) )
+       (and (boundp 'skk-servers-list)
+	    (setq base (append base '(skk-servers-list))) )
+       base ))))
+
+(eval-after-load "edebug"
+  '(progn
+     (def-edebug-spec skk-save-point t)
+     (def-edebug-spec skk-with-point-move t)
+     ))
+
+(eval-after-load "hilit19"
+  '(mapcar (function
+            (lambda (pattern)
+              (hilit-add-pattern
+               (car pattern) (cdr pattern)
+               (cond ((eq skk-background-mode 'mono)
+                      'bold )
+                     ((eq skk-background-mode 'light)
+                      'RoyalBlue )
+                     (t 'cyan) )
+               'emacs-lisp-mode )))
+           '(("^\\s *(skk-deflocalvar\\s +\\S +" . "")
+	     ("^\\s *(skk-defun-cond\\s +\\S +" . "")
+	     ("^\\s *(skk-defsubst-cond\\s +\\S +" . "") )))
+
+(eval-after-load "font-lock"
+  '(setq lisp-font-lock-keywords-2
+	 (nconc
+	  '(("^(\\(skk-defun-cond\\)[ \t'\(]*\\(\\sw+\\)?"
+	     (1 font-lock-keyword-face)
+	     (2 font-lock-variable-name-face) )
+	    ("^(\\(skk-defsubst-cond\\)[ \t'\(]*\\(\\sw+\\)?"
+	     (1 font-lock-keyword-face)
+	     (2 font-lock-variable-name-face) )
+	    ("^(\\(skk-deflocalvar\\)[ \t'\(]*\\(\\sw+\\)?"
+	     (1 font-lock-keyword-face)
+	     (2 font-lock-variable-name-face) ))
+	  lisp-font-lock-keywords-2 )))
+
+(provide 'skk-develop)
+;;; Local Variables:
+;;; End:
+;;; skk-develop.el ends here
 ;;; skk-foreword.el --- $BA0=q$-(B
-;; Copyright (C) 1997 Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Copyright (C) 1997, 1998, 1999 Mikio Nakajima <minakaji@osaka.email.ne.jp>
 
 ;; Author: Mikio Nakajima <minakaji@osaka.email.ne.jp>
-;; Maintainer: Murata Shuuichirou  <mrt@mickey.ai.kyutech.ac.jp>
+;; Maintainer: Hideki Sakurada <sakurada@kuis.kyoto-u.ac.jp>
+;;             Murata Shuuichirou  <mrt@astec.co.jp>
 ;;             Mikio Nakajima <minakaji@osaka.email.ne.jp>
 ;; Version: $Id$
 ;; Keywords: japanese
 ;; Last Modified: $Date$
 
-;; This program is free software; you can redistribute it and/or modify
+;; This file is not part of SKK yet.
+
+;; SKK 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 versions 2, or (at your option)
 ;; any later version.
 
-;; This program is distributed in the hope that it will be useful
+;; SKK 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.
 
 ;;; Commentary:
 
-;; $BA0$KDj5A$7$F$*$+$J$1$l$P$J$j$^$;$s!#$3$N%U%!%$%k$O!"$3$N$h(B
-;; $B$&$K!"JQ?t$N@k8@0JA0$KDj5A$7$F$*$+$J$1$l$P$J$i$J$$$b$N$r$^(B
-;; $B$H$a$?$b$N$G$9!#%f!<%6!<JQ?t$NDj5A$NA0$K!"$4$A$c$4$A$c$H%f(B
-;; $B!<%6!<$K6=L#$,$J$$$b$N$,JB$s$G$$$?$N$G$O!"%f!<%6!<%U%l%s%I(B
-;; $B%j!<$G$O$J$$$H9M$($k$+$i$G$9!#(B
-;; 
-;; Following people contributed modifications to skk-foreword.el (Alphabetical order):
-;;       Hideki Sakurada <sakurada@kuis.kyoto-u.ac.jp>
-;;       Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
+;; $B$3$N%U%!%$%k$O!"%f!<%6!<JQ?t$N@k8@<+BN$K;HMQ$9$k%^%/%m!"(Bskk-*.el $B$G(B
+;; $B;HMQ$9$k%^%/%m$J$I!"JQ?t$N@k8@0JA0!"(Bskk-*.el $B$N:G=i$KDj5A$7$F$*$+$J(B
+;; $B$1$l$P$J$i$J$$$b$N$r$^$H$a$?$b$N$G$9!#%f!<%6!<JQ?t$NDj5A$NA0$K!"$4(B
+;; $B$A$c$4$A$c$H%f!<%6!<$K6=L#$,$J$$$b$N$,JB$s$G$$$?$N$G$O!"%f!<%6!<%U(B
+;; $B%l%s%I%j!<$G$O$J$$$H9M$($k$+$i$G$9!#(B
+;;
+;;; Code:
+(cond ((or (and (boundp 'epoch::version) epoch::version)
+	   (string< (substring emacs-version 0 2) "18") )
+       (error "THIS SKK requires Emacs 19 or later") )
+      ((not (featurep 'mule))
+       (error "THIS SKK requires MULE features") ))
 
-;;; Change log:
+(eval-when-compile
+  (defvar skk-abbrev-cursor-color)
+  (defvar skk-abbrev-mode)
+  (defvar skk-abbrev-mode-string)
+  (defvar skk-current-rule-tree)
+  (defvar skk-default-cursor-color)
+  (defvar skk-downcase-alist)
+  (defvar skk-echo)
+  (defvar skk-hankaku-alist)
+  (defvar skk-henkan-count)
+  (defvar skk-henkan-list)
+  (defvar skk-hiragana-cursor-color)
+  (defvar skk-hiragana-mode-string)
+  (defvar skk-input-mode-string)
+  (defvar skk-j-mode)
+  (defvar skk-jisx0208-latin-cursor-color)
+  (defvar skk-jisx0208-latin-mode)
+  (defvar skk-jisx0208-latin-mode-string)
+  (defvar skk-kana-cleanup-command-list)
+  (defvar skk-kana-input-search-function)
+  (defvar skk-kana-start-point)
+  (defvar skk-katakana)
+  (defvar skk-katakana-cursor-color)
+  (defvar skk-katakana-mode-string)
+  (defvar skk-last-henkan-data)
+  (defvar skk-latin-cursor-color)
+  (defvar skk-latin-mode)
+  (defvar skk-latin-mode-string)
+  (defvar skk-look-completion-words)
+  (defvar skk-mode)
+  (defvar skk-prefix)
+  (defvar skk-previous-point)
+  (defvar skk-use-numeric-conversion) )
 
-;;; Code:
+(require 'advice)
 (require 'easymenu)
+;; APEL 9.22 or later required.
+(eval-when-compile (require 'static))
+(require 'poe)
+(require 'poem) ; requires pces.
+(require 'pcustom)
+(require 'alist)
+;; Elib 1.0 is required.
+(require 'queue-m)
+
+;;;###autoload
+(eval-and-compile
+  (defconst skk-emacs-type (cond ((string-match "XEmacs" emacs-version) 'xemacs)
+				 ((and (boundp 'mule-version)
+				       (string< "4.0" mule-version) 'mule4 ))
+				 ((and (boundp 'mule-version)
+				       (string< "3.0" mule-version) 'mule3 ))
+				 ((and (boundp 'mule-version)
+				       (string< "2.0" mule-version) 'mule2 )))))
+
+(defconst skk-package-data-directory
+  (if (boundp 'early-packages)
+      (let ((dirs (append (if early-package-load-path early-packages)
+			  (if late-package-load-path late-packages)
+			  (if last-package-load-path last-packages) ))
+	    dir )
+	(while (not (file-exists-p (setq dir (car dirs))))
+	  (setq dirs (cdr dirs)) )
+	(and dir
+	     (expand-file-name "skk" (expand-file-name "etc" dir)) ))))
+
+;;(princ (format "SKK-PACKAGE-DATA-DIRECTORY is %s\n"
+;;	       skk-package-data-directory ))
 
 ;; necessary macro and functions to be declared before user variable declarations.
 
+;;;; macros
+;; Why I use non-intern temporary variable in the macro --- see comment in
+;; save-match-data of subr.el of GNU Emacs. And should we use the same manner
+;; in the save-current-buffer, with-temp-buffer and with-temp-file macro
+;; definition?
+(defmacro skk-save-point (&rest body)
+  (` (let ((skk-save-point (point-marker)))
+       (unwind-protect
+	   (progn (,@ body))
+	 (goto-char skk-save-point)
+         (skk-set-marker skk-save-point nil) ))))
+
+(defmacro skk-message (japanese english &rest arg)
+  ;; skk-japanese-message-and-error $B$,(B non-nil $B$@$C$?$i(B JAPANESE $B$r(B nil $B$G$"$l(B
+  ;; $B$P(B ENGLISH $B$r%(%3!<%(%j%"$KI=<($9$k!#(B
+  ;; ARG $B$O(B message $B4X?t$NBh#20z?t0J9_$N0z?t$H$7$FEO$5$l$k!#(B
+  (append (list 'message (list 'if 'skk-japanese-message-and-error
+			       japanese english ))
+	  arg ))
+
+(defmacro skk-error (japanese english &rest arg)
+  ;; skk-japanese-message-and-error $B$,(B non-nil $B$@$C$?$i(B JAPANESE $B$r(B nil $B$G$"$l(B
+  ;; $B$P(B ENGLISH $B$r%(%3!<%(%j%"$KI=<($7!"%(%i!<$rH/@8$5$;$k!#(B
+  ;; ARG $B$O(B error $B4X?t$NBh#20z?t0J9_$N0z?t$H$7$FEO$5$l$k!#(B
+  (append (list 'error (list 'if 'skk-japanese-message-and-error
+			     japanese english ))
+	  arg ))
+
+(defmacro skk-yes-or-no-p (japanese english)
+  ;; skk-japanese-message-and-error $B$,(B non-nil $B$G$"$l$P!"(Bjapanese $B$r(B nil $B$G$"(B
+  ;; $B$l$P(B english $B$r%W%m%s%W%H$H$7$F(B yes-or-no-p $B$r<B9T$9$k!#(B
+  ;; yes-or-no-p $B$N0z?t$N%W%m%s%W%H$,J#;($KF~$l9~$s$G$$$k>l9g$O$3$N%^%/%m$r;H(B
+  ;; $B$&$h$j%*%j%8%J%k$N(B yes-or-no-p $B$r;HMQ$7$?J}$,%3!<%I$,J#;($K$J$i$J$$>l9g$,(B
+  ;; $B$"$k!#(B
+  (list 'yes-or-no-p (list 'if 'skk-japanese-message-and-error
+				   japanese english )))
+
+(defmacro skk-y-or-n-p (japanese english)
+  ;; skk-japanese-message-and-error $B$,(B non-nil $B$G$"$l$P!"(Bjapanese $B$r(B nil $B$G$"(B
+  ;; $B$l$P(B english $B$r%W%m%s%W%H$H$7$F(B y-or-n-p $B$r<B9T$9$k!#(B
+  (list 'y-or-n-p (list 'if 'skk-japanese-message-and-error
+				japanese english )))
+
+(defmacro skk-set-marker (marker position &optional buffer)
+  ;; $B%P%C%U%!%m!<%+%kCM$G$"$k(B skk-henkan-start-point, skk-henkan-end-point,
+  ;; skk-kana-start-point, $B$"$k$$$O(B skk-okurigana-start-point $B$,(B nil $B$@$C$?$i!"(B
+  ;; $B?75,%^!<%+!<$r:n$C$FBeF~$9$k!#(B
+  (list 'progn
+        (list 'if (list 'not marker)
+              (list 'setq marker (list 'make-marker)) )
+        (list 'set-marker marker position buffer) ))
+
 ;; From viper-util.el.  Welcome!
 (defmacro skk-deflocalvar (var default-value &optional documentation)
   (` (progn
        (make-variable-buffer-local '(, var))
      )))
 
-;; From emu.el of tm package.   Welcome!  Its original is defun-maybe.
-(defmacro skk-defunsoft (name &rest everything-else)
-  (or (fboundp name)
-      (` (or (fboundp (quote (, name)))
-             (defun (, name) (,@ everything-else)) ))))
+(defmacro skk-with-point-move (&rest form)
+  ;; $B%]%$%s%H$r0\F0$9$k$,%U%C%/$r<B9T$7$F$[$7$/$J$$>l9g$K;H$&!#(B
+  (` (unwind-protect
+	 (progn (,@ form))
+       (setq skk-previous-point (point)) )))
+
+(defmacro skk-face-on (object start end face &optional priority)
+  (static-cond
+   ((eq skk-emacs-type 'xemacs)
+    (` (let ((inhibit-quit t))
+	 (if (not (extentp (, object)))
+	     (progn
+	       (setq (, object) (make-extent (, start) (, end)))
+	       (if (not (, priority))
+		   (set-extent-face (, object) (, face))
+		 (set-extent-properties
+		  (, object) (list 'face (, face) 'priority (, priority)) )))
+	   (set-extent-endpoints (, object) (, start) (, end))  ))))
+   (t
+    (` (let ((inhibit-quit t))
+	 (if (not (overlayp (, object)))
+	     (progn
+	       (setq (, object) (make-overlay (, start) (, end)))
+	       (and (, priority) (overlay-put (, object) 'priority (, priority)))
+	       (overlay-put (, object) 'face (, face)) )
+	   (move-overlay (, object) (, start) (, end)) ))))))
 
 (put 'skk-deflocalvar 'lisp-indent-function 'defun)
-(put 'skk-defunsoft 'lisp-indent-function 'defun)
 
-;;(defun skk-get (symbol property-name &optional default)
-;;  ;; SYMBOL $B$NB0@-%j%9%H$K(B PROPERTY-NAME $B$H$$$&B0@-L>$,$"$l$P$=$NB0@-CM$rJV$9!#(B
-;;  ;; $B$J$1$l$P(B DEFAULT $B$rJV$9(B (DEFAULT $B$,;XDj$5$l$F$$$J$1$l$P(B NIL)$B!#B0@-L>$NHf(B
-;;  ;; $B3S$O!"(Beq $B$G9T$J$&!#(B
-;;  (if default
-;;      (let ((pl (memq property-name (symbol-plist symbol))))
-;;        (if pl (nth 1 pl) default) )
-;;    (get symbol property-name) ))
+;;;; inline functions
+(defsubst skk-file-exists-and-writable-p (file)
+  (and (setq file (expand-file-name file))
+       (file-exists-p file) (file-writable-p file) ))
+
+(defsubst skk-lower-case-p (char)
+  ;; CHAR $B$,>.J8;z$N%"%k%U%!%Y%C%H$G$"$l$P!"(Bt $B$rJV$9!#(B
+  (and (<= ?a char) (>= ?z char) ))
+
+(defsubst skk-downcase (char)
+  (or (cdr (assq char skk-downcase-alist)) (downcase char)) )
+
+(defsubst skk-mode-off ()
+  (setq skk-mode nil
+        skk-abbrev-mode nil
+        skk-latin-mode nil
+        skk-j-mode nil
+        skk-jisx0208-latin-mode nil
+        ;; j's sub mode.
+        skk-katakana nil )
+  ;; initialize
+  (setq skk-input-mode-string skk-hiragana-mode-string)
+  (force-mode-line-update)
+  (remove-hook 'pre-command-hook 'skk-pre-command 'local) )
+
+(defsubst skk-j-mode-on (&optional katakana)
+  (setq skk-mode t
+        skk-abbrev-mode nil
+        skk-latin-mode nil
+        skk-j-mode t
+        skk-jisx0208-latin-mode nil
+        ;; j's sub mode.
+        skk-katakana katakana )
+  ;; mode line
+  (setq skk-input-mode-string (if katakana skk-katakana-mode-string
+				skk-hiragana-mode-string ))
+  (force-mode-line-update) )
+
+(defsubst skk-latin-mode-on ()
+  (setq skk-mode t
+        skk-abbrev-mode nil
+        skk-latin-mode t
+        skk-j-mode nil
+        skk-jisx0208-latin-mode nil
+        ;; j's sub mode.
+        skk-katakana nil
+        skk-input-mode-string skk-latin-mode-string )
+  (force-mode-line-update) )
+
+(defsubst skk-jisx0208-latin-mode-on ()
+  (setq skk-mode t
+        skk-abbrev-mode nil
+        skk-latin-mode nil
+        skk-j-mode nil
+        skk-jisx0208-latin-mode t
+        ;; j's sub mode.
+        skk-katakana nil
+        skk-input-mode-string skk-jisx0208-latin-mode-string )
+  (force-mode-line-update) )
+
+(defsubst skk-abbrev-mode-on ()
+  (setq skk-mode t
+        skk-abbrev-mode t
+        skk-latin-mode nil
+        skk-j-mode nil
+        skk-jisx0208-latin-mode nil
+        ;; j's sub mode.
+        skk-katakana nil
+        skk-input-mode-string skk-abbrev-mode-string )
+  (force-mode-line-update) )
+
+(defsubst skk-in-minibuffer-p ()
+  ;; $B%+%l%s%H%P%C%U%!$,%_%K%P%C%U%!$+$I$&$+$r%A%'%C%/$9$k!#(B
+  (window-minibuffer-p (selected-window)) )
+
+(defsubst skk-insert-prefix (&optional char)
+  ;; skk-echo $B$,(B non-nil $B$G$"$l$P%+%l%s%H%P%C%U%!$K(B skk-prefix $B$rA^F~$9$k!#(B
+  (and skk-echo
+       ;; skk-prefix $B$NA^F~$r%"%s%I%%$NBP>]$H$7$J$$!#A^F~$7$?%W%l%U%#%C%/%9$O!"(B
+       ;; $B$+$JJ8;z$rA^F~$9$kA0$KA4$F>C5n$9$k$N$G!"$=$N4V!"(Bbuffer-undo-list $B$r(B
+       ;; t $B$K$7$F%"%s%I%%>pJs$rC_$($J$/$H$bLdBj$,$J$$!#(B
+       (let ((buffer-undo-list t))
+         (insert-and-inherit (or char skk-prefix)) )))
+
+(defsubst skk-erase-prefix (&optional clean)
+  ;; skk-echo $B$,(B non-nil $B$G$"$l$P%+%l%s%H%P%C%U%!$KA^F~$5$l$?(B skk-prefix $B$r>C(B
+  ;; $B$9!#%*%W%7%g%J%k0z?t$N(B CLEAN $B$,;XDj$5$l$k$H!"JQ?t$H$7$F$N(B skk-prefix $B$r(B
+  ;; null $BJ8;z$K!"(Bskk-current-rule-tree $B$r(B nil $B=i4|2=$9$k!#(B
+  ;;
+  ;; $B$+$JJ8;z$NF~NO$,$^$@40@.$7$F$$$J$$>l9g$K$3$N4X?t$,8F$P$l$?$H$-$J$I$O!"%P%C(B
+  ;; $B%U%!$KA^F~$5$l$F$$$k(B skk-prefix $B$O:o=|$7$?$$$,!"JQ?t$H$7$F$N(B skk-prefix $B$O(B
+  ;; null $BJ8;z$K$7$?$/$J$$!#(B
+  (and skk-echo skk-kana-start-point
+       (not (string= skk-prefix ""))	; fail safe.
+       ;; skk-prefix $B$N>C5n$r%"%s%I%%$NBP>]$H$7$J$$!#(B
+       (let ((buffer-undo-list t)
+	     (start (marker-position skk-kana-start-point)) )
+	 (and start
+	      (condition-case nil
+		  (delete-region start (+ start (length skk-prefix)))
+		(error
+		 (skk-set-marker skk-kana-start-point nil) 
+		 (setq skk-prefix ""
+		       skk-current-rule-tree nil ))))))
+  (and clean (setq skk-prefix ""
+		   skk-current-rule-tree nil ))) ; fail safe
+
+(defsubst skk-string<= (str1 str2)
+  ;; STR1 $B$H(B STR2 $B$H$rHf3S$7$F!"(Bstring< $B$+(B string= $B$G$"$l$P!"(Bt $B$rJV$9!#(B
+  (or (string< str1 str2) (string= str1 str2)) )
+
+(defsubst skk-do-auto-fill ()
+  ;; auto-fill-function $B$KCM$,BeF~$5$l$F$*$l$P!"(Bdo-auto-fill $B$r%3!<%k$9$k!#(B
+  (and auto-fill-function (funcall auto-fill-function)) )
+
+;;;; from dabbrev.el.  Welcome!
+;; $BH=Dj4V0c$$$rHH$9>l9g$"$j!#MW2~NI!#(B
+(defsubst skk-minibuffer-origin ()
+  (nth 1 (buffer-list)) )
+
+(defsubst skk-current-insert-mode ()
+  (cond (skk-abbrev-mode 'abbrev)
+	(skk-latin-mode 'latin)
+	(skk-jisx0208-latin-mode 'jisx0208-latin)
+	(skk-katakana 'katakana)
+	(skk-j-mode 'hiragana) ))
+
+(defsubst skk-numeric-p ()
+  (and skk-use-numeric-conversion (require 'skk-num) skk-num-list) )
+
+(defsubst skk-substring-head-character (string)
+  (char-to-string (string-to-char string)) )
+
+(defsubst skk-get-current-candidate-simply (&optional noconv)
+  (if (> 0 skk-henkan-count)
+      (skk-error "$B8uJd$r<h$j=P$9$3$H$,$G$-$^$;$s(B"
+		 "Cannot get current candidate" )
+    ;; (nth -1 '(A B C)) $B$O!"(BA $B$rJV$9$N$G!"Ii$G$J$$$+$I$&$+%A%'%C%/$9$k!#(B
+    (let ((word (nth skk-henkan-count skk-henkan-list)))
+      (and word
+	   (if (and (skk-numeric-p) (consp word))
+	       (if noconv (car word) (cdr word))
+	     word )))))
+
+;; convert skk-rom-kana-rule-list to skk-rule-tree.
+;; The rule tree follows the following syntax:
+;; <branch-list>    ::= nil | (<tree> . <branch-list>)
+;; <tree>         ::= (<char> <prefix> <nextstate> <kana> <branch-list>)
+;; <kana>         ::= (<$B$R$i$,$JJ8;zNs(B> . <$B%+%?%+%JJ8;zNs(B>) | nil
+;; <char>         ::= <$B1Q>.J8;z(B>
+;; <nextstate>    ::= <$B1Q>.J8;zJ8;zNs(B> | nil
+
+;; $B%D%j!<$K%"%/%;%9$9$k$?$a$N%$%s%?!<%U%'!<%9(B
+
+(defsubst skk-make-rule-tree (char prefix nextstate kana branch-list)
+  (list char
+	prefix
+	(if (string= nextstate "") nil nextstate)
+	kana
+	branch-list ))
+
+(defsubst skk-get-char (tree)
+  (car tree) )
+
+(defsubst skk-set-char (tree char)
+  (setcar tree char) )
+
+(defsubst skk-set-prefix (tree prefix)
+  (setcar (nthcdr 1 tree) prefix) )
+
+(defsubst skk-get-prefix (tree)
+  (nth 1 tree) )
+
+(defsubst skk-get-nextstate (tree)
+  (nth 2 tree) )
+
+(defsubst skk-set-nextstate (tree nextstate)
+  (if (string= nextstate "") (setq nextstate nil))
+  (setcar (nthcdr 2 tree) nextstate) )
+
+(defsubst skk-get-kana (tree)
+  (nth 3 tree) )
+
+(defsubst skk-set-kana (tree kana)
+  (setcar (nthcdr 3 tree) kana) )
+
+(defsubst skk-get-branch-list (tree)
+  (nth 4 tree) )
+
+(defsubst skk-set-branch-list (tree branch-list)
+  (setcar (nthcdr 4 tree) branch-list) )
+
+;; tree procedure for skk-kana-input.
+(defsubst skk-add-branch (tree branch)
+  (skk-set-branch-list tree (cons branch (skk-get-branch-list tree))) )
+
+(defsubst skk-select-branch (tree char)
+  (assq char (skk-get-branch-list tree)) )
+
+(defsubst skk-kana-cleanup (&optional force)
+  (let ((data (or
+	       (and skk-current-rule-tree
+		    (null (skk-get-nextstate skk-current-rule-tree))
+		    (skk-get-kana skk-current-rule-tree) )
+	       (and skk-kana-input-search-function
+		    (car (funcall skk-kana-input-search-function)) )))
+	kana )
+	(if (or force data)
+	    (progn
+	      (skk-erase-prefix 'clean)
+	      (setq kana (if (functionp data) (funcall data nil) data))
+	      (if (consp kana)
+		  (setq kana (if skk-katakana (car kana) (cdr kana))) )
+	      (if (stringp kana) (skk-insert-str kana))
+	      (skk-set-marker skk-kana-start-point nil)
+	      t ))))
+
+(defsubst skk-pre-command ()
+  (and (memq last-command '(skk-insert skk-previous-candidate))
+       (null (memq this-command skk-kana-cleanup-command-list))
+       (skk-kana-cleanup t) ))
+
+(defsubst skk-make-raw-arg (arg)
+  (cond ((= arg 1) nil)
+	((= arg -1) '-)
+	((numberp arg) (list arg)) ))
+
+(defsubst skk-unread-event (event)
+  ;; Unread single EVENT.
+  (setq unread-command-events (nconc unread-command-events (list event))) )
+
+(defsubst skk-after-point-move ()
+  (and (or (not skk-previous-point) (not (= skk-previous-point (point))))
+       (skk-get-prefix skk-current-rule-tree)
+       (skk-with-point-move (skk-erase-prefix 'clean)) ))
+
+(defsubst skk-get-last-henkan-data (key)
+  (cdr (assq key skk-last-henkan-data)) )
+
+(defsubst skk-put-last-henkan-data (key val)
+  (setq skk-last-henkan-data (put-alist key val skk-last-henkan-data)) )
 
 (defun skk-terminal-face-p ()
   (and (not window-system)
-       (fboundp 'frame-face-alist) ;; $BJQ?tL>$_$?$$$J4X?t$@$J(B...$B!#(B
+       ;;; XEmacs does not have this funciton...
+       (fboundp 'frame-face-alist) ; $BJQ?tL>$_$?$$$J4X?t$@$J(B...$B!#(B
        (fboundp 'selected-frame) ))
 
-;;; skk-defunsofts  Define nothing if it is already there.
-
-;; eval-after-load is not defined in XEmacs but after-load-alist is usable.
-;; See subr.el in XEmacs.
-(skk-defunsoft eval-after-load (file form)
-  (or (assoc file after-load-alist)
-      (setq after-load-alist (cons (list file) after-load-alist)))
-  (let ((elt (assoc file after-load-alist)))
-    (or (member form (cdr elt))
-        (nconc elt (list form))))
-  form )
-
-(skk-defunsoft set-cursor-color (color-name)
-  (set-frame-property (selected-frame) 'cursor-color
-                      (if (color-instance-p color-name)
-                          color-name
-                        (make-color-instance color-name))))
-
-(skk-defunsoft rassoc (key alist)
-  (cond ((null alist) nil)
-        ((and (consp (car alist))
-              (equal key (cdr (car alist))) (car alist)))
-        (t (rassoc key (cdr alist))) ))
-
-(skk-defunsoft add-to-list (list-var element)
-  (or (member element (symbol-value list-var))
-      (set list-var (cons element (symbol-value list-var))) ))
-
-;; mule-3 $B$G$O!"(Bcancel-undo-boundary $B$,$J$$!#(B    
-;; from mule-util.el
-(skk-defunsoft cancel-undo-boundary ()
-  ;; buffer-undo-list $B$N(B car $B$N(B nil $B$r>C$7!"(Bundo $B%3%^%s%I$,D>6a$N%P%C%U%!(B
-  ;; $B$NJQ99$G;_$^$i$J$$$h$&$K$9$k!#(Bbuffer-undo-list $B$K$*$1$k(B nil $B$O!"JQ(B
-  ;; $B9972$HJQ9972$N6-3&$r<($9%G%j%_%?$NF/$-$r$7$F$$$k!#(B
-  (if (and (consp buffer-undo-list)
-           ;; car $B$,(B nil $B$@$C$?$i$=$l$r>C$9!#(B
-           (null (car buffer-undo-list)) )
-      (setq buffer-undo-list (cdr buffer-undo-list)) ))
-
-(skk-defunsoft match-string (n str)
-  (substring str (match-beginning n) (match-end n)) )
-
-;;;; version specific matter.
-(eval-and-compile
-  (defconst skk-xemacs (and (featurep 'mule)
-			    (string-match "XEmacs" emacs-version) )
-    "Non-nil $B$G$"$l$P!"(BXEmacs $B$G(B SKK $B$r;HMQ$7$F$$$k$3$H$r<($9!#(B" )
-  
-  (defconst skk-mule3 (and (featurep 'mule) (boundp 'mule-version)
-                           (string< "3.0" mule-version))
-    "Non-nil $B$G$"$l$P!"(BMule 3 $B$G(B SKK $B$r;HMQ$7$F$$$k$3$H$r<($9!#(B" )
-  
-  (defconst skk-mule (featurep 'mule)
-    "Non-nil $B$G$"$l$P!"(BMule $B$G(B SKK $B$r;HMQ$7$F$$$k$3$H$r<($9!#(B" )
-
-  (defconst skk-20 (or skk-mule3 skk-xemacs)
-    "Non-nil $B$G$"$l$P!"(BEmacs $B$N(B ver. 20 $B$G(B SKK $B$r;HMQ$7$F$$$k$3$H$r<($9!#(B" )
-
-  (cond ((or (and (boundp 'epoch::version) epoch::version)
-             (string< (substring emacs-version 0 2) "18") )
-         (message "THIS SKK requires Emacs 19")
-         (sit-for 2) )
-        ;; for XEmacs
-        (skk-xemacs
-         (defalias 'skk-buffer-substring 'buffer-substring-no-properties)
-         (defalias 'skk-character-to-event 'character-to-event)
-         (defalias 'skk-event-to-character 'event-to-character)
-         (defalias 'skk-int-char 'int-char)
-         (defalias 'skk-read-event 'next-command-event)
-         (defsubst skk-unread-event (event)
-           ;; Unread single EVENT.
-           (setq unread-command-events
- 		 (nconc unread-command-events (list event))) )
-         (defalias 'skk-make-overlay 'make-extent)
-         (defalias 'skk-move-overlay 'set-extent-endpoints)
-         (defalias 'skk-overlay-put 'set-extent-property)
-         (defalias 'skk-overlayp 'extentp)
-         (defalias 'skk-delete-overlay 'detach-extent)
-	 (defalias 'skk-charsetp 'find-charset)
-	 (defalias 'skk-char-to-string 'char-to-string)
-	 (defun skk-make-char (charset n1 n2)
-	   (make-char charset
-		      (logand (lognot 128) n1)
-		      (logand (lognot 128) n2) ))
-         ;; skk-kana-input-event-type
-         ;; (event $B$G$J$/J8;z$r0z?t$K$H$k$h$&$K$7$?$N$G(B,
-         ;;  skk-kana-input-char-type $B$NL>A0$r;H$$$^$7$?(B)
-         (defun skk-kana-input-char-type (char)
-           ;; "Return type of CHAR for `skk-kana-input'."
-           ;; CHAR is character or nil
-           (cond ((and char
-                       (<= 0 char) (< char (length skk-char-type-vector)))
-                  ;; this is normal ascii char
-                  (aref skk-char-type-vector char))
-                 ;; if you want to perform delete by event other than ascii
-                 ;; keystroke event, following clause should be modified to
-                 ;; return type 5 when apropriciate.
-                 (t nil) ))
-
-         (defmacro with-output-to-temp-buffer (bufname &rest body)
-           (let ((obuf (make-symbol "obuf"))
-                 (buf (make-symbol "buf")) )
-             `(let ((,obuf (current-buffer))
-                    (,buf (get-buffer-create ,bufname))
-                    standard-output  )
-                (set-buffer ,buf)
-                (erase-buffer)
-                (setq standard-output ,buf)
-                ,@body
-                (pop-to-buffer ,buf) )))
-
-	 (defmacro with-current-buffer (buffer &rest body)
-	   "Execute the forms in BODY with BUFFER as the current buffer.
-             The value returned is the value of the last form in BODY.
-             See also `with-temp-buffer'."
-	   (` (save-current-buffer
-	      (set-buffer (, buffer))
-	      (,@ body))))
-	 
-	 (defmacro with-temp-file (file &rest forms)
-	   "Create a new buffer, evaluate FORMS there, and write the buffer to FILE.
-             The value of the last form in FORMS is returned, like `progn'.
-             See also `with-temp-buffer'."
-	   (let ((temp-file (make-symbol "temp-file"))
-		 (temp-buffer (make-symbol "temp-buffer")))
-	     (` (let (((, temp-file) (, file))
-		    ((, temp-buffer)
-		     (get-buffer-create (generate-new-buffer-name " *temp file*"))))
-		(unwind-protect
-		    (prog1
-			(with-current-buffer (, temp-buffer)
-			  (,@ forms))
-		      (with-current-buffer (, temp-buffer)
-			(widen)
-			(write-region (point-min) (point-max) (, temp-file) nil 0)))
-		  (and (buffer-name (, temp-buffer))
-		       (kill-buffer (, temp-buffer))))))))
-	 (defmacro combine-after-change-calls (&rest body)
-	   (` (unwind-protect
-		(let ((combine-after-change-calls t))
-		  . (, body))
-	      (combine-after-change-execute))))
-	 (defmacro combine-after-change-execute (&rest body)
-	   body )
-         )
-        ;; for Emacs 19
-        (t
-         (defmacro skk-character-to-event (char) char);; $B2?$b$7$J$$(B
-         (defmacro skk-int-char (char) char);; $B2?$b$7$J$$(B
-         (defsubst skk-unread-event (event)
-           ;; Unread single EVENT.
-           (setq unread-command-events
- 		 (nconc unread-command-events (list event))))
-         (defalias 'skk-read-event 'read-event)
-         (defalias 'skk-make-overlay 'make-overlay)
-         (defalias 'skk-move-overlay 'move-overlay)
-         (defalias 'skk-overlay-put 'overlay-put)
-         (defalias 'skk-overlayp 'overlayp)
-         (defalias 'skk-delete-overlay 'delete-overlay)
-         (defun skk-event-to-character (event)
-           ;; Return character of keystroke EVENT.
-           (cond ((symbolp event)
-                  ;; mask is (BASE-TYPE MODIFIER-BITS) or nil.
-                  (let ((mask (get event 'event-symbol-element-mask)))
-                    (if mask
-                        (let ((base (get (car mask) 'ascii-character)))
-                          (if base
-                              (logior base (car (cdr mask))))))))
-                 ((integerp event)
-                  event)
-                 (t nil) ))
-         (defun skk-kana-input-char-type (event)
-           ;; "Return type of EVENT for `skk-kana-input'."
-           (cond ((and (integerp event)
-                       (<= 0 event) (< event (length skk-char-type-vector)))
-                  ;; this is normal ascii keystroke event
-                  (aref skk-char-type-vector event))
-                 ;; if you want to perform delete by event other than ascii
-                 ;; keystroke event, following clause should be modified to
-                 ;; return type 5 when apropriciate.
-                 (t nil) ))
-
-	 ;; overwrite built-in combine-after-change-execute
-	 (defmacro combine-after-change-execute (&rest body)
-	   body )
-	 (defmacro combine-after-change-calls (&rest body)
-	   (` (unwind-protect
-		  (let ((combine-after-change-calls t))
-		    . (, body))
-		(combine-after-change-execute))))
-	 (if skk-mule3
-	     nil
-
-           (defmacro with-output-to-temp-buffer (bufname &rest body)
-             (let ((obuf (make-symbol "obuf"))
-                   (buf (make-symbol "buf")) )
-               `(let ((,obuf (current-buffer))
-                      (,buf (get-buffer-create ,bufname))
-                      standard-output  )
-                  (set-buffer ,buf)
-                  (erase-buffer)
-                  (setq standard-output ,buf)
-                  ,@body
-                  (pop-to-buffer ,buf) )))
-
-	   (defmacro save-current-buffer (&rest body)
-	     (let ((orig-buffer (make-symbol "orig-buffer")))
-	       (` (let (((, orig-buffer) (current-buffer)))
-		    (unwind-protect
-			(progn (,@ body))
-		      (set-buffer (, orig-buffer)) )))))
-	   
-	   (defmacro with-current-buffer (buffer &rest body)
-	     "Execute the forms in BODY with BUFFER as the current buffer.
-	      The value returned is the value of the last form in BODY.
-	      See also `with-temp-buffer'."
-	      (` (save-current-buffer
-		   (set-buffer (, buffer))
-		   (,@ body))))
-	   
-	   (defmacro with-temp-file (file &rest forms)
-	     "Create a new buffer, evaluate FORMS there, and write the buffer to FILE.
-	      The value of the last form in FORMS is returned, like `progn'.
-	      See also `with-temp-buffer'."
-	      (let ((temp-file (make-symbol "temp-file"))
-		    (temp-buffer (make-symbol "temp-buffer")))
-		(` (let (((, temp-file) (, file))
-			 ((, temp-buffer)
-			  (get-buffer-create (generate-new-buffer-name " *temp file*"))))
-		     (unwind-protect
-			 (prog1
-			     (with-current-buffer (, temp-buffer)
-			       (,@ forms))
-			   (with-current-buffer (, temp-buffer)
-			     (widen)
-			     (write-region (point-min) (point-max) (, temp-file) nil 0)))
-		       (and (buffer-name (, temp-buffer))
-			    (kill-buffer (, temp-buffer))))))))
-	   
-	   (defmacro with-temp-buffer (&rest forms)
-	     "Create a temporary buffer, and evaluate FORMS there like `progn'.
-	      See also `with-temp-file' and `with-output-to-string'."
-	      (let ((temp-buffer (make-symbol "temp-buffer")))
-		(` (let (((, temp-buffer)
-			  (get-buffer-create (generate-new-buffer-name " *temp*"))))
-		     (unwind-protect
-			 (with-current-buffer (, temp-buffer)
-			   (,@ forms))
-		       (and (buffer-name (, temp-buffer))
-			    (kill-buffer (, temp-buffer))))))))
-	   
-	   (defmacro with-output-to-string (&rest body)
-	     "Execute BODY, return the text it sent to `standard-output', as a string."
-	      (` (let ((standard-output
-			(get-buffer-create (generate-new-buffer-name " *string-output*"))))
-		   (let ((standard-output standard-output))
-		     (,@ body))
-		   (with-current-buffer standard-output
-		     (prog1
-			 (buffer-string)
-		       (kill-buffer nil)))))))
-	 (cond
-	  ((string< "20" emacs-version)
-	   ;; For emacs 20
-	   (defalias 'skk-charsetp 'charsetp)
-	   (defalias 'skk-make-char 'make-char)
-	   (defalias 'skk-buffer-substring 'buffer-substring-no-properties)
-	   (defun skk-char-to-string (char)
-	     (condition-case nil
-		 (char-to-string char)
-	       (error
-		nil ))))
-	  ((string< "19.29" emacs-version)
-	   ;; For emacs 19.29, 19.30...
-	   (defalias 'skk-charsetp 'character-set)