MzScheme+Vim 7.1をFedora 8にインストール
ふふ。案外大変だった。
Fedora8に用意されているMzScheme(plt)パッケージはGCの関係で使えないので、MzScheme本家から372のソースを貰ってくる。
http://download.plt-scheme.org/mzscheme/
おし。
展開して、/usr/local/pltにインストールしていく。
% ./configure --prefix=/usr/local/plt --enable-cgcdefault % make % sudo make install
デフォルトでは3mというGCになってしまうので、CGCを使う。3mを使う場合はVim側のMakefileをいじる必要がありそう。違いはここら辺。後で読むかも。
MzScheme + Vim 7.1を目指す。CVSから貰ってきて、make。
% ./configure --prefix=/usr/local --enable-mzschemeinterp --with-plthome=/usr/local/plt % make
うんうん。
とりあえず動かしてみる。
% src/vim :version VIM - Vi IMproved 7.1 (2007 May 12, compiled Mar 31 2008 10:07:17) Included patches: 1-285 Compiled by tanaka@black.home Normal version without GUI. Features included (+) or not (-): (略) +mzscheme (略) :mz (+ 1 1) 2
おk。MzSchemeはGCによってライブラリの種類が違うということに気づくのに時間がかかった。
もうちょっとコンパイルオプションを増やしてっと。
% ./configure --prefix=/usr/local --with-features=huge \ --enable-multibyte --enable-cscope \ --enable-perlinterp --enable-rubyinterp --enable-pythoninterp --enable-tclinterp \ --enable-mzschemeinterp --with-plthome=/usr/local/plt
後はmake installするだけ。
以下メモ。
- GTK回りで依存関係エラーが出る場合は、pkg-configを見るといい。
- 日本語入力がおかしくなってたので、.Xdefaultsに、inputMethodを追加したら直った。
*inputMethod: scim
前のスクリプトを~/.vim/after/ftplugin/scheme.vimに移行しといてっと。
vmap <buffer> <C-CR> :call <SID>EvalVisual()<CR> nmap <buffer> <C-CR> :call <SID>EvalNormal()<CR> nmap <silent> <buffer> <A-i> :exe "normal A ; " . <SID>Readirect(function("<SID>EvalNormal"))<CR> vmap <silent> <buffer> <A-i> :exe "normal A ; " . <SID>Readirect(function("<SID>EvalVisual"))<CR> function! s:Readirect(Fn) let tmp = "" redir => tmp silent call a:Fn() redir END return substitute(tmp, '\n', '', '') endfunc function! s:EvalNormal() let line = line('.') let col = col('.') silent normal % let saved_reg = @" silent normal y% execute 'mzscheme ' . @" let @" = saved_reg call cursor(line, col) endfunction function! s:EvalVisual() range let saved_reg = @" silent normal `<v`>y execute 'mzscheme ' . @" let @" = saved_reg endfunction if has("mzscheme") :mz << EOF (current-library-collection-paths (map (lambda (p) (if (bytes? p) (bytes->path p) p)) (current-library-collection-paths))) (current-directory (bytes->string/utf-8 (vim-eval "expand(\"%:p:h\")"))) (require (prefix vim- vimext)) (require (lib "trace.ss")) (require (lib "process.ss")) (require (lib "1.ss" "srfi")) (define (square x) (* x x)) EOF endif setl lispwords=define,lambda,let,let*,letrec "setl lispwords+=and,or,if,cond,case setl lispwords+=begin,do,delay,set!,else,=> setl lispwords+=quote,quasiquote,unquote,unquote-splicing setl lispwords+=define-syntax,let-syntax,letrec-syntax,syntax-rules setl lispwords+=module,define-macro map <buffer> <silent> <F5> :call <SID>MakeEasy()<CR> function! s:MakeEasy() w % if filereadable("./Makefile") make elseif strpart(getline(1), 0, 2) == "#!" !./% else !mred -vmf % endif endfunction
スクリプトの概要は、
- C-CRで括弧内を実行する。C-CRは
eに直すかも。 - M-iで実行結果をコメントとして挿入する。
- ライブラリの設定。current-library-collection-pathsらへんはかなり重要。
- lispwords色々。
- F5で全体を実行する。
っと。