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 " }}} 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) "{{{ function! vimwiki#base#find_wiki(path) "{{{
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path)) let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
for idx in range(vimwiki#vars#number_of_wikis()) for idx in range(vimwiki#vars#number_of_wikis())
@ -1881,14 +1883,12 @@ endfunction " }}}
" vimwiki#base#normalize_link_helper " vimwiki#base#normalize_link_helper
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
let str = a:str let url = matchstr(a:str, a:rxUrl)
let url = matchstr(str, a:rxUrl) let descr = matchstr(a:str, a:rxDesc)
let descr = matchstr(str, a:rxDesc)
let template = a:template
if descr == "" if descr == ""
let descr = s:clean_url(url) let descr = s:clean_url(url)
endif endif
let lnk = s:safesubstitute(template, '__LinkDescription__', descr, '') let lnk = s:safesubstitute(a:template, '__LinkDescription__', descr, '')
let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '') let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
return lnk return lnk
endfunction " }}} endfunction " }}}
@ -1978,8 +1978,8 @@ endfunction " }}}
function! s:normalize_link_syntax_v() " {{{ function! s:normalize_link_syntax_v() " {{{
let sel_save = &selection let sel_save = &selection
let &selection = "old" let &selection = "old"
let rv = @" let default_register_save = @"
let rt = getregtype('"') let registertype_save = getregtype('"')
try try
" Save selected text to register " " Save selected text to register "
@ -1997,7 +1997,7 @@ function! s:normalize_link_syntax_v() " {{{
call setreg('"', sub, 'v') call setreg('"', sub, 'v')
normal! `>""pgvd normal! `>""pgvd
finally finally
call setreg('"', rv, rt) call setreg('"', default_register_save, registertype_save)
let &selection = sel_save let &selection = sel_save
endtry endtry
endfunction " }}} endfunction " }}}

View File

@ -51,7 +51,7 @@ function! Complete_wikifiles(findstart, base)
return -1 return -1
else else
" Completion works for wikilinks/anchors, and for tags. s:line_content " 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. " solution, because calling col('.') here returns garbage.
if s:line_context == '' if s:line_context == ''
return [] return []

View File

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