egg-980712. gniibe
authormorioka <morioka>
Sun, 30 Aug 1998 12:17:58 +0000 (12:17 +0000)
committermorioka <morioka>
Sun, 30 Aug 1998 12:17:58 +0000 (12:17 +0000)
ChangeLog
Makefile
egg-cnv.el
egg-mlh.el
egg.el
egg/canna.el
egg/sj3.el
egg/sj3rpc.el
egg/wnn.el

index 58e4fdc..bbcbd66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,58 @@
+1998-07-12  NIIBE Yutaka  <gniibe@mri.co.jp>
+
+       * egg-mlh.el (mlh-space-bar-backward-henkan): Don't test against
+       egg-conversion-backend-alist.
+
+       * egg/wnn.el (wnn-fini-lang): Reneme from wnn-fini.
+       (wnn-fini): New implementation calling wnn-fini-lang.
+
+       (wnn-close): Call wnn-fini-lang.
+       (wnn-dictionary-save): Ditto.
+
+       * egg/canna.el (canna-fini): Delete LANG argument.
+       * egg/sj3.el (sj3-fini): Ditto.
+
+       * egg-cnv.el (egg-set-conversion-backend): Removed.
+
+       * egg/sj3.el (sj3-start-conversion): Signal error on non-supported
+       language.
+       * egg/canna.el (canna-start-conversion): Likewise.
+       * egg/wnn.el (wnn-start-conversion): Likewise.
+
+       * egg-cnv.el (egg-convert-region): Add handler for
+       lang-not-supported.
+
+       * egg/wnn.el (egg-activate-wnn): load wnnrpc here conditionally.
+       * egg/sj3.el: Likewise.
+       * egg/canna.el: Likewise.
+
+       * egg.el (egg-support-languages, egg-set-support-languages): Removed.
+       (egg-mode): Don't call egg-set-conversion-backend.
+       * egg/{canna.el, wnn.el, sj3.el}: Don't call egg-support-languages.
+
+       * egg-cnv.el (egg-set-current-backend): Removed.
+       (egg-initialize-backend, egg-start-conversion,
+       egg-start-reverse-conversion): Don't call egg-set-current-backend.
+       (egg-conversion-backend-null): Rename from *-other-languages.
+       (egg-conversion-backend-alist): Removed.
+       (egg-conversion-backend): Not buffer local.
+       (egg-finalize-backend-alist): Removed.
+
+1998-07-10  NIIBE Yutaka  <gniibe@mri.co.jp>
+
+       * egg-cnv.el (egg-start-conversion-failure-hook): New Variable.
+       (egg-start-conversion-failure-fallback): New Function.
+       (egg-convert-region): Handle error and hook on failure.
+
+       * egg/sj3.el (sj3-open): Remove bogus setq-s of sj3-sys-dict-list,
+       sj3-user-dict-list.
+
+       * egg-mlh.el (mlh-space-bar-backward-henkan): Don't emit message
+       "converting...", as it may flush out error message.
+
+       * egg/sj3rpc.el ("egg-com", "egg/sj3"): Require on compilation.
+       (sj3rpc-open): Failure when version is different.
+
 1998-07-03  KATAYAMA Yoshio <kate@pfu.co.jp>
 
        * its/erpin.el, its/hangul.el, its/hankata.el, its/hira.el,
index 07a693a..f3f4a8b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
 # Project Leader: Satoru Tomura <tomura@etl.go.jp>
 
 DOTEMACS=/home/niibe/.emacs
-LEIMDIR=/usr/local/share/emacs/20.2.892/leim
+LEIMDIR=/usr/local/share/emacs/20.2.96/leim
 SITEDIR=/usr/local/share/emacs/site-lisp
 
 INSTALL=/usr/bin/install
@@ -13,7 +13,7 @@ INSTALL=/usr/bin/install
 
 DEPS = -l ./docomp.el
 BATCHFLAGS = -batch -q -no-site-file
-EMACS = emacs
+EMACS = /usr/local/bin/emacs
 
 .SUFFIXES: .el .elc
 
