Small refactoring

This commit is contained in:
Marco Hinz 2014-03-31 18:40:37 +02:00
parent 19870ae159
commit ac67377d52

View file

@ -359,7 +359,6 @@ endfunction
" Function: s:show_sessions {{{1 " Function: s:show_sessions {{{1
function! s:show_sessions(cnt) abort function! s:show_sessions(cnt) abort
let sfiles = split(globpath(s:session_dir, '*'), '\n') let sfiles = split(globpath(s:session_dir, '*'), '\n')
let slen = len(sfiles)
if empty(sfiles) if empty(sfiles)
if exists('s:last_message') if exists('s:last_message')
@ -367,34 +366,37 @@ function! s:show_sessions(cnt) abort
endif endif
return a:cnt return a:cnt
endif endif
let cnt = a:cnt
if exists('s:last_message') if exists('s:last_message')
call s:print_section_header() call s:print_section_header()
endif endif
let cnt = a:cnt
let slen = len(sfiles)
for i in range(slen) for i in range(slen)
let idx = (i + cnt) let index = s:get_index_as_string(cnt)
let index = s:get_index_as_string(idx)
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fnamemodify(sfiles[i], ':t:r')) call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fnamemodify(sfiles[i], ':t:r'))
execute 'nnoremap <buffer>' index ':source' fnameescape(sfiles[i]) '<cr>' execute 'nnoremap <buffer>' index ':source' fnameescape(sfiles[i]) '<cr>'
let cnt += 1
endfor endfor
call append('$', '') call append('$', '')
return idx + 1 return cnt
endfunction endfunction
" Function: s:show_bookmarks {{{1 " Function: s:show_bookmarks {{{1
function! s:show_bookmarks(cnt) abort function! s:show_bookmarks(cnt) abort
let cnt = a:cnt
if exists('g:startify_bookmarks') if exists('g:startify_bookmarks')
if exists('s:last_message') if exists('s:last_message')
call s:print_section_header() call s:print_section_header()
endif endif
let cnt = a:cnt
for fname in g:startify_bookmarks for fname in g:startify_bookmarks
let index = s:get_index_as_string(cnt) let index = s:get_index_as_string(cnt)