wkoikingのブログ

内容は主にhaskellやxyzzy関連です。

xyzzy haskell-mode

windowsのhaskellユーザーが少ないこともあって、 今まで、haskellのプログラミング環境の構築には苦労して 来ました。

一時期、haskellerの中ではメインストリーム1linux + vimに乗り換えようとも思いましたが、敷居が高すぎて、 断念したヘタレです。

結局、現時点ではwindows + xyzzyに落ち着いています:

OS Windows 7
エディタ xyzzy 0.2.2 系列 + haskell mode
コンパイラ ghc

 

拡大

lispの文法すら把握できていないヘタレですが、 他人のコードのコピペで適当なhaskell modeを作ってみたので、 公開します:

ファイル名コピペ元(参考程度だったり、ほぼそのままだったり)
hs-mode.l http://www.shido.info/xyzzy/hs-mode.html
ghci.l http://d.hatena.ne.jp/bonotake/20060429/1146338542
hasktags.l https://github.com/matsuoka/ctags.l-for-xyzzy
キーワードファイル http://www.shido.info/xyzzy/hs-mode.html

インストール方法 2

  1. hs-mode.lghci.lhasktags.l\sitelispにいれて、キーワードファイル Haskell\etcにいれます。

  2. .xyzzy(もしくはsite-init.l)に以下を追加します。

(require "hasktags")
(require "hs-mode")
(require "ghci")
(push '("\\.hs$" . (lambda ()
                     (hs-mode)
                     (ghci-mode)
                     )) *auto-mode-alist*)
(push '("\\.lhs$" . (lambda ()
                      (hs-mode)
                      (ghci-mode)
                      )) *auto-mode-alist*)

使い方

hs-mode.l

キー関数名説明
TAB hs-tab-indent-toggle 適当にインデントの調整(トグル)
RET hs-newline-and-indent 改行して手前の行にインデントをあわせる

ghci.l

キー関数名説明
C-c C-i ghci-load-file カレントバッファをghciバッファにロード

hasktags.l

関数名説明
hasktags-make-tags-file tagsファイルを生成
hasktags-jump-tag タグジャンプ
hasktags-back-tag-jump バックタグジャンプ

.xyzzyに適当にキーバインドを設定しておくとよいです3

(global-set-key #\F4 'hasktags-jump-tag)
(global-set-key #\S-F4 'hasktags-back-tag-jump)
(global-set-key #\M-/ 'hasktags-make-tags-file)

色設定(おまけ)

おまけに画面例で使った私のxyzzy色設定を晒しておきます。 (個人的にはなかなかイケてると思っている。)

[Colors]
textColor=#c6c6c6
backColor=#211816
ctlColor=#8080
selectionTextColor=#f000000
selectionBackColor=#e800000
kwdColor1=#6dc79c
kwdColor2=#cd987e
kwdColor3=#219fad
stringColor=#5263d6
commentColor=#808080
tagColor=#face87
cursorColor=#800080
caretColor=#ff00
imeCaretColor=#ffff
linenum=#c6c6c6
reverse=#fcf8
unselectedModeLineFg=#13000000
unselectedModeLineBg=#10e8e8e8
modeLineFg=#d0d0d0
modeLineBg=#13000000

おわりに

現時点では、ghci.lでxyzzyからghciを操作するとき、ghciのTAB補完機能が使えません。

最新のghciでは:completeというコマンドが実装され、(emacsなどの)テキストエディタから TAB補完機能が使えるようになったらしいです。

そのうちxyzzyでもこの:completeコマンドを利用して、TAB補完を実装したいと思っています。


  1. the State of Haskell, 2011 Survey?

  2. haskell platformとhasktags がインストールされており、ghci.exeとhasktags.exeの存在するディレクトリに パスが通っていることを前提としています。?

  3. (注意)このキーバインドだとhaskell以外の言語のタグジャンプができなくなります。?