@@ -70,13 +70,16 @@ leim-list.el:
          cat ${LEIMDIR}/leim-list.el leim-list-egg.el >leim-list.el; \
        fi
 
+install-leim: leim-list.el
+       ${INSTALL} leim-list.el ${SITEDIR}
+
 install-dirs:
        for d in its egg; do \
          if [ ! -d ${SITEDIR}/$$d ]; then mkdir -p ${SITEDIR}/$$d; fi; \
         done
 
 install: all install-dirs
-       for x in ${SRCS} ${ELCS}; do $(INSTALL) -m 644 $$x ${SITEDIR}/`dirname $$x`; done
+       for x in ${SRCS} ${ELCS}; do ${INSTALL} -m 644 $$x ${SITEDIR}/`dirname $$x`; done
        @echo -n "### See leim-list-egg.el for registering input method"
        @echo " (if you haven't yet)."
 
index a835836..515fb91 100644 (file)
     bunsetsu-info))
 ;;
 
-(defconst egg-conversion-backend-other-languages
-  [ egg-init-other-languages
-
-       egg-start-conversion-other-languages
-      egg-get-bunsetsu-converted-other-languages
-      egg-get-bunsetsu-source-other-languages
-      egg-list-candidates-other-languages
-         egg-get-number-of-candidates-other-languages
-         egg-get-current-candidate-number-other-languages
-         egg-get-all-candidates-other-languages
-         egg-decide-candidate-other-languages
-      egg-change-bunsetsu-length-other-languages
-    egg-end-conversion-other-languages
+(defconst egg-conversion-backend-null
+  [ egg-init-null
+
+      egg-start-conversion-null
+      egg-get-bunsetsu-converted-null
+      egg-get-bunsetsu-source-null
+      egg-list-candidates-null
+         egg-get-number-of-candidates-null
+         egg-get-current-candidate-number-null
+         egg-get-all-candidates-null
+         egg-decide-candidate-null
+      egg-change-bunsetsu-length-null
+    egg-end-conversion-null
     nil
 
-    egg-fini-other-languages
+    egg-fini-null
  ])
 
-(defun egg-init-other-languages ()
-  )
+(defun egg-init-null ()
+ )
 
-(defun egg-start-conversion-other-languages (yomi-string language)
-  (setq egg-conversion-backend egg-conversion-backend-other-languages)
+(defun egg-start-conversion-null (yomi-string language)
   (list yomi-string))
-(defun egg-get-bunsetsu-converted-other-languages (bunsetsu-info)
+(defun egg-get-bunsetsu-converted-null (bunsetsu-info)
   bunsetsu-info)
-(defun egg-get-bunsetsu-source-other-languages (bunsetsu-info)
+(defun egg-get-bunsetsu-source-null (bunsetsu-info)
   bunsetsu-info)
-(defun egg-list-candidates-other-languages (bunsetsu-info prev-bunsetsu-info)
+(defun egg-list-candidates-null (bunsetsu-info prev-bunsetsu-info)
   1)
-(defun egg-get-number-of-candidates-other-languages (bunsetsu-info)
+(defun egg-get-number-of-candidates-null (bunsetsu-info)
   1)
-(defun egg-get-current-candidate-number-other-languages (bunsetsu-info)
+(defun egg-get-current-candidate-number-null (bunsetsu-info)
   0)
-(defun egg-get-all-candidates-other-languages (bunsetsu-info)
+(defun egg-get-all-candidates-null (bunsetsu-info)
   (list bunsetsu-info))
-(defun egg-decide-candidate-other-languages (bunsetsu-info candidate-pos)
+(defun egg-decide-candidate-null (bunsetsu-info candidate-pos)
   bunsetsu-info)
-(defun egg-change-bunsetsu-length-other-languages (b0 b1 b2 len)
+(defun egg-change-bunsetsu-length-null (b0 b1 b2 len)
   (let ((s (concat b1 b2)))
     (set-text-properties 0 (length s) nil s)
     (if (= len (length s))
        (list s)
       (list (substring s 0 len) (substring s len)))))
-(defun egg-end-conversion-other-languages (bunsetsu-info-list abort)
+(defun egg-end-conversion-null (bunsetsu-info-list abort)
   nil)
-(defun egg-fini-other-languages (language)
+(defun egg-fini-null (language)
   nil)
 
-(defvar egg-conversion-backend-alist nil)
-(make-variable-buffer-local 'egg-conversion-backend-alist)
 (defvar egg-conversion-backend nil)
-(make-variable-buffer-local 'egg-conversion-backend)
-
-(defvar egg-finalize-backend-alist nil)
-
-(defun egg-set-current-backend (language)
-  (setq egg-conversion-backend
-       (cdr (assq language egg-conversion-backend-alist)))
-  (if (null egg-conversion-backend)
-      (setq egg-conversion-backend egg-conversion-backend-other-languages)))
 
 (defun egg-initialize-backend (language)
-  (egg-set-current-backend language)
   (funcall (aref egg-conversion-backend 0)))
 
 (defun egg-start-conversion (yomi-string language)
-  (egg-set-current-backend language)
   (funcall (aref egg-conversion-backend 1) yomi-string language))
 (defun egg-get-bunsetsu-converted (bunsetsu-info)
   (funcall (aref egg-conversion-backend 2) bunsetsu-info))
 (defun egg-end-conversion (bunsetsu-info-list abort)
   (funcall (aref egg-conversion-backend 10) bunsetsu-info-list abort))
 (defun egg-start-reverse-conversion (yomi-string language)
-  (egg-set-current-backend language)
   (if (aref egg-conversion-backend 11)
       (funcall (aref egg-conversion-backend 11) yomi-string language)
     (beep)))
 
 (defun egg-finalize-backend ()
-  (let ((alist egg-finalize-backend-alist))
-    (while alist
-      (funcall (car (car (car alist))) (cdr (car (car alist))))
-      (setq alist (cdr alist)))))
-
-(defun egg-set-conversion-backend (backend langs &optional force)
-  (let (pair)
-    (if backend
-       (setq egg-conversion-backend backend)
-      (setq backend egg-conversion-backend))
-    (while langs
-      (setq pair (assoc (car langs) egg-conversion-backend-alist))
-      (cond
-       ((null pair)
-       (setq egg-conversion-backend-alist
-             (cons (cons (car langs) backend) egg-conversion-backend-alist)))
-       (force
-       (setcdr pair backend)))
-      (setq pair (cons (aref backend (1- (length backend))) (car langs)))
-      (if (null (assoc pair egg-finalize-backend-alist))
-         (setq egg-finalize-backend-alist
-               (cons (list pair) egg-finalize-backend-alist)))
-      (setq langs (cdr langs)))))
+  (aref egg-conversion-backend 12))
 \f
 (defvar egg-conversion-open  "|"  "*\e$B%U%'%s%9$N;OE@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
 (defvar egg-conversion-close "|"  "*\e$B%U%'%s%9$N=*E@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
                       (assq t egg-conversion-face)))))
     (if face (cdr face) egg-conversion-face)))
 
+(defvar egg-start-conversion-failure-hook
+  '(egg-start-conversion-failure-fallback)
+  "Hook which runs on failure of conversion.")
+
+;; SAIGO no shudan
+(defun egg-start-conversion-failure-fallback (language)
+  (setq egg-conversion-backend egg-conversion-backend-null))
+
 ;;
 (defun egg-convert-region (start end)
   (interactive "r")
   (let ((source (buffer-substring start end))
        (no-prop-source (buffer-substring-no-properties start end))
-       bunsetsu-info-list len result i j s)
+       len result i j s)
     (if (>= start end)
        ;; nothing to do
        nil
        (while (< i len)
          (setq egg-current-language (get-text-property i 'egg-lang source)
                j (egg-next-single-property-change i 'egg-lang source len))
-         (condition-case result
-             (setq bunsetsu-info-list (egg-start-conversion
-                                       (substring no-prop-source i j)
-                                       egg-current-language))
-           (error                      ; XXX: catching all error is BADBADBAD
-            (setq bunsetsu-info-list (egg-start-conversion-other-languages
-                                      (substring no-prop-source i j)
-                                      egg-current-language))
-            (message "egg %s backend: %s"
-                     egg-current-language (nth 1 result))))
-         (egg-insert-bunsetsu-list bunsetsu-info-list
-                                   (if (< j len) 'contine t))
+         (let (bunsetsu-info-list)
+           (while (null bunsetsu-info-list)
+             (condition-case err
+                 (setq bunsetsu-info-list (egg-start-conversion
+                                           (substring no-prop-source i j)
+                                           egg-current-language))
+               ;; Don't catch programming error
+               (lang-not-supported
+                (message "Language not supported: %s" egg-current-language)
+                (ding)
+                (setq bunsetsu-info-list
+                      (egg-start-conversion-null
+                       (substring no-prop-source i j)
+                       egg-current-language)))
+               (file-error             
+                (message "Error on %s backend: %s"
+                         egg-current-language (nth 1 err))
+                (ding)
+                (sit-for 1)
+                (run-hook-with-args-until-success
+                 'egg-start-conversion-failure-hook egg-current-language))))
+           (egg-insert-bunsetsu-list bunsetsu-info-list
+                                     (if (< j len) 'contine t)))
          (setq i j))
        (goto-char start)))))
 
index 41b5129..e3f8297 100644 (file)
@@ -43,7 +43,7 @@ Or else, execute command that space-bar invokes usually."
   (let ((henkan-begin nil)
         (inhibit-henkan t)
         (its-disable-special-action t))
-    (if (null (assq 'Japanese egg-conversion-backend-alist))
+    (if (null egg-conversion-backend)
        (progn
           (setq egg-mode-preference nil)
           (activate-input-method (concat "japanese-egg-" mlh-default-backend)))
@@ -53,11 +53,7 @@ Or else, execute command that space-bar invokes usually."
     (if henkan-begin
         (if (or inhibit-henkan (= henkan-begin (point)))
             (egg-do-auto-fill)
-          (progn
-            (message "Converting...")
-            (sit-for 0)
-           (egg-convert-region henkan-begin (point))
-            (message "") ))
+         (egg-convert-region henkan-begin (point)))
       (setq this-command 'self-insert-command)
       (call-interactively 'self-insert-command))))
 
diff --git a/egg.el b/egg.el
index 601c981..474f59b 100644 (file)
--- a/egg.el
+++ b/egg.el
@@ -61,7 +61,6 @@
     (if (null (string= (car arg) egg-last-method-name))
        (progn
          (funcall (nth 1 arg))
-         (egg-set-conversion-backend nil (list its-current-language) t)
          (setq egg-default-language its-current-language)))
     (setq egg-last-method-name (car arg))
     (use-local-map (if egg-mode-preference
@@ -76,7 +75,8 @@
   "Generate modefull keymap for EGG mode."  
   (let ((map (make-sparse-keymap))
        (i 33))
-    (define-key map "\C-_" 'egg-jis-code-input)
+    ;; BAD BAD BAD it should be UNDO
+    ;;    (define-key map "\C-_" 'egg-jis-code-input)
     (while (< i 127)
       (define-key map (vector i) 'egg-self-insert-char)
       (setq i (1+ i)))
 (require 'egg-mlh)
 (require 'egg-cnv)
 (require 'egg-com)
-(require 'custom)
+(require 'custom)                      ; Really?
 
 (defgroup egg nil
   "Tamagotchy --- EGG Versio 4.0")
 
-(defvar egg-support-languages nil)
-
-(defun egg-set-support-languages (langs)
-  (while langs
-    (if (null (member (car langs) egg-support-languages))
-       (setq egg-support-languages (cons (car langs) egg-support-languages)))
-    (setq langs (cdr langs))))
-
 (add-hook 'kill-emacs-hook 'egg-kill-emacs-function)
 (defun egg-kill-emacs-function ()
   (egg-finalize-backend))
index 80f04b6..dfa8014 100644 (file)
@@ -31,8 +31,6 @@
 
 (require 'egg-edep)
 
-(defconst canna-support-languages '(Japanese))
-
 (eval-when-compile
   (defmacro CANNA-const (c)
     (cond ((eq c 'FileNotExist) xxxxxxxxxxxxxx)
 (defun canna-start-conversion (yomi lang)
   "Convert YOMI string to kanji, and enter conversion mode.
 Return the list of bunsetsu."
-  (let ((env (canna-get-environment)))
-    (cannarpc-begin-conversion env yomi)))
+  (if (eq lang 'Japanese)
+      (let ((env (canna-get-environment)))
+       (cannarpc-begin-conversion env yomi))
+    (signal 'lang-not-supported)))    
 
 (defun canna-end-conversion (bunsetsu-list abort)
   (let* ((env (cannabunsetsu-get-env (car bunsetsu-list)))
@@ -267,21 +267,18 @@ Return the list of bunsetsu."
       (list bunsetsu1))))
 
 ;;;;;;;;;;;;;; MADAMADA
-(defun canna-fini (lang)
+(defun canna-fini ()
 )
 
 ;;; setup
-
 (require 'egg)
-(load "egg/cannarpc")
 
 ;;;###autoload
 (defun egg-activate-canna (&rest arg)
   "Activate CANNA backend of Tamagotchy."
-  (egg-set-support-languages canna-support-languages)
-  (egg-set-conversion-backend canna-conversion-backend 
-                             canna-support-languages
-                             nil)
+  (setq egg-conversion-backend canna-conversion-backend)
+  (if (not (fboundp 'cannarpc-open))
+      (load-library "egg/canna"))
   (apply 'egg-mode arg))
 
 ;;; egg/canna.el ends here.
index 865f42b..0827c33 100644 (file)
@@ -31,8 +31,6 @@
 
 (require 'egg-edep)
 
-(defconst sj3-support-languages '(Japanese))
-
 (eval-when-compile
   (defmacro SJ3-const (c)
     (cond ((eq c 'FileNotExist) 35)
@@ -57,7 +55,7 @@
  ])
 
 (defvar sj3-server-port 3000 "Port number of SJ3 server")
-(defvar sj3-stdy-size 0 "STDYSIZE of SJ3 server")
+(defvar sj3-stdy-size 0 "STDYSIZE of SJ3 server (will be set on connection)")
 (defvar sj3-hostname "localhost"
   "Hostname of SJ3 server")
 
 
 (defun sj3-open (hostname)
   "Establish the connection to SJ3 server.  Return process object."
-  (let* ((buf (generate-new-buffer " *SJ3*"))
-        (proc (open-network-stream "SJ3" buf hostname sj3-server-port))
-        result)
+  (let ((buf (generate-new-buffer " *SJ3*"))
+       proc result)
+    (condition-case err
+       (setq proc (open-network-stream "SJ3" buf hostname sj3-server-port))
+      (error
+       (kill-buffer buf)
+       (signal 'file-error (cdr err))))        ; Re-raise the signal with file-error
     (process-kill-without-query proc)
     (set-process-coding-system proc 'no-conversion 'no-conversion)
     (set-marker-insertion-type (process-mark proc) t)
       (erase-buffer)
       (buffer-disable-undo)
       (set-buffer-multibyte nil))
-    ;; Initialize dictionaries
-    (setq sj3-sys-dict-list nil)
-    (setq sj3-user-dict-list nil)
     (setq result (sj3rpc-open proc (system-name) (user-login-name)))
     (if (< result 0)
        (let ((msg (sj3rpc-get-error-message (- result))))
          (delete-process proc)
          (kill-buffer buf)
-         (error "Can't open SJ3 session (%s): %s" hostname msg)))
-    (setq result (sj3rpc-get-stdy-size proc))
-    (if (< result 0)
-       (let ((msg (sj3rpc-get-error-message (- result))))
-         (delete-process proc)
-         (kill-buffer buf)
-         (error "Can't get SJ3 STDYSIZE: %s"msg)))
-    (setq sj3-stdy-size result)
-    proc))
-
-;; (defun sj3-open (hostname-list)
-;;   "Establish the connection to SJ3 server.  Return process object."
-;;   (let* ((buf (generate-new-buffer " *SJ3*"))
-;;      (msg-form "SJ3: connecting to sj3serv at %s...")
-;;      hostname proc result msg)
-;;     (save-excursion
-;;       (set-buffer buf)
-;;       (erase-buffer)
-;;       (buffer-disable-undo)
-;;       (setq enable-multibyte-characters nil))
-;;     (cond
-;;      ((null hostname-list)
-;;       (setq hostname-list '("localhost")))
-;;      ((null (listp hostname-list))
-;;       (setq hostname-list (list hostname-list))))
-;;     (while (and hostname-list (null proc))
-;;       (setq hostname (car hostname-list)
-;;         hostname-list (cdr hostname-list))
-;;       (message msg-form hostname)
-;;       (sit-for 0)
-;;       (condition-case result
-;;       (setq proc (open-network-stream "SJ3" buf hostname sj3-server-port))
-;;     (error nil))
-;;       (if proc
-;;       (progn
-;;         (process-kill-without-query proc)
-;;         (set-process-coding-system proc 'no-conversion 'no-conversion)
-;;         (set-marker-insertion-type (process-mark proc) t)
-;;         ;; Initialize dictionaries
-;;         (setq sj3-sys-dict-list nil)
-;;         (setq sj3-user-dict-list nil)
-;;         (setq result (sj3rpc-open proc (system-name) (user-login-name)))
-;;         (if (< result 0)
-;;             (progn
-;;               (delete-process proc)
-;;               (setq proc nil
-;;                     msg (format "Can't open SJ3 session (%s): %s"
-;;                                 hostname msg)))
-;;           (setq result (sj3rpc-get-stdy-size proc))
-;;           (if (< result 0)
-;;               (progn
-;;                 (delete-process proc)
-;;                 (setq proc nil
-;;                       msg (format "Can't get SJ3 STDYSIZE: %s"
-;;                                   (sj3rpc-get-error-message (- result)))))
-;;             (setq sj3-stdy-size result))))))
-;;     (if proc
-;;     (progn
-;;       (setq sj3-open-message (format (concat msg-form "done") hostname))
-;;       proc)
-;;       (kill-buffer buf)
-;;       (error "%s" (or msg "no sj3serv available")))))
+         (signal 'file-error
+              (list (format "Can't open SJ3 session (%s): %s" hostname msg))))
+      (setq result (sj3rpc-get-stdy-size proc))
+      (if (< result 0)
+         (let ((msg (sj3rpc-get-error-message (- result))))
+           (delete-process proc)
+           (kill-buffer buf)
+           (signal 'file-error
+                   (list (format "Can't get SJ3 STDYSIZE: %s" msg)))))
+      (setq sj3-stdy-size result)
+      proc)))
 
 ;; <env> ::= [ <proc> <dictionary-list> ]
 (defvar sj3-environment nil
 (defun sj3-start-conversion (yomi &optional lang)
   "Convert YOMI string to kanji, and enter conversion mode.
 Return the list of bunsetsu."
-  (let ((env (sj3-get-environment)))
-    (sj3rpc-begin env yomi)))
+  (if (eq lang 'Japanese)
+      (let ((env (sj3-get-environment)))
+       (sj3rpc-begin env yomi))
+    (signal 'lang-not-supported)))
 
 (defun sj3-end-conversion (bunsetsu-list abort)
   (if abort
@@ -354,7 +304,7 @@ Return the list of bunsetsu."
        (list bunsetsu1 bunsetsu2)
       (list bunsetsu1))))
 
-(defun sj3-fini (lang)
+(defun sj3-fini ()
   (let ((proc (sj3env-get-proc sj3-environment))
        (dict-list (sj3env-get-dictionary-list sj3-environment))
        dict)
@@ -367,16 +317,14 @@ Return the list of bunsetsu."
   (setq sj3-environment nil))
 
 ;;; setup
-
 (require 'egg)
-(load "egg/sj3rpc")
 
 ;;;###autoload
 (defun egg-activate-sj3 (&rest arg)
   "Activate SJ3 backend of Tamagotchy."
-  (egg-set-support-languages sj3-support-languages)
-  (egg-set-conversion-backend sj3-conversion-backend 
-                             sj3-support-languages)
+  (setq egg-conversion-backend sj3-conversion-backend)
+  (if (not (fboundp 'sj3rpc-open))
+      (load-library "egg/sj3rpc"))
   (apply 'egg-mode arg))
 
 ;;; egg/sj3.el ends here.
index 9520e53..4d76603 100644 (file)
@@ -33,7 +33,9 @@
 
 (eval-when-compile
   (require 'egg-com)
-;;  (load-library "egg/sj3")
+
+  ;; To get definition of sj3-make-bunsetsu and others
+  (load-library "egg/sj3")
   (defmacro sj3-const (c)
     (cond ((eq c 'OPEN)            1)
          ((eq c 'CLOSE)           2)
          (t (error "No such constant")))))
 
 ;; XXX
-(defconst sj3rpc-error-message (vector ))
+(defconst sj3rpc-error-message 
+     [ 
+      "Error #0 \e$B$G$9\e(B"
+      ])
 
 (defun sj3rpc-get-error-message (errno)
   (or (and (>= errno 0)
                 ;; program name
                 (format "%d.emacs-egg" (emacs-pid)))
     (comm-unpack (u) result)
-    (if (= result -2)
-       0
-      result)))
+    (if (= result -2)                  ; negated version number
+       0                               ; OK
+      -1)))                            ; Failure (different version)
 
 (defun sj3rpc-close (proc)
   (comm-call-with-proc proc (result)
index 1e8330d..3891e47 100644 (file)
 (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))
-        (env (wnn-get-environment server-info dic-set reverse))
-        (result (wnnrpc-renbunsetsu-conversion env yomi
-                                               (WNN-const BUN_SENTOU) "")))
-    (wnnenv-set-daibunsetsu-info env (car result))
-    (cdr result)))
+  (let ((server-info (wnn-server-get-info language)))
+    (if server-info
+       (let* ((env (wnn-get-environment server-info dic-set reverse))
+              (result (wnnrpc-renbunsetsu-conversion env yomi
+                                                     (WNN-const BUN_SENTOU) "")))
+         (wnnenv-set-daibunsetsu-info env (car result))
+         (cdr result))
+    (signal 'lang-not-supported))))
 
 (defun wnn-start-reverse-conversion (yomi &optional language dic-set)
   (wnn-start-conversion yomi language dic-set t))
@@ -369,7 +371,13 @@ Return the list of bunsetsu."
            ,@body)
          (setq env-list (cdr env-list))))))
 
-(defun wnn-fini (lang &optional save-only)
+(defun wnn-fini ()
+  (let ((l wnn-support-languages))
+    (while l
+      (wnn-fini-lang (car l))
+      (setq l (cdr l)))))
+
+(defun wnn-fini-lang (lang &optional save-only)
   (let* ((server-info (wnn-server-get-info lang))
         (server-type (wnn-server-type server-info))
         (l wnn-environments)
@@ -410,7 +418,7 @@ Return the list of bunsetsu."
   (or (listp lang)
       (setq lang (list lang)))
   (while lang
-    (wnn-fini (car lang))
+    (wnn-fini-lang (car lang))
     (setq lang (cdr lang))))
 
 (defun wnn-dictionary-save (lang)
@@ -418,7 +426,7 @@ Return the list of bunsetsu."
   (or (listp lang)
       (setq lang (list lang)))
   (while lang
-    (wnn-fini (car lang) t)
+    (wnn-fini-lang (car lang) t)
     (setq lang (cdr lang))))
 
 (defun wnn-read-active-lang ()
@@ -1002,14 +1010,13 @@ REVERSE specifies reverse conversion, if non nil."
 ;;; setup
 
 (require 'egg)
-(load "egg/wnnrpc")
 
 ;;;###autoload
 (defun egg-activate-wnn (&rest arg)
   "Activate Wnn backend of Tamagotchy."
-  (egg-set-support-languages wnn-support-languages)
-  (egg-set-conversion-backend wnn-conversion-backend
-                             wnn-support-languages)
+  (setq egg-conversion-backend wnn-conversion-backend)
+  (if (not (fboundp 'wnnrpc-open))
+      (load-library "egg/wnnrpc"))
   (apply 'egg-mode arg))
 
 ;;; egg/wnn.el ends here.