Don't open all diary files when going to next day
This is unnecessary and can be very slow when the user has many diary files. Ref #328
This commit is contained in:
parent
ca95b3fc73
commit
39745ebcd3
@ -43,7 +43,7 @@ function! s:get_position_links(link) "{{{
|
|||||||
let idx = -1
|
let idx = -1
|
||||||
let links = []
|
let links = []
|
||||||
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
||||||
let links = keys(s:get_diary_links())
|
let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
|
||||||
" include 'today' into links
|
" include 'today' into links
|
||||||
if index(links, s:diary_date_link()) == -1
|
if index(links, s:diary_date_link()) == -1
|
||||||
call add(links, s:diary_date_link())
|
call add(links, s:diary_date_link())
|
||||||
@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
|
|||||||
return result
|
return result
|
||||||
endfun "}}}
|
endfun "}}}
|
||||||
|
|
||||||
fun! s:get_diary_links() "{{{
|
fun! s:get_diary_files() "{{{
|
||||||
let rx = '^\d\{4}-\d\d-\d\d'
|
let rx = '^\d\{4}-\d\d-\d\d'
|
||||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||||
let files = split(s_files, '\n')
|
let files = split(s_files, '\n')
|
||||||
@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{
|
|||||||
" remove backup files (.wiki~)
|
" remove backup files (.wiki~)
|
||||||
call filter(files, 'v:val !~# ''.*\~$''')
|
call filter(files, 'v:val !~# ''.*\~$''')
|
||||||
|
|
||||||
let links_with_captions = s:read_captions(files)
|
return files
|
||||||
|
|
||||||
return links_with_captions
|
|
||||||
endfun "}}}
|
endfun "}}}
|
||||||
|
|
||||||
fun! s:group_links(links) "{{{
|
fun! s:group_links(links) "{{{
|
||||||
@ -129,7 +127,9 @@ endfunction "}}}
|
|||||||
function! s:format_diary() "{{{
|
function! s:format_diary() "{{{
|
||||||
let result = []
|
let result = []
|
||||||
|
|
||||||
let g_files = s:group_links(s:get_diary_links())
|
|
||||||
|
let links_with_captions = s:read_captions(s:get_diary_files())
|
||||||
|
let g_files = s:group_links(links_with_captions)
|
||||||
|
|
||||||
for year in s:sort(keys(g_files))
|
for year in s:sort(keys(g_files))
|
||||||
call add(result, '')
|
call add(result, '')
|
||||||
|
Loading…
Reference in New Issue
Block a user