Mercurial > hg > xemacs-beta
diff lisp/egg/egg-wnn.el @ 114:8619ce7e4c50 r20-1b9
Import from CVS: tag r20-1b9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:21:54 +0200 |
parents | 0d2f883870bc |
children | 585fb297b004 |
line wrap: on
line diff
--- a/lisp/egg/egg-wnn.el Mon Aug 13 09:20:50 2007 +0200 +++ b/lisp/egg/egg-wnn.el Mon Aug 13 09:21:54 2007 +0200 @@ -1,4 +1,4 @@ -;;; wnn-egg.el --- a inputting method communicating with [jck]server +;;; egg-wnn.el --- a inputting method communicating with [jck]server ;; Author: Satoru Tomura (tomura@etl.go.jp), and ;; Toshiaki Shingu (shingu@cpr.canon.co.jp) @@ -89,6 +89,7 @@ ;;; Code: +(require 'egg) (make-variable-buffer-local 'wnn-server-type) (make-variable-buffer-local 'cwnn-zhuyin) @@ -117,10 +118,12 @@ ;;; $B0J2<$N(B its mode $B4X78$N4X?t$O!"(Begg.el $B$GDj5A$5$l$F$$$k$,!"(B ;;; $B$?$+$J$G$O(B its mode $B$N@ZBX$($KF14|$7$F!"(Bjserver/cserver, ;;; pinyin/zhuyin $B$N@ZBX$($b9T$J$$$?$$$N$G!":FDj5A$7$F$$$k!#(B -;;; $B=>$C$F!"(Begg.el, wnn-egg.el $B$N=g$K%m!<%I$7$J$1$l$P$J$i$J$$!#(B +;;; $B=>$C$F!"(Begg.el, egg-wnn.el $B$N=g$K%m!<%I$7$J$1$l$P$J$i$J$$!#(B (defun its:select-mode (name) +"Switch ITS mode to NAME or prompt for it if called interactivly. +After changing, its:select-mode-hook is called." (interactive (list (completing-read "ITS mode: " its:*mode-alist*))) (if (its:get-mode-map name) (progn @@ -131,6 +134,8 @@ ) (defun its:select-mode-from-menu () +"Select ITS mode from menu. +After changing, its:select-mode-hook is called." (interactive) (setcar (nthcdr 2 its:*select-mode-menu*) its:*mode-alist*) (setq its:*current-map* (menu:select-from-menu its:*select-mode-menu*)) @@ -153,6 +158,8 @@ )))) (defun its:next-mode () +"Switch to next mode in list its:*standard-modes* +After changing, its:select-mode-hook is called." (interactive) (let ((pos (its:find its:*current-map* its:*standard-modes*))) (setq its:*current-map* @@ -162,6 +169,8 @@ (run-hooks 'its:select-mode-hook))) (defun its:previous-mode () +"Switch to previous mode in list its:*standard-modes* +After changing, its:select-mode-hook is called." (interactive) (let ((pos (its:find its:*current-map* its:*standard-modes*))) (setq its:*current-map* @@ -201,7 +210,7 @@ (defvar egg:*sai-henkan-end* nil) (defvar egg:*old-bunsetu-suu* nil) -(defun wnn-egg:kill-emacs-function () +(defun egg-wnn:kill-emacs-function () (let ((wnn-server-type)) (setq wnn-server-type 'jserver) (close-wnn) @@ -210,20 +219,93 @@ (setq wnn-server-type 'kserver) (close-wnn))) -(add-hook 'kill-emacs-hook 'wnn-egg:kill-emacs-function) +(add-hook 'kill-emacs-hook 'egg-wnn:kill-emacs-function) (defun egg:error (form &rest mesg) (apply 'notify (or form "%s") mesg) (apply 'error (or form "%s") mesg)) +(defun wnn-toggle-english-messages () +"Toggle whether wnn reports info in english or the native language of the server." + (interactive) + (setq wnn-english-messages (not wnn-english-messages))) + +(defvar wnn-english-messages nil "*If non-nil, display messages from the [jck]server in English") + +(make-symbol "english-mess") + (defun egg:msg-get (message) (or - (nth 1 (assoc message (nth 1 (assoc wnn-server-type *egg-message-alist*)))) + (nth 1 (assoc message (nth 1 (assoc (if wnn-english-messages 'english-mess wnn-server-type) + *egg-message-alist*)))) (format "No message. Check *egg-message-alist* %s %s" wnn-server-type message))) (defvar *egg-message-alist* - '((jserver + '((english-mess + ((open-wnn "Connected with Wnn on host %s") + (no-rcfile "No egg-startup-file on %s") + (file-saved "Wnn dictionary and frequency data recorded.") + (henkan-mode-indicator "$B4A(B") + (begin-henkan "$BJQ493+;OJ8;zNs(B: ") + (end-henkan "$BJQ49=*N;J8;zNs(B: ") + (kugiri-dai "$BBgJ8@a6h@Z$jJ8;zNs(B: ") + (kugiri-sho "$B>.J8@a6h@Z$jJ8;zNs(B: ") + (face-henkan "$BJQ496h4VI=<(B0@-(B: ") + (face-dai "$BBgJ8@a6h4VI=<(B0@-(B: ") + (face-sho "$B>.J8@a6h4VI=<(B0@-(B: ") + (jikouho "$B<!8uJd(B:") + (off-msg "%s %s(%s:%s) turned off.") + (henkan-help "Kanji conversion mode: +$BJ8@a0\F0(B + \\[henkan-first-bunsetu]\t$B@hF,J8@a(B\t\\[henkan-last-bunsetu]\t$B8eHxJ8@a(B + \\[henkan-backward-bunsetu]\t$BD>A0J8@a(B\t\\[henkan-forward-bunsetu]\t$BD>8eJ8@a(B +$BJQ49JQ99(B + $BBgJ8@a<!8uJd(B \\[henkan-next-kouho-dai]\t$B>.J8@a<!8uJd(B \\[henkan-next-kouho-sho] + $BA08uJd(B \\[henkan-previous-kouho] \t$B<!8uJd(B \\[henkan-next-kouho] + $BBgJ8@a?-$7(B \\[henkan-bunsetu-nobasi-dai] \t$BBgJ8@a=L$a(B \\[henkan-bunsetu-chijime-dai] + $B>.J8@a?-$7(B \\[henkan-bunsetu-nobasi-sho] \t$B>.J8@a=L$a(B \\[henkan-bunsetu-chijime-sho] + $BBgJ8@aJQ498uJdA*Br(B \\[henkan-select-kouho-dai] \t$B>.J8@aJQ498uJdA*Br(B \\[henkan-select-kouho-sho] +$BJQ493NDj(B + $BA4J8@a3NDj(B \\[henkan-kakutei] \t$BD>A0J8@a$^$G3NDj(B \\[henkan-kakutei-before-point] +$BJQ49Cf;_(B \\[henkan-quit] +") + (hinsimei "Hinshi (product/noun) name:") + (jishotouroku-yomi "Dictionary entry for$B!X(B%s$B!Y(B reading:") + (touroku-jishomei "Name of dictionary:" ) + (registerd "Dictonary entry$B!X(B%s$B!Y(B(%s: %s) registered in %s.") + (yomi "Reading$B!'(B") + (no-yomi "No dictionary entry for $B!X(B%s$B!Y(B.") + (jisho "Dictionary:") + (hindo "Frequency:") + (kanji "Kanji:") + (register-notify "Dictonary entry$B!X(B%s$B!Y(B(%s: %s) registered in %s.") + (cannot-remove "Cannot delete entry from system dictionary.") + (enter-hindo "Enter frequency:") + (remove-notify "Dictonary entry$B!X(B%s$B!Y(B(%s) removed from %s.") + (removed "Dictonary entry$B!X(B%s$B!Y(B(%s) removed from %s.") + (jishomei "Dictionary name:" ) + (comment "Comment:") + (jisho-comment "Dictionary:%s: comment:%s") + (param ("$B#N(B ( $BBg(B ) $BJ8@a2r@O$N#N(B" + "$BBgJ8@aCf$N>.J8@a$N:GBg?t(B" + "$B448l$NIQEY$N%Q%i%a!<%?(B" + "$B>.J8@aD9$N%Q%i%a!<%?(B" + "$B448lD9$N%Q%i%a!<%?(B" + "$B:#;H$C$?$h%S%C%H$N%Q%i%a!<%?(B" + "$B<-=q$N%Q%i%a!<%?(B" + "$B>.J8@a$NI>2ACM$N%Q%i%a!<%?(B" + "$BBgJ8@aD9$N%Q%i%a!<%?(B" + "$B>.J8@a?t$N%Q%i%a!<%?(B" + "$B5?;wIJ;l(B $B?t;z$NIQEY(B" + "$B5?;wIJ;l(B $B%+%J$NIQEY(B" + "$B5?;wIJ;l(B $B1Q?t$NIQEY(B" + "$B5?;wIJ;l(B $B5-9f$NIQEY(B" + "$B5?;wIJ;l(B $BJD3g8L$NIQEY(B" + "$B5?;wIJ;l(B $BIUB08l$NIQEY(B" + "$B5?;wIJ;l(B $B3+3g8L$NIQEY(B")) + )) + (jserver ((open-wnn "$B%[%9%H(B %s $B$N(B Wnn $B$r5/F0$7$^$7$?(B") (no-rcfile "%s $B>e$K(B egg-startup-file $B$,$"$j$^$;$s!#(B") (file-saved "Wnn$B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$^$7$?!#(B") @@ -458,6 +540,10 @@ ;; ###jhod Currently very broken. Needs to be rewritten for the new ;; wnn-server-set-param (defun set-wnn-param (&rest param) +"Set parameters for the current wnn session. +Uses property list PARAM, or prompts if called interactivly. + +Currently very broken." (interactive) ; (open-wnn-if-disconnected) (let ((current-param (wnn-server-get-param)) @@ -601,6 +687,7 @@ (cons name (delete name list))) (defun set-wnn-host-name (name) +"Set egg/wnn to connect to jserver on host NAME, or prompt for it." (interactive "sHost name: ") (let ((wnn-server-type 'jserver)) (close-wnn)) (setq jserver-list @@ -610,6 +697,7 @@ (fset 'set-jserver-host-name (symbol-function 'set-wnn-host-name)) (defun set-cwnn-host-name (name) +"Set egg/wnn to connect to cserver on host NAME, or prompt for it." (interactive "sHost name: ") (let ((wnn-server-type 'cserver)) (close-wnn)) (setq cserver-list @@ -619,6 +707,7 @@ (fset 'set-cserver-host-name (symbol-function 'set-cwnn-host-name)) (defun set-kwnn-host-name (name) +"Set egg/wnn to connect to kserver on host NAME, or prompt for it." (interactive "sHost name: ") (let ((wnn-server-type 'kserver)) (close-wnn)) (setq kserver-list @@ -695,10 +784,12 @@ (run-hooks 'egg:open-wnn-hook)))) (defun disconnect-wnn () +"Dump connection to Wnn servers, discarding dictionary and frequency changes." (interactive) (if (wnn-server-isconnect) (wnn-server-close))) (defun close-wnn () +"Cleanly shutdown connection to Wnn servers, saving data and calling egg:close-wnn-hook" (interactive) (if (wnn-server-isconnect) (progn @@ -1010,6 +1101,7 @@ (setq i (1+ i))))) (defun henkan-kakutei () + "Accept the current henkan region" (interactive) (egg:bunsetu-face-off) (egg:henkan-face-off) @@ -1060,6 +1152,7 @@ ;; end of patch (defun henkan-kakutei-before-point () +"Accept the henkan region before point, and put the rest back into a fence." (interactive) (egg:bunsetu-face-off) (egg:henkan-face-off) @@ -1100,7 +1193,9 @@ (use-local-map fence-mode-map) (egg:mode-line-display)) +;; ### Should probably put this on a key. (defun sai-henkan () +"Reconvert last henkan entry." (interactive) (if egg:henkan-mode-in-use nil (let ((finished nil)) @@ -1131,8 +1226,8 @@ ;; make dai-bunsetu extent and sho-bunsetu extent if they do not exist. ;; put thier faces to extents and move them to each bunsetu. (let* ((bunsetu-begin *bunsetu-number*) - (bunsetu-end) - (bunsetu-suu (wnn-server-bunsetu-suu))) + (bunsetu-end)) +; (bunsetu-suu (wnn-server-bunsetu-suu))) ; dai bunsetu (if egg:*dai-bunsetu-face* (progn @@ -1252,7 +1347,7 @@ (defun henkan-goto-kouho (kouho-number) ; (egg:bunsetu-face-off) (let ((point (point)) - (yomi (bunsetu-yomi *bunsetu-number*)) +; (yomi (bunsetu-yomi *bunsetu-number*)) (max) (min)) (setq kouho-number @@ -1330,8 +1425,7 @@ (bunsetu-length-henko l))) (defun bunsetu-length-henko (length) - (let ((i 0) - (r (wnn-server-bunsetu-henkou *bunsetu-number* length egg:*dai*)) + (let ((r (wnn-server-bunsetu-henkou *bunsetu-number* length egg:*dai*)) (start (max 0 (1- *bunsetu-number*)))) (cond((null r) (egg:error (wnn-server-get-msg))) @@ -1749,7 +1843,7 @@ (if (= (current-column) 0) 1 0) -1) *diced-dict-info*)) - (hindo (nth 2 dict-item)) +; (hindo (nth 2 dict-item)) (dict-number (nth 3 dict-item)) (serial-number (nth 4 dict-item)) ) @@ -1760,13 +1854,13 @@ (defun diced-hindo-set (&optional newhindo) (interactive) (if (null newhindo) - (setq newhindo (read-minibuffer (egg:msg-get 'enter-hindo)))) + (setq newhindo (read-expression (egg:msg-get 'enter-hindo)))) (let* ((dict-item (nth (+ (count-lines (point-min) (point)) (if (= (current-column) 0) 1 0) -1) *diced-dict-info*)) - (hindo (nth 2 dict-item)) +; (hindo (nth 2 dict-item)) (dict-number (nth 3 dict-item)) (serial-number (nth 4 dict-item)) ) @@ -1793,10 +1887,10 @@ (kanji (nth 0 dict-item)) (bunpo (nth 1 dict-item)) (hinshi (wnn-server-hinsi-name bunpo)) - (hindo (nth 2 dict-item)) +; (hindo (nth 2 dict-item)) (dict-number (nth 3 dict-item)) (dict-name (wnn-dict-name dict-number (wnn-server-dict-list))) - (sys-dict-p (null (memq dict-number (wnn-server-hinsi-dicts -1)))) +; (sys-dict-p (null (memq dict-number (wnn-server-hinsi-dicts -1)))) (serial-number (nth 4 dict-item)) ) (if (notify-yes-or-no-p (egg:msg-get 'remove-notify) @@ -1829,7 +1923,7 @@ (if (eobp) (forward-line -1))) (defun diced-mode () - "Mode for \"editing\" dictionaries. + "Mode for \"editing\" Wnn dictionaries. In diced, you are \"editing\" a list of the entries in dictionaries. You can move using the usual cursor motion commands. Letters no longer insert themselves. Instead, @@ -1926,6 +2020,6 @@ hindo hyoka daihyoka kangovect) t))))))))) -(provide 'wnn-egg) +(provide 'egg-wnn) -;;; wnn-egg.el ends here +;;; egg-wnn.el ends here