Commits

Anonymous committed 2cfbe6e

package standards update, many bugfixes

Comments (0)

Files changed (7)

+1999-07-14  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg-wnn.el (diced-mode-map): Set the default binding to
+	`undefined'.
+	* egg-sj3.el (diced-mode-map): Ditto.
+	* egg.el (fence-mode-map): Ditto.
+
+1999-07-12  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg-wnn.el (henkan-mode-map): Don't bother to define each keys
+	as `undefined'.
+	* egg-sj3.el (henkan-mode-map): Ditto.
+
+	* egg-sj3.el (henkan-quit): Sync up with the last change of
+	egg-wnn.el.
+	(henkan-region-internal): Ditto.
+	(henkan-kakutei): Ditto.
+
+1999-07-11  Masahiro MURATA   <muse@ba2.so-net.ne.jp>
+
+	* egg-wnn.el (henkan-quit): go back to fence mode after the
+	henkan-quit.
+	(henkan-region-internal): Bug fix: set egg:*region-end* to
+	marker.
+
+1999-07-10  Takeshi Yamada   <yamada@cslab.kecl.ntt.co.jp>
+
+	* egg.el (fence-exit-internal): Exit from fence-mode-map before
+	delete-region calls are made, otherwise undesirable deadlock can
+	happen when delete-region is somehow failed.
+
+	* wnn-egg.el (henkan-kakutei): Exit from hekan-mode-map and
+	fence-mode-map before delete-region calls are made, otherwise
+	undesirable deadlock can happen when delete-region is somehow
+	failed.
+	(henkan-kakutei-first-char): Ditto.
+
+1999-07-09  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg-wnn.el (TopLevel): Set the default binding of
+	`henkan-mode-map' and `henkan-mode-esc-map' in the way of XEmacs.
+	* egg-sj3.el (TopLevel): Ditto.
+
+1999-07-01  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg.el (menu:goto-nth-element): Use `event-to-character' insted
+	of `event-key' for allowing keys [kp-0] .. [kp-9].
+	(minibuffer-local-menu-map): Add definitions for some keys.
+
+1999-06-28  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg.el (notify-internal): Enclose `bury-buffer' with
+	`save-window-excursion' for the use of minibufferless frames.
+
+	* egg-sj3-client.el (sj3-get-result): Bind `focus-follows-mouse' to
+	t while waiting for the process output.  It is needed for the use
+	of minibufferless frames.
+	(sj3-get-stdy): Remove codes for debugging.
+	(sj3-get-convert-string): Ditto.
+	(sj3-get-string): Ditto.
+	(sj3-get-byte): Ditto.
+	(sj3-get-4byte): Ditto.
+
+	* egg-wnn.el (set-dict-comment): Ignore non existent dictionaries.
+	(egg:toroku-word): Ditto.
+
+1999-06-17  Takeshi Yamada    <yamada@cslab.kecl.ntt.co.jp>
+            Masahiro MURATA   <muse@ba2.so-net.ne.jp>
+            Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg.el (menu:select-from-menu): menu handling parts are
+	completely rewritten by adopting codes originally submitted by
+	YAMAMOTO Mitsuharu <mituharu@is.s.u-tokyo.ac.jp> to the mule-jp
+	mailing list back in 1995. The menu keymap is no more hard coded!
+
+1999-06-27  Masahiro MURATA   <muse@ba2.so-net.ne.jp>
+
+	* egg.el (notify-internal): Bind `focus-follows-mouse' to t while
+	sleeping.  It is needed for the use of minibufferless frames.
+
+1999-06-25  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* egg.el (hankaku-region): Use `split-char' instead of `char-octet'.
+	(katakana-region): Ditto.
+	(hiragana-region): Ditto.
+	* egg-sj3-client.el (sj3-put-kata): Ditto.
+
+	* egg-wnn.el (sai-henkan): Ignore `disable-undo'.
+	(henkan-region-internal): Ditto.
+	(*egg-message-alist*): Put vocabulary entries in brackets.
+
 1999-06-15  Katsumi Yamaoka   <yamaoka@jpl.org>
 
 	* egg-sj3.el (henkan-quit): Bug-fix - fence string remained and
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.18
+VERSION = 1.19
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = egg-its

egg-sj3-client.el

     ;;;(goto-char (point-min))
     (while (< (point-max) (+ point 4))
       (accept-process-output)
-      (if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed.")))
+      ;;(if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed.")))
       (setq c (1+ c)))
     (goto-char point))
 
   (let ((c 0) (point (point)))
     (while (< (point-max) (1+ point))
       (accept-process-output)
-      (if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed.")))
+      ;;(if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed.")))
       (setq c (1+ c)))
     (goto-char point)
     (prog1
     (let ((c 0))
       (while (eobp)
 	(accept-process-output)
-	(if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed")))
+	;;(if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed")))
 	(setq c (1+ c))
 	(skip-chars-forward "^\0")))
     (prog1 
     (while (not (search-forward "\0" nil t))
       (accept-process-output)
       (goto-char point)
-      (if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed")))
+      ;;(if (= c 10) (if t (progn (sit-for 0) (setq c 0)) (error "Count exceed")))
       (setq c (1+ c)))
     (setq str (buffer-substring point (1- (point))))
     (delete-region point (point))
   (let ((c 0) (point (point)))
     (while (< (point-max) (+ point sj3-stdy-size))
       (accept-process-output)
-      (if (>= c 10) (progn (sit-for 0) (setq c 0))) ;;; delete error
+      ;;(if (>= c 10) (progn (sit-for 0) (setq c 0))) ;;; delete error
       (setq c (1+ c)))
     (goto-char (+ point sj3-stdy-size))))
 
 (defun sj3-get-result ()
   (set-buffer sj3-server-buffer)
   (condition-case ()
-      (accept-process-output sj3-server-process)
+      (let ((focus-follows-mouse t))
+	(accept-process-output sj3-server-process))
     (error nil))
   (goto-char (point-min)))
 
 	    (if (and (/= ?$B!<(B ch)
 		     (string-match "\\cH" (char-to-string ch)))
 		(make-char (find-charset 'japanese-jisx0208) 37
-			   (char-octet ch 1))
+			   (nth 2 (split-char ch)))
 	      ch))
       (incf i))
     (insert str 0)))
 		  (or (markerp egg:*region-start*)
 		      (setq egg:*region-start* (make-marker)))
 		  (or (markerp egg:*region-end*)
-		      (setq egg:*region-end*
-			    (set-marker-insertion-type (make-marker) t)))
+		      (set-marker-insertion-type
+		       (setq egg:*region-end* (make-marker)) t))
 		  (if (null (marker-position egg:*region-start*))
 		      (progn
                       ;;;(setq egg:*global-map-backup* (current-global-map))
   (interactive)
   (egg:bunsetu-face-off)
   (egg:henkan-face-off)
+  (setq egg:henkan-mode-in-use nil)
+  (setq egg:*in-fence-mode* nil)
   (delete-region (- egg:*region-start* (length egg:*henkan-open*))
 		 egg:*region-start*)
   (delete-region egg:*region-start* egg:*region-end*)
       (setq i (1+ i))
       ))
   (KKCP:henkan-end)
-  (setq egg:henkan-mode-in-use nil)
   (egg:quit-egg-mode)
   )
 
   (delete-region egg:*region-start* egg:*region-end*)
   (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*henkan-close*)))
   (goto-char egg:*region-start*)
-  (if egg:*in-fence-mode*
-      (progn
-	(insert egg:*fence-open*)
-	(set-marker egg:*region-start* (point))
-	(insert egg:*kanji-kanabuff*)
-	(let ((point (point)))
-	  (insert egg:*fence-close*)
-	  (set-marker egg:*region-end* point)
-	  )
-	(goto-char egg:*region-end*)
-	(egg:fence-face-on)
-	(KKCP:henkan-quit)
-	(setq egg:*mode-on* t))
-    (resume-undo-list)
-    (insert egg:*kanji-kanabuff*)
-    (KKCP:henkan-quit)
-    (set-marker egg:*region-start* nil)
-    (set-marker egg:*region-end*   nil))
+  (insert egg:*fence-open*)
+  (set-marker egg:*region-start* (point))
+  (insert egg:*kanji-kanabuff*)
+  (let ((point (point)))
+    (insert egg:*fence-close*)
+    (set-marker egg:*region-end* point)
+    )
+  (goto-char egg:*region-end*)
+  (egg:fence-face-on)
+  (KKCP:henkan-quit)
+  (setq egg:*mode-on* t)
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
   ;;(use-local-map fence-mode-map)
+  (setq egg:*in-fence-mode* t)
   (egg:mode-line-display)
   )
 
   (henkan-kakutei))
 
 
-(defvar henkan-mode-map (make-keymap))
-
-(defvar henkan-mode-esc-map (make-keymap))
-
-(let ((ch 0))
-  (while (<= ch 127)
-    (unless (eq ch 27)
-      (define-key henkan-mode-map (make-string 1 ch) 'undefined))
-    (define-key henkan-mode-esc-map (make-string 1 ch) 'undefined)
-    (setq ch (1+ ch))))
+(defvar henkan-mode-map (make-sparse-keymap))
+(defvar henkan-mode-esc-map (make-sparse-keymap))
+(set-keymap-default-binding henkan-mode-map 'undefined)
+(set-keymap-default-binding henkan-mode-esc-map 'undefined)
 
 (let ((ch 32))
   (while (< ch 127)
     (setq ch (1+ ch))))
 
 (condition-case ()
-    (define-key henkan-mode-map "\e"    henkan-mode-esc-map)
+    (define-key henkan-mode-map "\e" henkan-mode-esc-map)
   (error nil))
-(define-key henkan-mode-map "\ei"  'undefined) ;; henkan-inspect-bunsetu
-					       ;; not support for sj3
-(define-key henkan-mode-map "\es"  'henkan-select-kouho)
-(define-key henkan-mode-map "\eh"  'henkan-hiragana)
-(define-key henkan-mode-map "\ek"  'henkan-katakana)
-(define-key henkan-mode-map "\e<"  'henkan-saishou-bunsetu)
-(define-key henkan-mode-map "\e>"  'henkan-saichou-bunsetu)
+(define-key henkan-mode-map [escape] henkan-mode-esc-map)
+(define-key henkan-mode-esc-map "i" 'henkan-bunsetu-chijime)
+(define-key henkan-mode-esc-map "o" 'henkan-bunsetu-nobasi)
+(define-key henkan-mode-esc-map "s" 'henkan-select-kouho)
+(define-key henkan-mode-esc-map "h" 'henkan-hiragana)
+(define-key henkan-mode-esc-map "k" 'henkan-katakana)
+(define-key henkan-mode-esc-map "<" 'henkan-saishou-bunsetu)
+(define-key henkan-mode-esc-map ">" 'henkan-saichou-bunsetu)
+
 (define-key henkan-mode-map " "    'henkan-next-kouho)
 (define-key henkan-mode-map "\C-@" 'henkan-next-kouho)
 (define-key henkan-mode-map "\C-a" 'henkan-first-bunsetu)
 (define-key henkan-mode-map "\C-b" 'henkan-backward-bunsetu)
 (define-key henkan-mode-map "\C-c" 'henkan-quit)
-(define-key henkan-mode-map "\C-d" 'undefined)
 (define-key henkan-mode-map "\C-e" 'henkan-last-bunsetu)
 (define-key henkan-mode-map "\C-f" 'henkan-forward-bunsetu)
 (define-key henkan-mode-map "\C-g" 'henkan-quit)
-(define-key henkan-mode-map "\C-h" 'help-command)
+(define-key henkan-mode-map "\C-h" 'henkan-help-command)
 (define-key henkan-mode-map "\C-i" 'henkan-bunsetu-chijime)
-(define-key henkan-mode-map "\C-j" 'undefined)
 (define-key henkan-mode-map "\C-k" 'henkan-kakutei-before-point)
 (define-key henkan-mode-map "\C-l" 'henkan-kakutei)
 (define-key henkan-mode-map "\C-m" 'henkan-kakutei)
 (define-key henkan-mode-map "\C-n" 'henkan-next-kouho)
 (define-key henkan-mode-map "\C-o" 'henkan-bunsetu-nobasi)
 (define-key henkan-mode-map "\C-p" 'henkan-previous-kouho)
-(define-key henkan-mode-map "\C-q" 'undefined)
-(define-key henkan-mode-map "\C-r" 'undefined)
-(define-key henkan-mode-map "\C-s" 'undefined)
-(define-key henkan-mode-map "\C-t" 'undefined)
-(define-key henkan-mode-map "\C-u" 'undefined)
-(define-key henkan-mode-map "\C-v" 'undefined)
-(define-key henkan-mode-map "\C-w" 'undefined)
-(define-key henkan-mode-map "\C-x" 'undefined)
-(define-key henkan-mode-map "\C-y" 'undefined)
-(define-key henkan-mode-map "\C-z" 'undefined)
 (define-key henkan-mode-map "\177" 'henkan-quit)
+(define-key henkan-mode-map [backspace] 'henkan-quit)
+(define-key henkan-mode-map [clear]     'henkan-quit)
+(define-key henkan-mode-map [delete]    'henkan-quit)
+(define-key henkan-mode-map [down]      'henkan-next-kouho)
+(define-key henkan-mode-map [help]      'henkan-help-command)
+(define-key henkan-mode-map [kp-enter]  'henkan-kakutei)
+(define-key henkan-mode-map [kp-down]   'henkan-next-kouho)
+(define-key henkan-mode-map [kp-left]   'henkan-backward-bunsetu)
+(define-key henkan-mode-map [kp-right]  'henkan-forward-bunsetu)
+(define-key henkan-mode-map [kp-up]     'henkan-previous-kouho)
+(define-key henkan-mode-map [left]      'henkan-backward-bunsetu)
+(define-key henkan-mode-map [next]      'henkan-next-kouho)
+(define-key henkan-mode-map [prior]     'henkan-previous-kouho)
+(define-key henkan-mode-map [return]    'henkan-kakutei)
+(define-key henkan-mode-map [right]     'henkan-forward-bunsetu)
+(define-key henkan-mode-map [up]        'henkan-previous-kouho)
 
 (unless (assq 'egg:henkan-mode-in-use minor-mode-map-alist)
   (setq minor-mode-map-alist
 "
  )
 
-(defvar diced-mode-map (let ((map (make-keymap))) (suppress-keymap map) map))
+(defvar diced-mode-map (make-sparse-keymap))
+(set-keymap-default-binding diced-mode-map 'undefined)
 
 (define-key diced-mode-map "a"    'diced-add)
 (define-key diced-mode-map "d"    'diced-delete)
 (define-key diced-mode-map "\e>"  'diced-end-of-buffer)
 (define-key diced-mode-map "\ev"  'diced-scroll-down)
 
+(define-key diced-mode-map [down]  'diced-next-line)
+(define-key diced-mode-map [help]  'help-command)
+(define-key diced-mode-map [next]  'diced-next-line)
+(define-key diced-mode-map [prior] 'previous-line)
+(define-key diced-mode-map [up]    'previous-line)
+
 ;;; egg-sj3.el ends here
       (register-notify "$B<-=q9`L\!X(B%s$B!Y(B(%s: %s)$B$r(B%s$B$KEPO?$7$^$9!#(B")
       (cannot-remove "$B%7%9%F%`<-=q9`L\$O:o=|$G$-$^$;$s!#(B")
       (enter-hindo "$BIQEY$rF~$l$F2<$5$$(B: ")
-      (remove-notify "$B<-=q9`L\(B%s(%s)$B$r(B%s$B$+$i:o=|$7$^$9!#(B")
-      (removed "$B<-=q9`L\(B%s(%s)$B$r(B%s$B$+$i:o=|$7$^$7$?!#(B")
+      (remove-notify "$B<-=q9`L\!X(B%s$B!Y(B(%s)$B$r(B%s$B$+$i:o=|$7$^$9!#(B")
+      (removed "$B<-=q9`L\!X(B%s$B!Y(B(%s)$B$r(B%s$B$+$i:o=|$7$^$7$?!#(B")
       (jishomei "$B<-=qL>(B:" )
       (comment "$B%3%a%s%H(B: ")
       (jisho-comment "$B<-=q(B:%s: $B%3%a%s%H(B:%s")
       (register-notify "$A4G5dOnD?!:(B%s$A!;(B(%s: %s)$A=+R*1;5GB<5=(B %s $AVP(B")
       (cannot-remove "$AO5M34G5dOn2;D\O{3}(B")
       (enter-hindo "$AGkJdHkF56H(B: ")
-      (remove-notify "$A4G5dOnD?(B%s(%s)$A=+R*4S(B %s $AVPO{3}(B")
-      (removed "$A4G5dOnD?(B%s(%s)$ARQ>-4S(B%s$AVPO{3}AK(B")
+      (remove-notify "$A4G5dOnD?!:(B%s$A!;(B(%s)$A=+R*4S(B %s $AVPO{3}(B")
+      (removed "$A4G5dOnD?!:(B%s$A!;(B(%s)$ARQ>-4S(B%s$AVPO{3}AK(B")
       (jishomei "$A4G5dC{(B:" )
       (comment "$AW"JM(B: ")
       (jisho-comment "$A4G5d(B:%s: $AW"JM(B:%s")
       (register-notify "$(C^vnp(B $(Cz#YM(B $(C!:(B%s$(C!;(B(%s: %s)$(C@;(B %s$(C?!(B $(CTtVbGO0Z@>4O4Y(B.")
       (cannot-remove "$(C=C=:E[(B $(C^vnpz#YM@:(B $(Ca<K[GR(B $(C<v(B $(C>x@>4O4Y(B.")
       (enter-hindo "$(C^:Sx8&(B $(Cl}UtGO=J=C?@(B: ")
-      (remove-notify "$(C^vnpz#YM(B %s(%s)$(C@;(B %s$(C:NEM(B $(Ca<K[GO0Z@>4O4Y(B.")
-      (removed "$(C^vnp(B $(Cz#YM(B %s(%s)$(C@;(B %s$(C:NEM(B $(Ca<K[G_@>4O4Y(B.")
+      (remove-notify "$(C^vnpz#YM!:(B%s$(C!;(B(%s)$(C@;(B %s$(C:NEM(B $(Ca<K[GO0Z@>4O4Y(B.")
+      (removed "$(C^vnp(B $(Cz#YM!:(B%s$(C!;(B(%s)$(C@;(B %s$(C:NEM(B $(Ca<K[G_@>4O4Y(B.")
       (jishomei "$(C^vnpY#(B: " )
       (comment "$(CqI`7(B: ")
       (jisho-comment "$(C^vnp(B:%s: $(CqI`7(B:%s")
 		      (or (markerp egg:*region-start*)
 			  (setq egg:*region-start* (make-marker)))
 		      (or (markerp egg:*region-end*)
-			  (setq egg:*region-end* (set-marker-insertion-type (make-marker) t)))
+			  (set-marker-insertion-type
+			   (setq egg:*region-end* (make-marker)) t))
 		      (if (null (marker-position egg:*region-start*))
 			  (progn
 			    ;;;(setq egg:*global-map-backup* (current-global-map))
 			    ;;(setq egg:*local-map-backup* (current-local-map))
-			    (and (boundp 'disable-undo) (setq disable-undo t))
+			    ;;(and (boundp 'disable-undo) (setq disable-undo t))
 			    (delete-region start end)
 			    (suspend-undo)
 			    (goto-char start)
 		      ;;(use-local-map henkan-mode-map)
 		      (run-hooks 'egg:henkan-start-hook)))))
 	    (setq finished t))
-	(or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)
+	(or finished
+	    ;;(setq disable-undo nil)
+	    (setq egg:henkan-mode-in-use nil)
 	    (resume-undo-list)))))
   )
 
   (interactive)
   (egg:bunsetu-face-off)
   (egg:henkan-face-off)
+  (setq egg:henkan-mode-in-use nil)
+  (setq egg:*in-fence-mode* nil)
   (delete-region (- egg:*region-start* (length egg:*henkan-open*))
 		 egg:*region-start*)
   (delete-region egg:*region-start* egg:*region-end*)
       ))
   (setq egg:*sai-henkan-end* (point))
   (wnn-server-hindo-update)
-  (setq egg:henkan-mode-in-use nil)
   (egg:quit-egg-mode)
   (run-hooks 'egg:henkan-end-hook)
   )
   (interactive)
   (egg:bunsetu-face-off)
   (egg:henkan-face-off)
+  (setq egg:henkan-mode-in-use nil)
+  (setq egg:*in-fence-mode* nil)
   (delete-region (- egg:*region-start* (length egg:*henkan-open*))
 		 egg:*region-start*)
   (delete-region egg:*region-start* egg:*region-end*)
   (forward-char 1)
   (delete-region (point) egg:*region-end*)
   (wnn-server-hindo-update)
-  (setq egg:henkan-mode-in-use nil)
   (egg:quit-egg-mode)
   )
 ;; end of patch
 	 (mode-line-egg-mode-update (egg:msg-get 'henkan-mode-indicator))
 	 (goto-char egg:*sai-henkan-start*)
 	 ;;(setq egg:*local-map-backup* (current-local-map))
-	 (and (boundp 'disable-undo) (setq disable-undo t))
+	 ;;(and (boundp 'disable-undo) (setq disable-undo t))
 	 (delete-region egg:*sai-henkan-start* egg:*sai-henkan-end*)
 	 (suspend-undo)
 	 (goto-char egg:*sai-henkan-start*)
 	 (henkan-goto-bunsetu 0)
 	 ;;(use-local-map henkan-mode-map)
 	 (setq finished t))
-       (or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)
+       (or finished
+	   ;;(setq disable-undo nil)
+	   (setq egg:henkan-mode-in-use nil)
 	   (resume-undo-list)))))
   )
 
   (delete-region egg:*region-start* egg:*region-end*)
   (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*henkan-close*)))
   (goto-char egg:*region-start*)
-  (if egg:*in-fence-mode*
-      (progn
-	(insert egg:*fence-open*)
-	(set-marker egg:*region-start* (point))
-	(insert egg:*kanji-kanabuff*)
-	(let ((point (point)))
-	  (insert egg:*fence-close*)
-	  (set-marker egg:*region-end* point)
-	  )
-	(goto-char egg:*region-end*)
-	(egg:fence-face-on)
-	(wnn-server-henkan-quit)
-	(setq egg:*mode-on* t))
-    (resume-undo-list)
-    (insert egg:*kanji-kanabuff*)
-    (wnn-server-henkan-quit)
-    (set-marker egg:*region-start* nil)
-    (set-marker egg:*region-end*   nil))
+  (insert egg:*fence-open*)
+  (set-marker egg:*region-start* (point))
+  (insert egg:*kanji-kanabuff*)
+  (let ((point (point)))
+    (insert egg:*fence-close*)
+    (set-marker egg:*region-end* point)
+    )
+  (goto-char egg:*region-end*)
+  (egg:fence-face-on)
+  (wnn-server-henkan-quit)
+  (setq egg:*mode-on* t)
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
   ;;(use-local-map fence-mode-map)
+  (setq egg:*in-fence-mode* t)
   (egg:mode-line-display)
   )
 
   (setq unread-command-events (list last-command-event))
   (henkan-kakutei))
 
-(defvar henkan-mode-map (make-keymap))
-(defvar henkan-mode-esc-map (make-keymap))
-
-(define-key henkan-mode-map [t] 'undefined)
-(define-key henkan-mode-esc-map [t] 'undefined)
-
-(let ((ch 0))
-  (while (<= ch 127)
-    (define-key henkan-mode-map (char-to-string ch) 'undefined)
-    (define-key henkan-mode-esc-map (char-to-string ch) 'undefined)
-    (setq ch (1+ ch))))
+(defvar henkan-mode-map (make-sparse-keymap))
+(defvar henkan-mode-esc-map (make-sparse-keymap))
+(set-keymap-default-binding henkan-mode-map 'undefined)
+(set-keymap-default-binding henkan-mode-esc-map 'undefined)
 
 (let ((ch 32))
   (while (< ch 127)
     (define-key henkan-mode-map (char-to-string ch) 'henkan-kakutei-and-self-insert)
     (setq ch (1+ ch))))
 
-(define-key henkan-mode-map "\e"   henkan-mode-esc-map)
-(define-key henkan-mode-map [escape]   henkan-mode-esc-map)
-;(define-key henkan-mode-map "\ei"  'henkan-inspect-bunsetu)
-(define-key henkan-mode-map "\ei"  'henkan-bunsetu-chijime-sho)
-(define-key henkan-mode-map "\eo"  'henkan-bunsetu-nobasi-sho)
-(define-key henkan-mode-map "\es"  'henkan-select-kouho-dai)
-(define-key henkan-mode-map "\eh"  'henkan-hiragana)
-(define-key henkan-mode-map "\ek"  'henkan-katakana)
-(define-key henkan-mode-map "\ez"  'henkan-select-kouho-sho)
-(define-key henkan-mode-map "\e<"  'henkan-saishou-bunsetu)
-(define-key henkan-mode-map "\e>"  'henkan-saichou-bunsetu)
+(condition-case ()
+    (define-key henkan-mode-map "\e" henkan-mode-esc-map)
+  (error nil))
+(define-key henkan-mode-map [escape] henkan-mode-esc-map)
+(define-key henkan-mode-esc-map "i" 'henkan-bunsetu-chijime-sho)
+(define-key henkan-mode-esc-map "o" 'henkan-bunsetu-nobasi-sho)
+(define-key henkan-mode-esc-map "s" 'henkan-select-kouho-dai)
+(define-key henkan-mode-esc-map "h" 'henkan-hiragana)
+(define-key henkan-mode-esc-map "k" 'henkan-katakana)
+(define-key henkan-mode-esc-map "z" 'henkan-select-kouho-sho)
+(define-key henkan-mode-esc-map "<" 'henkan-saishou-bunsetu)
+(define-key henkan-mode-esc-map ">" 'henkan-saichou-bunsetu)
+
 ;(define-key henkan-mode-map " "    'henkan-next-kouho-dai)
 					; 92.9.8 by T.Shingu
 (define-key henkan-mode-map " "    'henkan-next-kouho)
 (define-key henkan-mode-map "\C-e" 'henkan-last-bunsetu)
 (define-key henkan-mode-map "\C-f" 'henkan-forward-bunsetu)
 (define-key henkan-mode-map "\C-g" 'henkan-quit)
+(define-key henkan-mode-map "\C-h" 'henkan-help-command)
 (define-key henkan-mode-map "\C-i" 'henkan-bunsetu-chijime-dai)
 (define-key henkan-mode-map "\C-k" 'henkan-kakutei-before-point)
 (define-key henkan-mode-map "\C-l" 'henkan-kakutei)
 (define-key henkan-mode-map "\C-m" 'henkan-kakutei)
-(define-key henkan-mode-map [return] 'henkan-kakutei)
 (define-key henkan-mode-map "\C-n" 'henkan-next-kouho)
 (define-key henkan-mode-map "\C-o" 'henkan-bunsetu-nobasi-dai)
 (define-key henkan-mode-map "\C-p" 'henkan-previous-kouho)
 (define-key henkan-mode-map "\C-t"  'toroku-henkan-mode)
-(define-key henkan-mode-map "\C-u" 'undefined)
 (define-key henkan-mode-map "\C-v" 'henkan-inspect-bunsetu)
 (define-key henkan-mode-map "\C-w" 'henkan-next-kouho-dai)
 (define-key henkan-mode-map "\C-z" 'henkan-next-kouho-sho)
 (define-key henkan-mode-map "\177" 'henkan-quit)
-(define-key henkan-mode-map [delete] 'henkan-quit)
-(define-key henkan-mode-map 'backspace 'henkan-quit)
-(define-key henkan-mode-map '(control h) 'henkan-help-command)
-(define-key henkan-mode-map [right] 'henkan-forward-bunsetu)
-(define-key henkan-mode-map [left] 'henkan-backward-bunsetu)
-(define-key henkan-mode-map [down] 'henkan-next-kouho)
-(define-key henkan-mode-map [up] 'henkan-previous-kouho)
+(define-key henkan-mode-map [backspace] 'henkan-quit)
+(define-key henkan-mode-map [clear]     'henkan-quit)
+(define-key henkan-mode-map [delete]    'henkan-quit)
+(define-key henkan-mode-map [down]      'henkan-next-kouho)
+(define-key henkan-mode-map [help]      'henkan-help-command)
+(define-key henkan-mode-map [kp-enter]  'henkan-kakutei)
+(define-key henkan-mode-map [kp-down]   'henkan-next-kouho)
+(define-key henkan-mode-map [kp-left]   'henkan-backward-bunsetu)
+(define-key henkan-mode-map [kp-right]  'henkan-forward-bunsetu)
+(define-key henkan-mode-map [kp-up]     'henkan-previous-kouho)
+(define-key henkan-mode-map [left]      'henkan-backward-bunsetu)
+(define-key henkan-mode-map [next]      'henkan-next-kouho)
+(define-key henkan-mode-map [prior]     'henkan-previous-kouho)
+(define-key henkan-mode-map [return]    'henkan-kakutei)
+(define-key henkan-mode-map [right]     'henkan-forward-bunsetu)
+(define-key henkan-mode-map [up]        'henkan-previous-kouho)
 
 (unless (assq 'egg:henkan-mode-in-use minor-mode-map-alist)
   (setq minor-mode-map-alist
 	(dict-number
 	 (menu:select-from-menu
 	  (list 'menu (egg:msg-get 'touroku-jishomei)
-		(mapcar '(lambda (x)
-			   (let ((y (car (assoc x dic-list))))
-			     (cons (wnn-dict-name y dic-list) y)))
-			writable-dic-list))))
+		(delq nil
+		      (mapcar '(lambda (x)
+				 (let ((y (car (assoc x dic-list))))
+				   (if y
+				       (cons (wnn-dict-name y dic-list) y))))
+			      writable-dic-list)))))
 	(hinsi-name (hinsi-from-menu dict-number "/"))
 	(hinsi-no (wnn-server-hinsi-number hinsi-name))
 	(dict-name (wnn-dict-name dict-number dic-list)))
 "
   )
 
-(defvar diced-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) map))
+(defvar diced-mode-map (make-sparse-keymap))
+(set-keymap-default-binding diced-mode-map 'undefined)
 
 (define-key diced-mode-map "a"    'diced-add)
 (define-key diced-mode-map "d"    'diced-delete)
 	(dict-number
 	 (menu:select-from-menu
 	  (list 'menu (egg:msg-get 'jishomei)
-		(mapcar '(lambda (x)
-			   (let ((y (assoc x dic-list)))
-			     (cons (nth 1 y) (nth 0 y))))
-			writable-dic-list))))
+		(delq nil
+		      (mapcar '(lambda (x)
+				 (let ((y (assoc x dic-list)))
+				   (if y
+				       (cons (nth 1 y) (nth 0 y)))))
+			      writable-dic-list)))))
 	(comment (read-from-minibuffer (egg:msg-get 'comment)
 				       (wnn-dict-name dict-number dic-list))))
     (if (wnn-server-dict-comment dict-number comment)
 
 (defun notify-internal (message &optional noerase)
   (save-excursion
-    (let ((notify-buff (get-buffer-create *notification-window*)))
-      (set-buffer notify-buff)
-      (goto-char (point-max))
-      (setq buffer-read-only nil)
-      (insert (substring (current-time-string) 4 19) ":: " message ?\n )
-      (setq buffer-read-only t)
-      (bury-buffer notify-buff)
-      (message "%s" message)		; 92.4.15 by T.Enami
-      (if noerase nil
-	(sleep-for 1) (message "")))))
+    (set-buffer (get-buffer-create *notification-window*))
+    (goto-char (point-max))
+    (setq buffer-read-only nil)
+    (insert (substring (current-time-string) 4 19) ":: " message ?\n )
+    (setq buffer-read-only t)
+    (save-window-excursion
+      (bury-buffer)))
+  (message "%s" message)		; 92.4.15 by T.Enami
+  (if noerase
+      nil
+    (let ((focus-follows-mouse t))
+      (sleep-for 1))
+    (message "")))
 
 ;;;(defmacro notify-yes-or-no-p (str &rest args)
 ;;;  (list 'notify-yes-or-no-p-internal 
 
 ;;;----------------------------------------------------------------------
 ;;;
-;;; $B!V$?$^$4!W(B Menu System
+;;; Minibuffer Menu System
 ;;;
 ;;;----------------------------------------------------------------------
 
+;;; user-customizable variables
+(defvar menu:*display-item-value* nil
+  "*Non-nil means values of items are displayed in minibuffer menu")
+
+;;; The following will be localized, added only to pacify the compiler.
+(defvar menu:*cur-menu*)
+(defvar menu:*cur-selection*)
+(defvar menu:*cur-selections*)
+(defvar menu:*cur-element-no*)
+(defvar menu:*cur-selection-no*)
+(defvar menu:*cur-element-points*)
+(defvar menu:*menu-stack*)
+
+(defvar minibuffer-local-menu-map (make-sparse-keymap))
+(set-keymap-default-binding minibuffer-local-menu-map 'undefined)
+
+(mapcar
+ (lambda (elem)
+   (define-key minibuffer-local-menu-map
+     (car elem) (intern (format "menu:%s" (cdr elem)))))
+ '(
+   (" "		. next-element)
+   ("\C-a"	. beginning-of-selection)
+   ("\C-b"	. previous-element)
+   ("\C-d"	. previous-element)
+   ("\C-e"	. end-of-selection)
+   ("\C-f"	. next-element)
+   ("\C-g"	. quit)
+   ("\C-h"	. previous-element)
+   ("\C-i"	. next-element)
+   ("\C-j"	. select)
+   ("\C-l"	. refresh)
+   ("\C-m"	. select)
+   ("\C-n"	. next-selection)
+   ("\C-p"	. previous-selection)
+   ([backspace]	. previous-element)
+   ([clear]	. quit)
+   ([delete]	. previous-element)
+   ([down]	. next-selection)
+   ([kp-down]	. next-selection)
+   ([kp-enter]	. select)
+   ([kp-left]	. previous-element)
+   ([kp-right]	. next-element)
+   ([kp-tab]	. next-element)
+   ([kp-up]	. previous-selection)
+   ([left]	. previous-element)
+   ([next]	. next-selection)
+   ([prior]	. previous-selection)
+   ([return]	. select)
+   ([right]	. next-element)
+   ([tab]	. next-element)
+   ([up]	. previous-selection)
+   ))
+
+;;; 0 .. 9 A .. Z a .. z
+(mapcar
+ (lambda (char)
+   (define-key minibuffer-local-menu-map (char-to-string char)
+     'menu:goto-nth-element))
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
+
+;;; kp-0 .. kp-9
+(mapcar
+ (lambda (key)
+   (define-key minibuffer-local-menu-map key 'menu:goto-nth-element))
+ (list [kp-0] [kp-1] [kp-2] [kp-3] [kp-4] [kp-5] [kp-6] [kp-7] [kp-8] [kp-9]))
+
 ;;;
-;;;  minibuffer $B$K(B menu $B$rI=<(!&A*Br$9$k(B
+;;; predicates and selectors for menu
 ;;;
+;; <menu> ::= ( menu <prompt string> <items> )
+;; <items> ::= ( <item> ... )
+;; <item> ::= ( <string> . <value> ) | <string>
+;;         |  ( <char>   . <value> ) | <char>
+;; <value> :: = <menu> | <other object>
+;;
+(defun menu:menup (value)
+  (and (listp value)
+       (eq (car value) 'menu)))
+
+(defun menu:menu-prompt (&optional menu)
+  (car (cdr (or menu menu:*cur-menu*))))
+
+(defun menu:menu-items (&optional menu)
+  (car (cdr (cdr (or menu menu:*cur-menu*)))))
+
+(defun menu:menu-nth-item (n &optional menu)
+  (nth n (menu:menu-items menu)))
+
+(defun menu:item-string (item)
+  (cond ((stringp item) item)
+	((characterp item) (char-to-string item))
+	((consp item)
+	 (let ((str (cond ((stringp (car item)) (car item))
+			  ((characterp (car item)) (char-to-string (car item)))
+			  (t ""))))
+	   (if menu:*display-item-value*
+	       (format "%s [%s]" str (cdr item))
+	     str)))
+	(t "")))
+
+(defun menu:item-value (item)
+  (cond ((stringp item) item)
+	((characterp item) (char-to-string item))
+	((consp item) (cdr item))
+	(t "")))
+
+(defun menu:select-submenu (submenu)
+  "Save the current selection state, and select a new menu."
+  (setq menu:*menu-stack*
+	(cons (list menu:*cur-selection* menu:*cur-selections*
+		    menu:*cur-element-no* menu:*cur-selection-no*
+		    menu:*cur-menu* menu:*cur-element-points*)
+	      menu:*menu-stack*))
+  (setq menu:*cur-menu* submenu))
+
+(defun menu:select-saved-menu ()
+  "Restore the most recently stored selection state."
+  (let ((save (car menu:*menu-stack*)))
+    (setq menu:*menu-stack*
+	  (cdr menu:*menu-stack*))
+    (setq menu:*cur-selection*		(nth 0 save);92.10.26 by T.Saneto
+	  menu:*cur-selections*		(nth 1 save)
+	  menu:*cur-element-no*		(nth 2 save)
+	  menu:*cur-selection-no*	(nth 3 save)
+	  menu:*cur-menu*		(nth 4 save)
+	  menu:*cur-element-points*	(nth 5 save))))
 
 ;;;
-;;; menu $B$N;XDjJ}K!!'(B
+;;; constructors and selector for selection
 ;;;
-;;; <menu item> ::= ( menu <prompt string>  <menu-list> )
-;;; <menu list> ::= ( <menu element> ... )
-;;; <menu element> ::= ( <string> . <value> ) | <string>
-;;;                    ( <char>   . <value> ) | <char>
-
-;;; select-menu-in-minibuffer
-
-(defvar menu:*select-items* nil)
-(defvar menu:*select-menus* nil)
-(defvar menu:*select-item-no* nil)
-(defvar menu:*select-menu-no* nil)
-(defvar menu:*select-menu-stack* nil)
-(defvar menu:*select-start* nil)
-(defvar menu:*select-positions* nil)
-
-(defvar menu-mode-map (make-keymap))
-
-(define-key menu-mode-map "\C-a" 'menu:begining-of-menu)
-(define-key menu-mode-map "\C-e" 'menu:end-of-menu)
-(define-key menu-mode-map "\C-f" 'menu:next-item)
-(define-key menu-mode-map "\C-b" 'menu:previous-item)
-(define-key menu-mode-map "\C-n" 'menu:next-item-old)
-(define-key menu-mode-map "\C-g" 'menu:quit)
-(define-key menu-mode-map "\C-p" 'menu:previous-item-old)
-(define-key menu-mode-map "\C-l" 'menu:refresh)
-;;; 0 .. 9 a .. z A .. z
-(define-key menu-mode-map "\C-m" 'menu:select)
-(define-key menu-mode-map [return] 'menu:select)
-(define-key menu-mode-map [left] 'menu:previous-item)
-(define-key menu-mode-map [right] 'menu:next-item)
-(define-key menu-mode-map [up] 'menu:previous-item-old)
-(define-key menu-mode-map [down] 'menu:next-item-old)
-
-;; 92.6.14 by T.Enami -- This function was completely modified.
+;; <selection> ::= ( <pos> . <elements> )
+;;      <pos> ... integer that means the absolute position in menu items
+;; <elements> ::= ( <element string> ... )
+;;
+(defsubst menu:make-selection (pos elements)
+  (cons pos elements))
+
+(defsubst menu:selection-pos (&optional selection)
+  (car (or selection menu:*cur-selection*)))
+
+(defsubst menu:selection-elements (&optional selection)
+  (cdr (or selection menu:*cur-selection*)))
+
+(defsubst menu:selection-nth-element (&optional n selection)
+  (nth (or n menu:*cur-element-no*)
+       (menu:selection-elements selection)))
+
+(defsubst menu:selection-element-length (&optional selection)
+  (length (menu:selection-elements selection)))
+
+(defun menu:make-selections (items width)
+  "Make selection list from ITEMS so that each selection can fit with WIDTH."
+  (let ((headpos 0) (pos 0) (size 0)
+	revselections revelems
+	item-string item-width)
+    (while items
+      (setq item-string (menu:item-string (car items)))
+      (setq item-width (string-width item-string))
+      ;;; 92.9.19 by Y. Kawabe
+      (cond ((and revelems (<= width (+ size 4 item-width)))
+	     (setq revselections
+		   (cons (menu:make-selection headpos (nreverse revelems))
+			 revselections))
+	     (setq revelems nil)
+	     (setq size 0)
+	     (setq headpos pos))
+	    ((or (null (cdr items)) (<= width (+ size 4 item-width)))
+	     (setq revselections
+		   (cons
+		    (menu:make-selection
+		     headpos (nreverse (cons item-string revelems)))
+		    revselections))
+	     (setq size 0)
+	     (setq headpos pos)
+	     (setq items (cdr items))
+	     (setq pos (1+ pos)))
+	    (t
+	     ;;; 92.9.19 by Y. Kawabe
+	     (setq revelems (cons item-string revelems))
+	     (setq size (+ size 4 item-width))
+	     (setq items (cdr items))
+	     (setq pos (1+ pos)))))
+    (nreverse revselections)))
+
+(defun menu:setup-selections (window-width initpos)
+  (setq menu:*cur-selections*
+	(menu:make-selections (menu:menu-items)
+			      (- window-width
+				 ;;; 92.8.19 by K.Handa
+				 (string-width
+				  (menu:menu-prompt)))))
+  (if initpos
+      (let ((selections menu:*cur-selections*))
+	(setq menu:*cur-selection-no* 0)
+	(while (and (cdr selections)
+		    (< (menu:selection-pos (car (cdr selections)))
+		       initpos))
+	  (setq menu:*cur-selection-no* (1+ menu:*cur-selection-no*))
+	  (setq selections (cdr selections)))
+	(setq menu:*cur-element-no*
+	      (- initpos (menu:selection-pos (car selections)))))))
+
+;;; utility
+(defun menu:check-number-range (i min max)
+  (cond ((eq i 'max) max)
+	((eq i 'min) min)
+	((< i min) max)
+	((< max i) min)
+	(t i)))
+
+;;;
+;;; main part of menu
+;;;
 (defun menu:select-from-menu (menu &optional initial position)
-  (let ((echo-keystrokes 0)
-	(inhibit-quit t)
-	(menubuffer (get-buffer-create " *menu*"))
-	(minibuffer (window-buffer (minibuffer-window)))
-	value)
-    (save-window-excursion
-      (set-window-buffer (minibuffer-window) menubuffer)
-      (select-window (minibuffer-window))
-      (set-buffer menubuffer)
-      (delete-region (point-min) (point-max))
-      (insert (nth 1 menu))
-      (let* ((window-width (window-width (selected-window)))
-	     (finished nil))
-	(setq menu:*select-menu-stack* nil
-	      menu:*select-positions* nil
-	      menu:*select-start* (point)
-	      menu:*select-menus*
-	      (menu:make-selection-list (nth 2 menu)
-					(- window-width  
-					   ;;; 92.8.19 by K.Handa
-					   (string-width (nth 1 menu)))))
-	;; 92.7.8 by Y.Kawabe
-	(cond
-	 ((and (numberp initial)
-	       (<= 0 initial)
-	       (< initial (length (nth 2 menu))))
-	  (menu:select-goto-item-position initial))
-	 ((and (listp initial) (car initial)
-	       (<= 0 (car initial))
-	       (< (car initial) (length (nth 2 menu))))
-	  (menu:select-goto-item-position (car initial))
-	  (while (and (setq initial (cdr initial))
-		      (setq value (menu:item-value (nth menu:*select-item-no* 
-							menu:*select-items*)))
-		      (listp value) (eq (car value) 'menu))
+  "Display menu in minibuffer and return the selected value.
+If INITIAL is non-nil integer list, it behaves as menu is selected
+using the path specified by INITIAL in advance.
+If POSITION is non-nil value, return value is a pair of the selected
+value and the chosen path (represented by an integer list)."
+  (let ((menu:*cur-menu* menu)
+	(menu:*window-width* (window-width (minibuffer-window)))
+	menu:*cur-selection* menu:*cur-selections*
+	menu:*cur-element-no*
+	menu:*cur-selection-no*
+	menu:*cur-element-points*
+	menu:*menu-stack* menu:*select-positions*
+	(pos 0) value finished)
+    (if initial
+	(progn
+	  (if (numberp initial)
+	      (setq initial (list initial)))
+	  (while (cdr initial)
+	    (setq value (menu:item-value (menu:menu-nth-item (car initial))))
+	    (if (menu:menup value)
+		(progn
+		  (menu:setup-selections menu:*window-width* (car initial))
+		  (menu:select-submenu value)))
 	    (setq menu:*select-positions*
-		  (cons (menu:select-item-position) menu:*select-positions*))
-	    (setq menu:*select-menu-stack*
-		  (cons (list menu:*select-items* menu:*select-menus*
-			      menu:*select-item-no* menu:*select-menu-no*
-			      menu)
-			menu:*select-menu-stack*))
-	    (setq menu value)
-	    (delete-region (point-min) (point-max)) (insert (nth 1 menu))
-	    (setq menu:*select-start* (point))
-	    (setq menu:*select-menus*
-		  (menu:make-selection-list
-		   ;;; 92.9.19 by Y. Kawabe
-		   (nth 2 menu) (- window-width (string-width (nth 1 menu)))))
-	    (if (and (numberp (car initial))
-		     (<= 0 (car initial))
-		     (< (car initial) (length (nth 2 menu))))
-		(menu:select-goto-item-position (car initial))
-	      (setq menu:*select-item-no* 0)
-	      (menu:select-goto-menu 0)))
-	  (setq value nil))
-	 (t
-	  (setq menu:*select-item-no* 0)
-	  (menu:select-goto-menu 0))
-	 )
-	;; end of patch
-	(while (not finished)
-	  (let ((ch (egg-read-event)))
-	    (setq quit-flag nil)
-	    (cond
-	     ((eq ch ?\C-a)
-	      (menu:select-goto-item 0))
-	     ((eq ch ?\C-e)
-	      (menu:select-goto-item (1- (length menu:*select-items*))))
-	     ((or (eq ch ?\C-f) (eq ch 'right) (eq ch ?\ ))
-	      ;;(menu:select-goto-item (1+ menu:*select-item-no*))
-	      (menu:select-next-item)
-	      )
-	     ((or (eq ch ?\C-b) (eq ch 'left))
-	      ;;(menu:select-goto-item (1- menu:*select-item-no*))
-	      (menu:select-previous-item)
-	      )
-	     ((or (eq ch ?\C-n) (eq ch 'down))
-	      (menu:select-goto-menu (1+ menu:*select-menu-no*)))
-	     ((eq ch ?\C-g)
-	      (if menu:*select-menu-stack*
-		  (let ((save (car menu:*select-menu-stack*)))
-		    (setq menu:*select-menu-stack*
-			  (cdr menu:*select-menu-stack*))
-		    (setq menu:*select-items* (nth 0 save);92.10.26 by T.Saneto
-			  menu:*select-menus*    (nth 1 save)
-			  menu:*select-item-no*  (nth 2 save)
-			  menu:*select-menu-no*  (nth 3 save)
-			  menu                   (nth 4 save))
-		    (setq menu:*select-positions*
-			  (cdr menu:*select-positions*))
-		    (delete-region (point-min) (point-max))
-		    (insert (nth 1 menu))
-		    (setq menu:*select-start* (point))
-		    (menu:select-goto-menu menu:*select-menu-no*)
-		    (menu:select-goto-item menu:*select-item-no*)
-		    )
-		(setq finished t
-		      value nil)))
-	     ((or (eq ch ?\C-p) (eq ch 'up))
-	      (menu:select-goto-menu (1- menu:*select-menu-no*)))
-	     ((eq ch ?\C-l)  ;;; redraw menu
-	      (menu:select-goto-menu menu:*select-menu-no*))
-	     ((and (characterp ch) (<= ?0 ch) (<= ch ?9)
-		   (<= ch (+ ?0 (1- (length menu:*select-items*)))))
-	      (menu:select-goto-item (- ch ?0)))
-	     ((and (characterp ch) (<= ?a ch) (<= ch ?z)
-		   (<= (+ 10 ch) (+ ?a (1- (length menu:*select-items*)))))
-	      (menu:select-goto-item (+ 10 (- ch ?a))))
-	     ((and (characterp ch) (<= ?A ch) (<= ch ?Z)
-		   (<= (+ 10 ch) (+ ?A (1- (length menu:*select-items*)))))
-	      (menu:select-goto-item (+ 10 (- ch ?A))))
-	     ((or (eq ch ?\C-m) (eq ch 'return))
-	      (setq value (menu:item-value (nth menu:*select-item-no* 
-						menu:*select-items*)))
-	      (setq menu:*select-positions* 
-		    (cons (menu:select-item-position)
-			  menu:*select-positions*))
-	      (if (and (listp value)
-		       (eq (car value) 'menu))
-		  (progn
-		    (setq menu:*select-menu-stack*
-			  (cons
-			   (list menu:*select-items* menu:*select-menus*
-				 menu:*select-item-no* menu:*select-menu-no*
-				 menu)
-			   menu:*select-menu-stack*))
-		    (setq menu value)
-		    (delete-region (point-min) (point-max))
-		    (insert (nth 1 menu))
-		    (setq menu:*select-start* (point))
-		    (setq menu:*select-menus*
-			  ;;; 92.9.19 by Y. Kawabe
-			  (menu:make-selection-list
-			   (nth 2 menu)
-			   (- window-width
-			      (string-width (nth 1 menu)))))
-		    (setq menu:*select-item-no* 0)
-		    (menu:select-goto-menu 0)
-		    (setq value nil)
-		    )
-		(setq finished t)))
-	     (t (beep))))))
-      (delete-region (point-min) (point-max))
-      (setq menu:*select-positions*
-	    (nreverse menu:*select-positions*))
-      (set-window-buffer (minibuffer-window) minibuffer)
-      (if (null value)
-	  (setq quit-flag t)
-	(if position
-	    (cons value menu:*select-positions*)
-	  value)))))
-
-(defun menu:select-item-position ()
-  (let ((p 0) (m 0))
-    (while (< m menu:*select-menu-no*)
-      (setq p (+ p (length (nth m menu:*select-menus*))))
-      (setq m (1+ m)))
-    (+ p menu:*select-item-no*)))
-    
-(defun menu:select-goto-item-position (pos)
-  (let ((m 0) (p 0))
-    (while (<= (+ p (length (nth m menu:*select-menus*))) pos)
-      (setq p (+ p (length (nth m menu:*select-menus*))))
-      (setq m (1+ m)))
-    (setq menu:*select-item-no* (- pos p))
-    (menu:select-goto-menu m)))
-
-(defun menu:select-goto-menu (no)
-  (setq menu:*select-menu-no*
-	(check-number-range no 0 (1- (length menu:*select-menus*))))
-  (setq menu:*select-items* (nth menu:*select-menu-no* menu:*select-menus*))
-  (delete-region menu:*select-start* (point-max))
-  (if (<= (length menu:*select-items*) menu:*select-item-no*)
-      (setq menu:*select-item-no* (1- (length menu:*select-items*))))
-  (goto-char menu:*select-start*)
-  (let ((l menu:*select-items*) (i 0))
-    (while l
+		  (cons (car initial) menu:*select-positions*))
+	    (setq initial (cdr initial)))
+	  (setq pos (car initial))))
+    (while (not finished)
+      (menu:setup-selections menu:*window-width* pos)
+      (add-hook 'minibuffer-setup-hook 'menu:minibuffer-setup)
+      (unwind-protect
+	  (setq pos (read-from-minibuffer "" nil minibuffer-local-menu-map
+					  t 'menu:*select-positions*))
+	(remove-hook 'minibuffer-setup-hook 'menu:minibuffer-setup)
+	(if quit-flag
+	    (setq pos nil
+		  quit-flag nil)))
+      (cond (pos			; element selected
+	     (setcar menu:*select-positions* pos)
+	     (setq value (menu:item-value (menu:menu-nth-item pos)))
+	     (if (menu:menup value)
+		 (progn (menu:select-submenu value)
+			(setq pos 0))
+	       (setq finished t)))
+	    (menu:*menu-stack*		; quit (restore menu)
+	     (if (not (car menu:*select-positions*))
+		 (setq menu:*select-positions* (cdr menu:*select-positions*)))
+	     (setq menu:*select-positions* (cdr menu:*select-positions*))
+	     (menu:select-saved-menu))
+	    (t				; really quit
+	     (setq quit-flag t)
+	     (setq menu:*select-positions* nil)
+	     (setq finished t))))
+    (if position
+	(cons value (nreverse menu:*select-positions*))
+      value)))
+
+(defalias 'menu:minibuffer-setup 'menu:goto-selection)
+
+(defun menu:goto-selection (&optional sel-no elem-no)
+  (setq menu:*cur-selection-no*
+	(menu:check-number-range (or sel-no menu:*cur-selection-no*)
+				 0 (1- (length menu:*cur-selections*))))
+  (setq menu:*cur-selection*
+	(nth menu:*cur-selection-no* menu:*cur-selections*))
+  (erase-buffer)
+  (insert (menu:menu-prompt))
+  (let ((elements (menu:selection-elements))
+	(i 0)
+	revpoints)
+    (while elements
+      (setq revpoints (cons (+ (point) 2) revpoints))
       (insert (if (<= i 9) (format "  %d." i)
 		(format "  %c." (+ (- i 10) ?a)))
-	      (menu:item-string (car l)))
-      (setq l (cdr l)
-	    i (1+ i))))
-  (menu:select-goto-item menu:*select-item-no*))
-
-(defun menu:select-goto-item (no)
-  (setq menu:*select-item-no* 
-	(check-number-range no 0
-			    (1- (length menu:*select-items*))))
-  (let ((p (+ 2 menu:*select-start*)) (i 0))
-    (while (< i menu:*select-item-no*)
-      (setq p (+ p (length (menu:item-string (nth i menu:*select-items*))) 4))
-      (setq i (1+ i)))
-    (goto-char p)))
-    
-(defun menu:select-next-item ()
-  (if (< menu:*select-item-no* (1- (length menu:*select-items*)))
-      (menu:select-goto-item (1+ menu:*select-item-no*))
-    (progn
-      (setq menu:*select-item-no* 0)
-      (menu:select-goto-menu (1+ menu:*select-menu-no*)))))
-
-(defun menu:select-previous-item ()
-  (if (< 0 menu:*select-item-no*)
-      (menu:select-goto-item (1- menu:*select-item-no*))
-    (progn 
-      (setq menu:*select-item-no* 1000)
-      (menu:select-goto-menu (1- menu:*select-menu-no*)))))
-
-(defvar menu:*display-item-value* nil)
-
-(defun menu:item-string (item)
-  (cond((stringp item) item)
-       ((characterp item) (char-to-string item))
-       ((consp item)
-	(if menu:*display-item-value*
-	    (format "%s [%s]"
-		    (cond ((stringp (car item)) (car item))
-			  ((characterp (car item)) (char-to-string (car item)))
-			  (t ""))
-		    (cdr item))
-	  (cond ((stringp (car item))
-		 (car item))
-		((characterp (car item))
-		 (char-to-string (car item)))
-		(t ""))))
-       (t "")))
-
-(defun menu:item-value (item)
-  (cond((stringp item) item)
-       (t (cdr item))))
-
-(defun menu:make-selection-list (items width)
-  (let ((whole nil) (line nil) (size 0))
-    (while items
-      ;;; 92.9.19 by Y. Kawabe
-      (if (<= width (+ size 4 (string-width (menu:item-string(car items)))))
-	  (if line
-	      (setq whole (cons (reverse line) whole)
-		    line nil
-		    size 0)
-	    (setq whole (cons (list (car items)) whole)
-		  size 0
-		  items (cdr items)))
-	;;; 92.9.19 by Y. Kawabe
-	(setq line (cons (car items) line)
-	      size (+ size 4 (string-width(menu:item-string (car items))))
-	      items (cdr items))))
-    (if line
-	(reverse (cons (reverse line) whole))
-      (reverse whole))))
-
+	      (car elements))
+      (setq elements (cdr elements)
+	    i (1+ i)))
+    (setq menu:*cur-element-points* (nreverse revpoints)))
+  (menu:goto-element elem-no))
+
+(defun menu:goto-element (&optional elem-no)
+  (setq menu:*cur-element-no*
+	(menu:check-number-range (or elem-no menu:*cur-element-no*)
+				 0 (1- (menu:selection-element-length))))
+  (goto-char (nth menu:*cur-element-no* menu:*cur-element-points*)))
+
+(defun menu:beginning-of-selection ()
+  (interactive)
+  (menu:goto-element 0))
+
+(defun menu:end-of-selection ()
+  (interactive)
+  (menu:goto-element (1- (menu:selection-element-length))))
+
+(defun menu:next-selection ()
+  (interactive)
+  (menu:goto-selection (1+ menu:*cur-selection-no*)))
+
+(defun menu:previous-selection ()
+  (interactive)
+  (menu:goto-selection (1- menu:*cur-selection-no*)))
+
+(defun menu:next-element ()
+  (interactive)
+  (if (< menu:*cur-element-no* (1- (menu:selection-element-length)))
+      (menu:goto-element (1+ menu:*cur-element-no*))
+    (menu:goto-selection (1+ menu:*cur-selection-no*) 0)))
+
+(defun menu:previous-element ()
+  (interactive)
+  (if (< 0 menu:*cur-element-no*)
+      (menu:goto-element (1- menu:*cur-element-no*))
+    (menu:goto-selection (1- menu:*cur-selection-no*) 'max)))
+
+(defun menu:goto-nth-element ()
+  (interactive)
+  (let ((ch (event-to-character last-command-event))
+	(elem-no-max (1- (menu:selection-element-length))))
+    (if ch
+	(cond
+	 ((and (<= ?0 ch) (<= ch ?9)
+	       (<= ch (+ ?0 elem-no-max)))
+	  (menu:goto-element (- ch ?0)))
+	 ((and (<= ?a ch) (<= ch ?z)
+	       (<= (+ 10 ch) (+ ?a elem-no-max)))
+	  (menu:goto-element (+ 10 (- ch ?a))))
+	 ((and (<= ?A ch) (<= ch ?Z)
+	       (<= (+ 10 ch) (+ ?A elem-no-max)))
+	  (menu:goto-element (+ 10 (- ch ?A))))))))
+
+(defun menu:refresh ()
+  (interactive)
+  (menu:goto-selection))
+
+(defun menu:select ()
+  (interactive)
+  (erase-buffer)
+  (prin1 (+ (menu:selection-pos) menu:*cur-element-no*) (current-buffer))
+  (exit-minibuffer))
+
+(defun menu:quit ()
+  (interactive)
+  (erase-buffer)
+  (prin1 nil (current-buffer))
+  (exit-minibuffer))
 
 ;;;----------------------------------------------------------------------
 ;;;
 			(eq ch ?$B!+(B)
 			(eq ch ?$B!,(B)))
 	       (delete-char -1)
-	       (insert (make-char (find-charset 'japanese-jisx0208) 36 (char-octet ch 1))))))))
+	       (insert (make-char (find-charset 'japanese-jisx0208) 36
+				  (nth 2 (split-char ch)))))))))
 
 (defun hiragana-paragraph ()
   "hiragana  paragraph at or after point."
     (let ((ch (char-before (point))))
       (cond ((not (memq ch '(?$B!<(B ?$B!+(B ?$B!,(B)))
 	     (delete-char -1)
-	     (insert (make-char (find-charset 'japanese-jisx0208) 37 (char-octet ch 1))))))))
+	     (insert (make-char (find-charset 'japanese-jisx0208) 37
+				(nth 2 (split-char ch)))))))))
 
 (defun katakana-paragraph ()
   "katakana  paragraph at or after point."
     (narrow-to-region start end)
     (goto-char (point-min))
     (while (re-search-forward "\\cS\\|\\cA\\|\\cK" (point-max) (point-max))
-      (let* ((ch (char-before (point)))
-	     (ch1 (char-octet ch 0))
-	     (ch2 (char-octet ch 1)))
+      (let* ((ch (split-char (char-before (point))))
+	     (ch1 (nth 1 ch))
+	     (ch2 (nth 2 ch)))
 	(cond ((= ch1 33) ;Symbols
 	       (let ((val (cdr (assq ch2 *hankaku-alist*))))
 		 (if val (progn
 
 (defun fence-exit-internal ()
   (egg:fence-face-off)
+  (setq egg:*in-fence-mode* nil)
   (let ((kakutei-string (buffer-substring
 			 egg:*region-start* egg:*region-end*)))
     (delete-region (- egg:*region-start* (length egg:*fence-open*))
   ;;;(use-global-map egg:*global-map-backup*)
   ;;(use-local-map egg:*local-map-backup*)
   ;;(remove-hook 'post-command-hook 'fence-post-command-hook)
-  (setq egg:*in-fence-mode* nil)
   (egg:mode-line-display)
   (if overwrite-mode
       (let ((str (buffer-substring egg:*region-end* egg:*region-start*)))
     (ding)
     (select-window w)))
 
-(defvar fence-mode-map (make-keymap))
-
+(defvar fence-mode-map (make-sparse-keymap))
 (substitute-key-definition 'egg-self-insert-command
 			   'fence-self-insert-command
 			   fence-mode-map global-map)
+(set-keymap-default-binding fence-mode-map 'undefined)
 
 (define-key fence-mode-map "\eh"  'fence-hiragana)
 (define-key fence-mode-map "\ek"  'fence-katakana)
 (define-key fence-mode-map "\C-e" 'fence-end-of-line)
 (define-key fence-mode-map "\C-f" 'fence-forward-char)
 (define-key fence-mode-map "\C-g" 'fence-cancel-input)
+(define-key fence-mode-map "\C-h" 'fence-mode-help-command)
 (define-key fence-mode-map "\C-k" 'fence-kill-line)
 (define-key fence-mode-map "\C-l" 'fence-exit-mode)
 (define-key fence-mode-map "\C-m" 'fence-exit-mode)  ;;; RET
-(define-key fence-mode-map [return] 'fence-exit-mode)
 (define-key fence-mode-map "\C-q" 'its:select-previous-mode)
 (define-key fence-mode-map "\C-t" 'fence-transpose-chars)
 (define-key fence-mode-map "\C-w" 'henkan-fence-region)
 (define-key fence-mode-map "\C-\\" 'fence-toggle-egg-mode)
 (define-key fence-mode-map "\C-_" 'jis-code-input)
 (define-key fence-mode-map "\177" 'fence-backward-delete-char)
-(define-key fence-mode-map [delete] 'fence-backward-delete-char)
-(define-key fence-mode-map 'backspace 'fence-backward-delete-char)
-(define-key fence-mode-map '(control h) 'fence-mode-help-command)
-(define-key fence-mode-map [right] 'fence-forward-char)
-(define-key fence-mode-map [left] 'fence-backward-char)
+(define-key fence-mode-map [backspace] 'fence-backward-delete-char)
+(define-key fence-mode-map [clear]     'fence-cancel-input)
+(define-key fence-mode-map [delete]    'fence-backward-delete-char)
+(define-key fence-mode-map [help]      'fence-mode-help-command)
+(define-key fence-mode-map [kp-enter]  'fence-exit-mode)
+(define-key fence-mode-map [kp-left]   'fence-backward-char)
+(define-key fence-mode-map [kp-right]  'fence-forward-char)
+(define-key fence-mode-map [left]      'fence-backward-char)
+(define-key fence-mode-map [return]    'fence-exit-mode)
+(define-key fence-mode-map [right]     'fence-forward-char)
 
 (unless (assq 'egg:*in-fence-mode* minor-mode-map-alist)
   (setq minor-mode-map-alist
 (egg-its
-  (standards-version 1.0
+  (standards-version 1.1
    version VERSION
    author-version AUTHOR_VERSION
    date DATE
    distribution mule
    priority high
    category CATEGORY
-   dump t
+   dump nil
    description "Wnn (4.2 and 6) support.  SJ3 support."
    filename FILENAME
    md5sum MD5SUM