;;; Code:
-(require 'egg-edep)
-
-(defconst canna-support-languages '(Japanese))
+(defconst canna-support-languages '("Japanese"))
(eval-when-compile
(defmacro CANNA-const (c)
(set-buffer buf)
(erase-buffer)
(buffer-disable-undo)
- (set-buffer-multibyte nil))
+ (setq enable-multibyte-characters nil))
(setq result (cannarpc-open proc (user-login-name)))
(if (< result 0)
(let ((msg (cannarpc-get-error-message (- result))))
;;; Code:
-(require 'egg-edep)
-
-(defconst sj3-support-languages '(Japanese))
+(defconst sj3-support-languages '("Japanese"))
(eval-when-compile
(defmacro SJ3-const (c)
(set-buffer buf)
(erase-buffer)
(buffer-disable-undo)
- (set-buffer-multibyte nil))
+ (setq enable-multibyte-characters nil))
;; Initialize dictionaries
(setq sj3-sys-dict-list nil)
(setq sj3-user-dict-list nil)
(setq ret (sj3rpc-open-stdy proc name))
(if (= ret 0)
(setq trying nil)
- (message "\e$B3X=,%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s\e(B" name)
+ (message "\92\81³Ø\92\81½¬\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤¬\92\81¤¢\92\81¤ê\92\81¤Þ\92\81¤»\92\81¤ó" name)
(if (/= ret (SJ3-const FileNotExist))
(error "Fatal1") ; XXX
(if (and (y-or-n-p
- (format "\e$B3X=,%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s!#:n$j$^$9$+\e(B? "
+ (format "\92\81³Ø\92\81½¬\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤¬\92\81¤¢\92\81¤ê\92\81¤Þ\92\81¤»\92\81¤ó\92\81¡£\92\81ºî\92\81¤ê\92\81¤Þ\92\81¤¹\92\81¤«? "
name))
(sj3rpc-make-directory proc
(file-name-directory name))
;; ignore error
(= (sj3rpc-make-stdy proc name) 0))
- (message "\e$B3X=,%U%!%$%k\e(B(%s)\e$B$r:n$j$^$7$?\e(B" name)
+ (message "\92\81³Ø\92\81½¬\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤ò\92\81ºî\92\81¤ê\92\81¤Þ\92\81¤·\92\81¤¿" name)
(error "Fatal2"))))))) ; XXX
(defun sj3-open-dictionary (proc name passwd)
(setq ret (sj3rpc-open-dictionary proc name passwd))
(if (>= ret 0)
(setq trying nil)
- (message "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s\e(B" name)
+ (message "\92\81¼\92\81½ñ\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤¬\92\81¤¢\92\81¤ê\92\81¤Þ\92\81¤»\92\81¤ó" name)
(setq ret (- ret)) ; Get error code.
(if (/= ret (SJ3-const FileNotExist))
(error "Fatal3 %d" ret) ; XXX
(if (and (y-or-n-p
- (format "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s!#:n$j$^$9$+\e(B? "
+ (format "\92\81¼\92\81½ñ\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤¬\92\81¤¢\92\81¤ê\92\81¤Þ\92\81¤»\92\81¤ó\92\81¡£\92\81ºî\92\81¤ê\92\81¤Þ\92\81¤¹\92\81¤«? "
name))
(= (sj3rpc-make-dictionary proc name) 0))
- (message "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$r:n$j$^$7$?\e(B" name)
+ (message "\92\81¼\92\81½ñ\92\81¥Õ\92\81¥¡\92\81¥¤\92\81¥ë(%s)\92\81¤ò\92\81ºî\92\81¤ê\92\81¤Þ\92\81¤·\92\81¤¿" name)
(error "Fatal4"))))) ; XXX
ret))
;;
;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
-;; This file is part of EGG.
+;; This file will be part of EGG (in future).
;; EGG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;;; Commentary:
;;; Code:
-
-(require 'egg-edep)
-
(defgroup wnn nil
"Wnn interface for Tamagotchy"
:group 'egg)
-(defconst wnn-support-languages '(Japanese Chinese-GB Chinese-CNS Korean))
+(defconst wnn-support-languages
+ '("Japanese" "Chinese-GB" "Chinese-CNS" "Korean"))
(eval-when-compile
(defmacro WNN-const (c)
;; The port number should be initialized from $WNNLIB/serverdefs by wnn-init
(defconst wnn-server-info-list
- ;; language locale server port stream coding-system hostname
- '((Japanese "ja_JP" jserver wnn-jport "Wnn" fixed-euc-jp wnn-jserver)
- (Chinese-GB "zh_CN" cserver wnn-cport "cWnn" fixed-euc-cn wnn-cserver)
- (Chinese-CNS "zh_TW" tserver wnn-tport "tWnn" fixed-euc-tw wnn-tserver)
- (Korean "ko_KR" kserver wnn-kport "kWnn" fixed-euc-kr wnn-kserver)))
-
-(defsubst wnn-server-get-info (lang)
- (assq (or lang its-current-language) wnn-server-info-list))
-
-(defsubst wnn-server-language (info)
- (car info))
+ ;; language locale server port stream coding-system hostname
+ '(("Japanese" "ja_JP" jserver wnn-jport "Wnn" fixed-euc-jp wnn-jserver)
+ ("Chinese-GB" "zh_CN" cserver wnn-cport "cWnn" fixed-euc-cn wnn-cserver)
+ ("Chinese-CNS" "zh_TW" tserver wnn-tport "tWnn" fixed-euc-tw wnn-tserver)
+ ("Korean" "ko_KR" kserver wnn-kport "kWnn" fixed-euc-kr wnn-kserver)))
+
+(defun wnn-get-server-info (lang)
+ (let (info)
+ (if (null lang)
+ (setq lang its-current-language))
+ (if (setq info (assoc lang wnn-server-info-list)) info
+ (assoc "Japanese" wnn-server-info-list))))
(defsubst wnn-server-locale (info)
(nth 1 info))
(defun wnn-start-conversion (yomi &optional language dic-set reverse)
"Convert YOMI string to kanji, and enter conversion mode.
Return the list of bunsetsu."
- (let* ((server-info (wnn-server-get-info language))
+ (let* ((server-info (wnn-get-server-info language))
(env (wnn-get-environment server-info dic-set reverse))
(result (wnnrpc-renbunsetsu-conversion env yomi
(WNN-const BUN_SENTOU) "")))
(defvar wnn-sticky-environment-flag nil
"*Flag which specifies sticky environment.")
-(defmacro wnn-for-each-environment (lang env &rest body)
- `(let* ((server-info (wnn-server-get-info ,lang))
- (server-type (wnn-server-type server-info))
- (env-list wnn-environments))
- (if server-type
- (while env-list
- (let ((,env (car env-list)))
- ,@body)
- (setq env-list (cdr env-list))))))
-
-(defun wnn-fini (lang &optional save-only)
- (let* ((server-info (wnn-server-get-info lang))
- (server-type (wnn-server-type server-info))
- (l wnn-environments)
- new-env-list del-list env proc)
- (if server-type
- (progn
- (message "%s \e$B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$F$$$^$9\e(B"
- (wnn-server-stream-name server-info))
- (while l
- (setq env (car l))
- (if (eq (wnnenv-get-server-type env) server-type)
- (condition-case nil
- (progn
- (wnn-save-dictionaries env)
- (if (null save-only)
- (progn
- (setq del-list (nconc del-list (list env)))
- (if wnn-sticky-environment-flag
- (wnnrpc-make-env-sticky env)
- (wnnrpc-make-env-unsticky env))
- (wnnrpc-disconnect env))))
- (error nil))
- (setq new-env-list (nconc new-env-list (list env))))
- (setq l (cdr l)))
- (message "%s \e$B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$^$7$?\e(B"
- (wnn-server-stream-name server-info))
- (if (null save-only)
- (progn
- (setq proc (and del-list (wnnenv-get-proc (car del-list))))
- (if (and proc (eq (process-status proc) 'open))
- (progn
- (wnnrpc-close proc)
- (kill-buffer (process-buffer proc))))
- (setq wnn-environments new-env-list)))))))
-
-(defun wnn-close (lang)
- (interactive (list (wnn-read-active-lang)))
- (or (listp lang)
- (setq lang (list lang)))
- (while lang
- (wnn-fini (car lang))
- (setq lang (cdr lang))))
-
-(defun wnn-dictionary-save (lang)
- (interactive (list (wnn-read-active-lang)))
- (or (listp lang)
- (setq lang (list lang)))
- (while lang
- (wnn-fini (car lang) t)
- (setq lang (cdr lang))))
-
-(defun wnn-read-active-lang ()
- (let ((completion-ignore-case t)
- (env wnn-environments)
- langs server server-list)
- (while env
- (setq server (wnnenv-get-server-type (car env))
- env (cdr env))
- (if (null (member server server-list))
- (setq server-list (cons server server-list))))
- (setq langs (delete nil
- (mapcar (lambda (info)
- (if (memq (wnn-server-type info) server-list)
- (wnn-server-language info)))
- wnn-server-info-list)))
- (if (<= (length langs) 1)
- langs
- (setq langs (cons (cons "All" langs)
- (mapcar (lambda (lang) (cons (symbol-name lang) lang))
- langs)))
- (cdr (assoc (completing-read "language? " langs nil t) langs)))))
+(defun wnn-fini (lang) ; XXX
+ ; tamago-971009 version
+ ; argument LANG is still dummy
+ (if wnn-environments
+ (let ((l wnn-environments))
+ (condition-case nil
+ (while l
+ (let ((env (car l)))
+ (if wnn-sticky-environment-flag
+ (wnnrpc-make-env-sticky env)
+ (wnnrpc-make-env-unsticky env))
+ (wnnrpc-disconnect env)
+ (setq l (cdr l))))
+ (error nil))
+ (setq l wnn-environments)
+ (while l
+ (let ((proc (wnnenv-get-proc (car l))))
+ (if (eq (process-status proc) 'open)
+ (progn
+ (wnnrpc-close proc)
+ (kill-buffer (process-buffer proc)))
+ (setq l (cdr l)))))
+ (setq wnn-environments nil))))
\f
;;
(defun wnn-comm-sentinel (proc reason) ; assume it is close
(set-buffer buf)
(erase-buffer)
(buffer-disable-undo)
- (setq egg-fixed-euc (wnn-server-coding-system server-info))
- (set-buffer-multibyte nil))
+ (setq enable-multibyte-characters nil
+ egg-fixed-euc (wnn-server-coding-system server-info)))
(cond
((null hostname-list)
(setq hostname-list '("localhost")))
(setq hostname (car hostname-list)
hostname-list (cdr hostname-list))
(message msg-form server-type hostname)
+ (sit-for 0)
(condition-case result
(setq proc (open-network-stream (wnn-server-stream-name server-info)
buf
;(defun wnn-set-conversion-mode ()
; (jl-set-environment))
-(defsubst wnn-dicinfo-entry (info) (aref info 0))
-(defsubst wnn-dicinfo-id (info freq) (aref info (+ 1 freq)))
-(defsubst wnn-dicinfo-mode (info freq) (aref info (+ 3 freq)))
-(defsubst wnn-dicinfo-enable (info) (aref info 5))
-(defsubst wnn-dicinfo-nice (info) (aref info 6))
-(defsubst wnn-dicinfo-reverse (info) (aref info 7))
-(defsubst wnn-dicinfo-comment (info) (aref info 8))
-(defsubst wnn-dicinfo-name (info freq) (aref info (+ 9 freq)))
-(defsubst wnn-dicinfo-passwd (info freq) (aref info (+ 11 freq)))
-(defsubst wnn-dicinfo-type (info) (aref info 13))
-(defsubst wnn-dicinfo-words (info) (aref info 14))
-(defsubst wnn-dicinfo-local (info freq) (aref info (+ 15 freq)))
-
-(defun wnn-save-dictionaries (env)
- (let ((dic-list (wnnrpc-get-dictionary-list-with-environment env))
- (result 0) info freq)
- (while (and dic-list
- (>= result 0))
- (setq info (car dic-list)
- dic-list (cdr dic-list)
- freq 0)
- (while (<= freq 1)
- (if (and (> (wnn-dicinfo-id info freq) 0)
- (= (wnn-dicinfo-mode info freq) 0))
- (if (= (wnn-dicinfo-local info freq) 1)
- (setq result (wnnrpc-write-file env
- (wnn-dicinfo-id info freq)
- (wnn-dicinfo-name info freq)))
- (message "WNN: remote dictionary (%s) not supported yet"
- (wnn-dicinfo-name info freq))
- (ding)
- (sit-for 1)))
- (if (< result 0)
- (wnnrpc-disconnect env))
- (setq freq (1+ freq))))))
+(defun wnn-save-dictionaries ()
+ (for-each-environment
+ js-dic-list
+ (while (< i count)
+ dic => id
+ js-file-write
+ hindo => id
+ js-file-write)))
(defun wnn-version (proc)
"Return version number string of WNN server."
"Macro for WNN constants."
(cond ((eq c 'JS_VERSION) 0)
((eq c 'JS_OPEN) 1)
- ((eq c 'JS_CLOSE) 3)
- ((eq c 'JS_CONNECT) 5)
- ((eq c 'JS_DISCONNECT) 6)
- ((eq c 'JS_ENV_EXIST) 7)
- ((eq c 'JS_ENV_STICKY) 8)
- ((eq c 'JS_ENV_UNSTICKY) 9)
- ((eq c 'JS_KANREN) 17)
- ((eq c 'JS_KANTAN_SHO) 18)
- ((eq c 'JS_KANZEN_SHO) 19)
- ((eq c 'JS_KANTAN_DAI) 20)
- ((eq c 'JS_KANZEN_DAI) 21)
- ((eq c 'JS_HINDO_SET) 24)
- ((eq c 'JS_DIC_ADD) 33)
- ((eq c 'JS_DIC_DELETE) 34)
- ((eq c 'JS_DIC_USE) 35)
- ((eq c 'JS_DIC_LIST) 36)
- ((eq c 'JS_DIC_INFO) 37)
- ((eq c 'JS_FUZOKUGO_SET) 41)
- ((eq c 'JS_FUZOKUGO_GET) 48)
- ((eq c 'JS_WORD_ADD) 49)
- ((eq c 'JS_WORD_DELETE) 50)
- ((eq c 'JS_WORD_SEARCH) 51)
- ((eq c 'JS_WORD_SEARCH_BY_ENV) 52)
- ((eq c 'JS_WORD_INFO) 53)
- ((eq c 'JS_WORD_COMMENT_SET) 54)
- ((eq c 'JS_PARAM_SET) 65)
- ((eq c 'JS_PARAM_GET) 66)
- ((eq c 'JS_MKDIR) 81)
- ((eq c 'JS_ACCESS) 82)
- ((eq c 'JS_WHO) 83)
- ((eq c 'JS_ENV_LIST) 85)
- ((eq c 'JS_FILE_LIST_ALL) 86)
- ((eq c 'JS_DIC_LIST_ALL) 87)
- ((eq c 'JS_FILE_READ) 97)
- ((eq c 'JS_FILE_WRITE) 98)
- ((eq c 'JS_FILE_SEND) 99)
- ((eq c 'JS_FILE_RECEIVE) 100)
- ((eq c 'JS_HINDO_FILE_CREATE) 101)
- ((eq c 'JS_DIC_FILE_CREATE) 102)
- ((eq c 'JS_FILE_REMOVE) 103)
- ((eq c 'JS_FILE_LIST) 104)
- ((eq c 'JS_FILE_INFO) 105)
- ((eq c 'JS_FILE_LOADED) 106)
- ((eq c 'JS_FILE_LOADED_LOCAL) 107)
- ((eq c 'JS_FILE_DISCARD) 108)
- ((eq c 'JS_FILE_COMMENT_SET) 109)
- ((eq c 'JS_FILE_PASSWORD) 110)
- ((eq c 'JS_FILE_STAT) 111)
- ((eq c 'JS_KILL) 112)
- ((eq c 'JS_HINSI_LIST) 114)
- ((eq c 'JS_HINSI_NAME) 115)
- ((eq c 'JS_HINSI_NUMBER) 116)
- ((eq c 'JS_HINSI_DICTS) 117)
- ((eq c 'JS_HINSI_TABLE_SET) 118)
+ ((eq c 'JS_CLOSE) 3)
+ ((eq c 'JS_CONNECT) 5)
+ ((eq c 'JS_DISCONNECT) 6)
+ ((eq c 'JS_ENV_EXIST) 7)
+ ((eq c 'JS_ENV_STICKY) 8)
+ ((eq c 'JS_ENV_UNSTICKY) 9)
+ ((eq c 'JS_KANREN) 17)
+ ((eq c 'JS_KANTAN_SHO) 18)
+ ((eq c 'JS_KANZEN_SHO) 19)
+ ((eq c 'JS_KANTAN_DAI) 20)
+ ((eq c 'JS_KANZEN_DAI) 21)
+ ((eq c 'JS_HINDO_SET) 24)
+ ((eq c 'JS_DIC_ADD) 33)
+ ((eq c 'JS_DIC_DELETE) 34)
+ ((eq c 'JS_DIC_USE) 35)
+ ((eq c 'JS_DIC_LIST) 36)
+ ((eq c 'JS_DIC_INFO) 37)
+ ((eq c 'JS_FUZOKUGO_SET) 41)
+ ((eq c 'JS_FUZOKUGO_GET) 48)
+ ((eq c 'JS_WORD_ADD) 49)
+ ((eq c 'JS_WORD_DELETE) 50)
+ ((eq c 'JS_WORD_SEARCH) 51)
+ ((eq c 'JS_WORD_SEARCH_BY_ENV) 52)
+ ((eq c 'JS_WORD_INFO) 53)
+ ((eq c 'JS_WORD_COMMENT_SET) 54)
+ ((eq c 'JS_PARAM_SET) 65)
+ ((eq c 'JS_PARAM_GET) 66)
+ ((eq c 'JS_MKDIR) 81)
+ ((eq c 'JS_ACCESS) 82)
+ ((eq c 'JS_WHO) 83)
+ ((eq c 'JS_ENV_LIST) 85)
+ ((eq c 'JS_FILE_LIST_ALL) 86)
+ ((eq c 'JS_DIC_LIST_ALL) 87)
+ ((eq c 'JS_FILE_READ) 97)
+ ((eq c 'JS_FILE_WRITE) 98)
+ ((eq c 'JS_FILE_SEND) 99)
+ ((eq c 'JS_FILE_RECEIVE) 100)
+ ((eq c 'JS_HINDO_FILE_CREATE) 101)
+ ((eq c 'JS_DIC_FILE_CREATE) 102)
+ ((eq c 'JS_FILE_REMOVE) 103)
+ ((eq c 'JS_FILE_LIST) 104)
+ ((eq c 'JS_FILE_INFO) 105)
+ ((eq c 'JS_FILE_LOADED) 106)
+ ((eq c 'JS_FILE_LOADED_LOCAL) 107)
+ ((eq c 'JS_FILE_DISCARD) 108)
+ ((eq c 'JS_FILE_COMMENT_SET) 109)
+ ((eq c 'JS_FILE_PASSWORD) 110)
+ ((eq c 'JS_FILE_STAT) 111)
+ ((eq c 'JS_KILL) 112)
+ ((eq c 'JS_HINSI_LIST) 114)
+ ((eq c 'JS_HINSI_NAME) 115)
+ ((eq c 'JS_HINSI_NUMBER) 116)
+ ((eq c 'JS_HINSI_DICTS) 117)
+ ((eq c 'JS_HINSI_TABLE_SET) 118)
((eq c 'JLIB_VERSION) 16387) ; 0x4003
((eq c 'WNN_MAX_FILE_OF_AN_ENV) 60))))
(defconst wnnrpc-error-message
- '((Japanese .
+ '(("Japanese" .
[
nil
"\e$B%U%!%$%k$,B8:_$7$^$;$s\e(B"
"\e$B<-=q$KIQEY%U%!%$%k$,$D$$$F$$$^$;$s\e(B"
"\e$B%Q%9%o!<%I$N%U%!%$%k$,:n@.=PMh$^$;$s\e(B"
])
- (Chinese-GB .
+ ("Chinese-GB" .
[
nil
"\e$AND<~2;4fTZ\e(B"
"\e$AWV5d5DF56HND<~C;SP\e(B"
"password\e$A5DND<~C;SP44=(3v@4\e(B"
])
- (Chinese-CNS .
+ ("Chinese-CNS" .
[
nil
"\e$(GEFG5DbGtGc\e(B"
"\e$(GGsL(N{s"PyEFG5JtH4\e(B"
"password\e$(GN{EFG5JtH4^6PzExKt\e(B"
])
- (Korean .
+ ("Korean" .
[
nil
"\e$(CH-@O@L\e(B \e$(CA8@gGOAv\e(B \e$(C>J=@4O4Y\e(B"
(defun wnnrpc-get-error-message (errno)
"Return error message string specified by ERRNO."
- (let ((msg (cdr (or (assoc egg-default-language wnnrpc-error-message)
- (assoc its-current-language wnnrpc-error-message)
- (assoc 'Japanese wnnrpc-error-message)))))
- (or (and (< errno (length msg)) (aref msg errno))
- (format "#%d" errno))))
+ (let ((msg (or (assoc egg-default-language wnnrpc-error-message)
+ (assoc its-current-language wnnrpc-error-message)
+ (assoc "Japanese" wnnrpc-error-message))))
+ (or (aref (cdr msg) errno) (format "#%d" errno))))
(defmacro wnnrpc-call-with-environment (e vlist send-expr &rest receive-exprs)
(let ((v (append
(concat (system-name)
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") 0 16)))
(comm-call-with-proc proc (result)
- (comm-format (u U U U s) (wnn-const JS_FILE_LOADED_LOCAL)
+ (comm-format (u U U U s) (wnn-const JS_FILE_LOADED_LOCAL)
time dev inode padded-hostname)
(comm-unpack (u) result)
result))))