Created
January 9, 2012 15:18
-
-
Save nukino/1583365 to your computer and use it in GitHub Desktop.
helpgrep修正スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func! FuncJHelpgrep(strg, type) | |
if ( &enc != "utf-8" ) | |
if ( !has('iconv') ) | |
echohl ErrorMsg | echomsg 'Not support iconv' | echohl None | |
return | |
endif | |
if ( a:type == 0 ) | |
let scmd = "helpgrep " | |
else | |
let scmd = "lhelpgrep " | |
endif | |
"検索結果をUTF-8に変換 | |
let sfind = iconv(a:strg, &enc, "utf-8") | |
exe scmd . sfind | |
if ( a:type == 0 ) | |
let flist = getqflist() | |
else | |
"ヘルプウィンドウを検索 | |
let l:bufnrlist = tabpagebuflist() | |
let nr_helpw = -1 | |
for i in bufnrlist | |
if ( getbufvar(i, "&filetype") == "help" ) | |
let nr_helpw = bufwinnr(i) | |
break | |
endif | |
endfor | |
if ( nr_helpw == -1 ) | |
echohl ErrorMsg | echomsg 'Not found Help Window' | echohl None | |
return | |
else | |
let flist = getloclist(nr_helpw) | |
endif | |
endif | |
for l in flist | |
let l.text = iconv(l.text, "utf-8", &enc) | |
endfor | |
if ( a:type == 0 ) | |
call setqflist(flist) | |
else | |
call setloclist(nr_helpw, flist) | |
endif | |
else | |
helpgrep a:strg | |
endif | |
endfunc | |
"コマンド | |
command! -nargs=1 Jhelpg call FuncJHelpgrep(<q-args>, 0) | |
command! -nargs=1 Jlhelpg call FuncJHelpgrep(<q-args>, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment