Home About
Wnn , FreeBSD , Emacs

Wnn7egg を Emacs 28.2, 29.1 で使う

Wnn8サーバは、 Ubuntu 22.04 でも FreeBSD 13.2 のどちらでも作動します。 今回、 Wnn7egg を Emacs 28.2 (29.1 にも対応)で使えるようにするために、 FreeBSD の ports japanese wnn7egg から wnn7egg 関連のファイルを入手して このパッチ wnn7-elisp-el-1.02-1.patch.gz をあてた上でさらにエラーに対処する という手順を踏んだため、 ついでに FreeBSD 13.2 に Wnn8 サーバをインストールできるか も検証しました。(インストールできました。)

なお このパッチ wnn7-elisp-el-1.02-1.patch.gz を Wnn7egg に適用しないと

候補が 1 つも作れませんでした

という謎のエラーに(たぶん)遭遇します。

もしかすると FreeBSD を入れて ports から Wnn7egg を入手などという回り道は不要で https://github.com/kaoru6/wnn7egg から emacs20 ディレクトリごとコピーしてくるだけで済む話だったかもしれません。(未検証)

なお、ここに書いてある情報のほとんどは以下のページに載っていることなので、 その点ご了承ください。 (Wnn7,8 の貴重かつ稀少な情報源。)

FreeBSD 13.2 のインストール

see also: FreeBSD 12.2 をインストールして...

http://ftp-archive.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/13.2/ このあたりから FreeBSD-13.2-RELEASE-amd64-disc1.iso を入手。

macOS上で 次のコマンドを使って インストール用のUSBメモリを作成しました。

$ sudo dd if=FreeBSD-13.2-RELEASE-amd64-disc1.iso of=/dev/disk2 bs=16m

インストール時に ports にチェックを入れておきます。

Wnn8 サーバの FreeBSD 13.2 へのインストール

Wnn8の製品を /mnt/cdrom に存在させておきます。

その上で、インストール自体は omron から提供されているアップデート版を使います。

FreeBSD 12.1 用 の amd64 版を使いました。

事前準備として次のパッケージを入れる。

$ sudo pkg install libglade2

それから ~/.login_conf に以下を設定。

me:\
    :charset=UTF-8:\
    :lang=ja_JP.UTF-8:

検証はしていないが、インストールコマンドを ./Install ではなく ./inst.utf8 にすれば この設定しなくてもよいかもしれない。

sudo できるようにFreeBSDを設定した上で(やり方の説明は割愛)、いよいよ Wnn8 を次のコマンドでインストール。

$ sudo ./Install

しかしこれは wrong architecture: FreeBSD:12: instead of FreeBSD:13:amd64* と言われて失敗します。

具体的には次のメッセージが出ました。

Wnn8 基本辞書パッケージのインストール...pkg: wrong architecture: FreeBSD:12:* instead of FreeBSD:13:amd64 失敗
Wnn8 オプション辞書パッケージのインストール...pkg: wrong architecture: FreeBSD:12:* instead of FreeBSD:13:amd64 失敗
Wnn8 サーバパッケージのインストール...pkg: wrong architecture: FreeBSD:12:amd64 instead of FreeBSD:13:amd64 失敗
dpkey8 ライセンスサーバパッケージのインストール...pkg: wrong architecture: FreeBSD:12:amd64 instead of FreeBSD:13:amd64 失敗

ドキュメント/HTMLマニュアルのインストール...完了

dpkeyserv の起動...失敗
jserver の起動...失敗

...インストール処理終了

回避方法は、 pkg add -f の -f オプションつきでインストールさせることです。

inst.utf8 ファイルを開いて、次の部分を修正します。

PKGINST_F="pkg add"

PKGINST_F="pkg add -f"

に変更するだけです。

これで再度 sudo ./Install して質問に答えれば、インストールは成功します。

Wnn7egg を Emacs 28.2 で使えるようにする

本題の wnn7egg です。

FreeBSD 上で、wnn7egg の ports に移動して sudo make します。

cd /usr/ports/japanese/wnn7egg
sudo make

そうすると、今必要としている wnn7egg の emacs 用コードが次のディレクトリに入ります。

ここでパッチをあてます。

$ cd /usr/ports/japanese/wnn7egg/work
$ sudo fetch http://www.jpl.org/ftp/pub/elisp/wnn7-elisp-el-1.02-1.patch.gz
$ sudo gzip -d wnn7-elisp-el-1.02-1.patch.gz
$ sudo patch < wnn7-elisp-el-1.02-1.patch

