From 76f334e2fe809b36369c21ae700fb4111c959cde Mon Sep 17 00:00:00 2001 From: morioka Date: Sun, 30 Aug 1998 10:37:44 +0000 Subject: [PATCH] Merge egg-980316. --- egg/canna.el | 6 +- egg/sj3.el | 18 +++--- egg/wnn.el | 186 ++++++++++++++++----------------------------------------- egg/wnnrpc.el | 127 +++++++++++++++++++-------------------- 4 files changed, 123 insertions(+), 214 deletions(-) diff --git a/egg/canna.el b/egg/canna.el index c401aa2..845bfd1 100644 --- a/egg/canna.el +++ b/egg/canna.el @@ -29,9 +29,7 @@ ;;; Code: -(require 'egg-edep) - -(defconst canna-support-languages '(Japanese)) +(defconst canna-support-languages '("Japanese")) (eval-when-compile (defmacro CANNA-const (c) @@ -72,7 +70,7 @@ (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)))) diff --git a/egg/sj3.el b/egg/sj3.el index 865f42b..b011f05 100644 --- a/egg/sj3.el +++ b/egg/sj3.el @@ -29,9 +29,7 @@ ;;; Code: -(require 'egg-edep) - -(defconst sj3-support-languages '(Japanese)) +(defconst sj3-support-languages '("Japanese")) (eval-when-compile (defmacro SJ3-const (c) @@ -75,7 +73,7 @@ (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) @@ -235,17 +233,17 @@ (setq ret (sj3rpc-open-stdy proc name)) (if (= ret 0) (setq trying nil) - (message "$B3X=,%U%!%$%k(B(%s)$B$,$"$j$^$;$s(B" name) + (message "’³Ø’½¬’¥Õ’¥¡’¥¤’¥ë(%s)’¤¬’¤¢’¤ê’¤Þ’¤»’¤ó" name) (if (/= ret (SJ3-const FileNotExist)) (error "Fatal1") ; XXX (if (and (y-or-n-p - (format "$B3X=,%U%!%$%k(B(%s)$B$,$"$j$^$;$s!#:n$j$^$9$+(B? " + (format "’³Ø’½¬’¥Õ’¥¡’¥¤’¥ë(%s)’¤¬’¤¢’¤ê’¤Þ’¤»’¤ó’¡£’ºî’¤ê’¤Þ’¤¹’¤«? " name)) (sj3rpc-make-directory proc (file-name-directory name)) ;; ignore error (= (sj3rpc-make-stdy proc name) 0)) - (message "$B3X=,%U%!%$%k(B(%s)$B$r:n$j$^$7$?(B" name) + (message "’³Ø’½¬’¥Õ’¥¡’¥¤’¥ë(%s)’¤ò’ºî’¤ê’¤Þ’¤·’¤¿" name) (error "Fatal2"))))))) ; XXX (defun sj3-open-dictionary (proc name passwd) @@ -255,15 +253,15 @@ (setq ret (sj3rpc-open-dictionary proc name passwd)) (if (>= ret 0) (setq trying nil) - (message "$B<-=q%U%!%$%k(B(%s)$B$,$"$j$^$;$s(B" name) + (message "’¼­’½ñ’¥Õ’¥¡’¥¤’¥ë(%s)’¤¬’¤¢’¤ê’¤Þ’¤»’¤ó" name) (setq ret (- ret)) ; Get error code. (if (/= ret (SJ3-const FileNotExist)) (error "Fatal3 %d" ret) ; XXX (if (and (y-or-n-p - (format "$B<-=q%U%!%$%k(B(%s)$B$,$"$j$^$;$s!#:n$j$^$9$+(B? " + (format "’¼­’½ñ’¥Õ’¥¡’¥¤’¥ë(%s)’¤¬’¤¢’¤ê’¤Þ’¤»’¤ó’¡£’ºî’¤ê’¤Þ’¤¹’¤«? " name)) (= (sj3rpc-make-dictionary proc name) 0)) - (message "$B<-=q%U%!%$%k(B(%s)$B$r:n$j$^$7$?(B" name) + (message "’¼­’½ñ’¥Õ’¥¡’¥¤’¥ë(%s)’¤ò’ºî’¤ê’¤Þ’¤·’¤¿" name) (error "Fatal4"))))) ; XXX ret)) diff --git a/egg/wnn.el b/egg/wnn.el index acd5bc6..9b4e3e4 100644 --- a/egg/wnn.el +++ b/egg/wnn.el @@ -10,7 +10,7 @@ ;; ;; Maintainer: NIIBE Yutaka -;; 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 @@ -30,14 +30,12 @@ ;;; 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) @@ -168,17 +166,18 @@ ;; 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)) @@ -207,7 +206,7 @@ (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) ""))) @@ -359,88 +358,29 @@ Return the list of bunsetsu." (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 $B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$F$$$^$9(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 $B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$^$7$?(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)))) ;; (defun wnn-comm-sentinel (proc reason) ; assume it is close @@ -475,8 +415,8 @@ Return the list of bunsetsu." (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"))) @@ -486,6 +426,7 @@ Return the list of bunsetsu." (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 @@ -898,41 +839,14 @@ REVERSE specifies reverse conversion, if non nil." ;(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." diff --git a/egg/wnnrpc.el b/egg/wnnrpc.el index ee35e72..723453a 100644 --- a/egg/wnnrpc.el +++ b/egg/wnnrpc.el @@ -38,60 +38,60 @@ "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 @@ -106,7 +106,7 @@ ((eq c 'WNN_MAX_FILE_OF_AN_ENV) 60)))) (defconst wnnrpc-error-message - '((Japanese . + '(("Japanese" . [ nil "$B%U%!%$%k$,B8:_$7$^$;$s(B" @@ -226,7 +226,7 @@ "$B<-=q$KIQEY%U%!%$%k$,$D$$$F$$$^$;$s(B" "$B%Q%9%o!<%I$N%U%!%$%k$,:n@.=PMh$^$;$s(B" ]) - (Chinese-GB . + ("Chinese-GB" . [ nil "$AND<~2;4fTZ(B" @@ -346,7 +346,7 @@ "$AWV5d5DF56HND<~C;SP(B" "password$A5DND<~C;SP44=(3v@4(B" ]) - (Chinese-CNS . + ("Chinese-CNS" . [ nil "$(GEFG5DbGtGc(B" @@ -466,7 +466,7 @@ "$(GGsL(N{s"PyEFG5JtH4(B" "password$(GN{EFG5JtH4^6PzExKt(B" ]) - (Korean . + ("Korean" . [ nil "$(CH-@O@L(B $(CA8@gGOAv(B $(C>J=@4O4Y(B" @@ -590,11 +590,10 @@ (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 @@ -1354,7 +1353,7 @@ HINSHI and FUZOKU are information of preceding bunsetsu." (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)))) -- 1.7.10.4