Mac OS X Lion の emacs-appでmigemoを使えるようにする

最近買ったMac miniで、cmigemoをインストールした時のメモ。


C/Migemo — KaoriYaでcmigemoの最新版をチェック。

% wget http://cmigemo.googlecode.com/files/cmigemo-default-src-20110227.zip
% unzip cmigemo-default-src-20110227.zip 
% cd cmigemo-default-src 

doc/README_j.txtを見ながら作業する。

% chmod +x configure
% ./configure
% make osx

ここで

src/wordbuf.c:118: error: ‘INT_MAX’ undeclared (first use in this function)
src/wordbuf.c:118: error: (Each undeclared identifier is reported only once
src/wordbuf.c:118: error: for each function it appears in.)
make[1]: *** [build/object/wordbuf.o] Error 1
make: *** [osx-rel] Error 2

とエラーを吐かれるので、src/wordbuf.cがlimits.hをインクルードするように書き換える。

/* vim:set ts=8 sts=4 sw=4 tw=0: */
/*
 * wordbuf.h -
 *
 * Written By:  MURAOKA Taro <koron@tka.att.ne.jp>
 * Last Change: 20-Sep-2009.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h> /* この行を追加 */
#include "wordbuf.h"

再びターミナルで

% make osx
% make osx-dict

UTF-8の辞書も作る

% cd dict
% make utf-8
% cd ..

root権限でインストール

% sudo make osx-install 

これで、cmigemoのビルド+インストールは完了。続いて、Emacsインクリメンタルサーチができるように設定。
migemo.elを https://gist.github.com/457761 からダウンロード。

% cd ~/.emacs.d/
% mkdir migemo
% cd migemo
% curl -L -o migemo.el https://raw.github.com/gist/457761/539882a79ec11bc9b6e1ac417cdafe0e198e245f/migemo.el

~/.emacs.d/init.elに設定を書く。

(setq load-path (cons "~/.emacs.d/migemo/" load-path))
(require 'migemo)
(setq migemo-command "/usr/local/bin/cmigemo")
(setq migemo-options '("-q" "--emacs"))
(setq migemo-dictionary "/usr/local/share/migemo/utf-8/migemo-dict")
(setq migemo-user-dictionary nil)
(setq migemo-coding-system 'utf-8-unix)
(setq migemo-regex-dictionary nil)
(load-library "migemo")
(migemo-init)

これで、日本語インクリメンタルサーチができるようになった。