説明の都合上 sudo していますが、work フォルダごと、一般ユーザーのアクセス権に変更してしまって sudo なしで作業しても構いません。

これで /usr/ports/japanese/wnn7egg/work/wnn7/elips/emacs20/ 以下に wnn7egg の el ファイルがパッチがあたった状態でできあがっています。

Emacs 28.2 から Wnn7egg を使う

Emacs 28.2 のインストール手順は省きます。(すでにインストールされていたこととする。)
see also about installing emacs 28.2

それでは作成した ./emacs20/ を使って Emacs 28.2 で日本語入力できるように Emacs の設定します。

ここでは /usr/ports/japanese/wnn7egg/work/wnn7/elips/emacs20/home/foo/.emacs.d/emacs20 に配置したとして説明していきます。

~/.emacs.d/init.el に次の設定を入れます。

;; wnn7egg
(add-to-list 'load-path "/home/foo/.emacs.d/emacs20")

(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)

(setq enable-double-n-syntax t)

;(setq wnn7-server-name "127.0.0.1")

(global-set-key "\C-\\" 'toggle-input-method)
(load "wnn7egg-leim")

(set-input-method "japanese-egg-wnn7")
(set-language-info "Japanese" 'input-method "japanese-egg-wnn7")

;;;; 候補選択モード
;(egg-use-input-predict)
;(setq egg-predict-realtime nil)
;;;; インライン候補選択モード
;;(setq egg-predict-mode "inline")
;;;; ウインドウ候補選択モード
;(setq egg-predict-mode "window")

(define-key wnn7-henkan-mode-map " " 'wnn7-henkan-select-kouho-dai)

さてこれで Emacs 28.2 を起動して使おうとしても、エラーが出て使えません。一つ一つ解消します。

なお、この解消方法は冒頭でも紹介したこのページ http://maikaze.cafe.coocan.jp/wnn8.html をみて 解決しただけです。 詳細はそちらを確認いただくことにして、ごく簡単に対処だけ説明します。
patch ファイルを用意したので、必要ならお使いください。 使い方はそれぞれ patch < wnn7egg-xxx_el.patch するだけです。
もし以前に byte-compile-file していて .elc ファイルが存在している場合は、それを消す必要があります。 (またはパッチを適用後、再度 byte-compile-file する。)

make-coding-system

Symbol's function definition is void: make-coding-system

対処方法: wnn7egg-com.el を修正 wnn7egg-com_el.patch

--- wnn7egg-com.el	2023-12-15 14:27:58.086080292 +0900
+++ wnn7egg-com.el.mod	2023-12-15 14:27:21.255080291 +0900
@@ -170,8 +170,9 @@
       (write-read-repeat r0))))))
 
 (if (not (coding-system-p 'egg-binary))
-    (make-coding-system 'egg-binary 4 ?W "Coding System for binary data"
-		    (cons ccl-decode-egg-binary ccl-encode-egg-binary)))
+	(define-coding-system 'egg-binary "Coding System for binary data"
+     :mnemonic ?W :coding-type 'ccl :ccl-decoder ccl-decode-egg-binary
+     :ccl-encoder ccl-encode-egg-binary))
 
 
 (defun comm-format-u32c (uint32c)

process-kill-without-query

Symbol’s function definition is void: process-kill-without-query

対処方法: wnn7egg-lib.el を修正 wnn7egg-lib_el.patch

--- wnn7egg-lib.el	2002-05-27 00:00:00.000000000 +0900
+++ wnn7egg-lib.el.mod	2023-12-15 14:34:29.765080315 +0900
@@ -714,7 +714,7 @@
 						wnn7-active-server-port))
 	      ((error quit))))
 	  (when proc
-	    (process-kill-without-query proc)
+        (set-process-query-on-exit-flag proc nil)
 	    (if (featurep 'xemacs)
 		(set-process-coding-system proc 'binary 'binary)
 	      (set-process-coding-system proc 'no-conversion 'no-conversion))

backend timeout

対処方法: wnn7egg-rpc.el を修正 wnn7egg-rpc_el.patch

--- wnn7egg-rpc.el	2023-12-15 03:00:10.000000000 +0900
+++ wnn7egg-rpc.el.mod	2023-12-15 14:38:45.009080331 +0900
@@ -457,6 +457,7 @@
 (defmacro wnn7rpc-get-result (&rest body)
   `(let (result)
      (comm-unpack (u) result)
+     (if (= result 4294967295) (setq result -1))
      (if (< result 0)
        (progn
 	 (comm-unpack (u) result)
@@ -538,6 +539,7 @@
 		 env-id type)
     (wnn7rpc-get-result
       (comm-unpack (u) result)
+      (if (= result 4294967295) (setq result -1))
       (1+ result))))
 
 (defun wnn7rpc-set-autolearning-dic (env type dic-id)

以上の修正で Emacs 28.2 で Wnn7egg を Wnn8 サーバと組み合わせて使用することできるようになりました。

Emacs 29.1 への対処

macOS (Ventura 13.6.1) で brew install emacs したところ 29.1 が入った。

$ emacs -version
GNU Emacs 29.1

新たに set-face-underlin-p , cl などの問題が出てしまった。

set-face-underline-p

対処方法: wnn7egg-cnv.el を修正 wnn7egg-cnv_el.patch

--- wnn7egg-cnv.el	2023-12-15 03:00:10
+++ wnn7egg-cnv.el.mod	2023-12-17 17:33:25
@@ -1931,7 +1931,7 @@
 (if (not egg-ud-face)
     (progn
       (setq egg-ud-face (make-face 'egg-ud-face))
-      (set-face-underline-p egg-ud-face t)))
+      (set-face-underline egg-ud-face t)))
 
 (defun egg-predict-mode-in-inline ()
   (interactive)

Package cl is deprecated

対処方法: wnn7egg.el を修正 wnn7egg_el.patch

--- wnn7egg.el	2023-12-15 03:00:10
+++ wnn7egg.el.mod	2023-12-17 17:29:30
@@ -1298,7 +1298,7 @@
 			(for-each* (cdr vars) body)
 			(list 'setq tvar (list 'cdr tvar))))))))
 			     
-(eval-when-compile (require 'cl)) ;; dolist
+(eval-when-compile (require 'cl-lib)) ;; dolist
 ;;;(put 'dolist 'lisp-indent-hook 1)
 ;;;
 ;;;(defmacro dolist (pair &rest body)

Symbol’s function definition is void: nil

日本語入力切り替えのために ctrl + \ を2度使うと表示されるエラー。 気にせず再度 ctrl + \ を連打すれば切り替えは可能だが、とても不便。

対処方法: wnn7egg-leim.el を修正 wnn7egg-leim_el.patch

--- wnn7egg-leim.el	2023-12-17 18:12:58
+++ wnn7egg-leim.el.mod	2023-12-17 18:14:08
@@ -48,13 +48,13 @@
 (defun wnn7egg-activate (&optional name)
   (require 'wnn7egg)
   (require 'wnn7egg-cnv)
-  (setq inactivate-current-input-method-function 'wnn7egg-inactivate)
+  (setq deactivate-current-input-method-function 'wnn7egg-deactivate)
   (setq wnn7egg-default-startup-file "eggrc-wnn7")
   (wnn7-egg-mode)
   (setq wnn7-activate t);;;;
   (toggle-egg-mode))
 
-(defun wnn7egg-inactivate ()
+(defun wnn7egg-deactivate ()
   (setq wnn7-activate nil);;;;
   (cond (egg:*mode-on* (toggle-egg-mode))))

inactivate-current-input-method-function という関数名が deactivate-current-input-method-function に変更になったということでしょうか。

次のように修正すれば、 defun wnn7egg-inactivate の関数名を直す必要はないと思いますが・・・

(setq deactivate-current-input-method-function 'wnn7egg-inactivate)

関数名を deactivate に揃えた方がよいという判断なのでしょう。

byte-compile-file

必要なら M-x byte-compile-file wnn7egg.el などして、 ~/.emacs.d/emacs20/*.el ファイルを全部バイトコンパイルするとよいかもしれません。

追伸 eggrc-wnn7 ファイルの入れ替え

Wnn6/Wnn7 対応のクライアントを Wnn8 で使用する方法は? https://socialsolution.omron.com/software/products/product_text/wnn8/faq/03clients.html#faq3-1

の件で、eggrc-wnn7 ファイルを入れ替えるか ~/.eggrc-wnn7 に配置するか、する話・・・ですが、 とりあえずは、この処置をしなくても Wnn8 サーバ + Wnn7egg で作動はしています。辞書関連のなにかをすることで必要になってくるのかもしれません。 または ターミナル上で Emacs + Wnn7egg を使うユーザーには関係ない話なのであろうか?

まとめ

Wnn9 でないかな。

Liked some of this entry? Buy me a coffee, please.