Small refactorings

This commit is contained in:
EinfachToll 2018-04-17 07:13:37 +02:00
parent cdc37162a9
commit 3556de54e1
3 changed files with 12 additions and 12 deletions

View File

@ -77,7 +77,9 @@ function! vimwiki#base#invsubdir(subdir) " {{{
endfunction " }}}
" Returns: the number of the wiki a file belongs to
" Returns: the number of the wiki a file belongs to or -1 if it doesn't belong
" to any registered wiki.
" The path can be the full path or just the directory of the file
function! vimwiki#base#find_wiki(path) "{{{
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
for idx in range(vimwiki#vars#number_of_wikis())
@ -1881,14 +1883,12 @@ endfunction " }}}
" vimwiki#base#normalize_link_helper
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
let str = a:str
let url = matchstr(str, a:rxUrl)
let descr = matchstr(str, a:rxDesc)
let template = a:template
let url = matchstr(a:str, a:rxUrl)
let descr = matchstr(a:str, a:rxDesc)
if descr == ""
let descr = s:clean_url(url)
endif
let lnk = s:safesubstitute(template, '__LinkDescription__', descr, '')
let lnk = s:safesubstitute(a:template, '__LinkDescription__', descr, '')
let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
return lnk
endfunction " }}}
@ -1978,8 +1978,8 @@ endfunction " }}}
function! s:normalize_link_syntax_v() " {{{
let sel_save = &selection
let &selection = "old"
let rv = @"
let rt = getregtype('"')
let default_register_save = @"
let registertype_save = getregtype('"')
try
" Save selected text to register "
@ -1997,7 +1997,7 @@ function! s:normalize_link_syntax_v() " {{{
call setreg('"', sub, 'v')
normal! `>""pgvd
finally
call setreg('"', rv, rt)
call setreg('"', default_register_save, registertype_save)
let &selection = sel_save
endtry
endfunction " }}}

View File

@ -51,7 +51,7 @@ function! Complete_wikifiles(findstart, base)
return -1
else
" Completion works for wikilinks/anchors, and for tags. s:line_content
" tells us, which string came before a:base. There seems to be no easier
" tells us which string came before a:base. There seems to be no easier
" solution, because calling col('.') here returns garbage.
if s:line_context == ''
return []

View File

@ -232,8 +232,8 @@ augroup END
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#base#ui_select()
" XXX: why not using <count> instead of v:count1?
" See Issue 324.
" why not using <count> instead of v:count1?
" See https://github.com/vimwiki-backup/vimwiki/issues/324
command! -count=1 VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count=1 VimwikiTabIndex