quickrun の hook-point を後から設定する

前回の続きです。
前回は予め各 point を作成して後から有効にしていましたが、今回は init 内で必要な point を作成しています。

[ソース]

let s:hook = {
\   "name" : "test2",
\   "kind" : "hook",
\   "config" : {
\       "enable" : 1,
\       "points" : ""
\   },
\}


function! s:hook.init(...)
    for point in split(self.config.points, ':')
        execute ''
\."           function! self.on_".point."(...)\n"
\."               call self.apply({ 'point' : '".point."', 'args' : a:000 })\n"
\."           endfunction\n"
    endfor
endfunction

function! s:hook.apply(context)
    echom a:context.point
endfunction


call quickrun#module#register(s:hook, 1)
unlet s:hook


" exit と finish を有効にする
QuickRun -hook/test/points exit:finish 1

んーどっちを使ってみようかな。
実装は違うけど UI 自体は競合していないので両方使えるようにするって手もあるんだけど。
今回は init で毎回関数を定義しているので処理速度が気になるんだけどどうなんだろう。