:VimwikiMakeDiaryNote makes a new note in the current wiki
... like the doc says, instead of always using the first wiki. Also, fix the menu entry, which always led to the wrong diary. Fix #482
This commit is contained in:
parent
c08a9f8c71
commit
057fa39303
@ -170,21 +170,25 @@ function! s:format_diary()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" The given wiki number a:wnum is 1 for the first wiki, 2 for the second and so on. This is in
|
||||||
|
" contrast to most other places, where counting starts with 0. When a:wnum is 0, the current wiki
|
||||||
|
" is used.
|
||||||
function! vimwiki#diary#make_note(wnum, ...)
|
function! vimwiki#diary#make_note(wnum, ...)
|
||||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
if a:wnum == 0
|
||||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
|
else
|
||||||
|
let wiki_nr = a:wnum - 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if wiki_nr >= vimwiki#vars#number_of_wikis()
|
||||||
|
echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" TODO: refactor it. base#goto_index uses the same
|
" TODO: refactor it. base#goto_index uses the same
|
||||||
if a:wnum > 0
|
|
||||||
let idx = a:wnum - 1
|
|
||||||
else
|
|
||||||
let idx = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', idx).
|
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr).
|
||||||
\ vimwiki#vars#get_wikilocal('diary_rel_path', idx))
|
\ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr))
|
||||||
|
|
||||||
let cmd = 'edit'
|
let cmd = 'edit'
|
||||||
if a:0
|
if a:0
|
||||||
@ -202,7 +206,7 @@ function! vimwiki#diary#make_note(wnum, ...)
|
|||||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
|
call vimwiki#base#open_link(cmd, link, s:diary_index(wiki_nr))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@ -297,8 +301,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" XXX: Well, +1 is for inconsistent index basing...
|
call vimwiki#diary#make_note(0, 0, link)
|
||||||
call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,14 +266,14 @@ command! -count=1 VimwikiTabIndex
|
|||||||
command! -count=1 VimwikiDiaryIndex
|
command! -count=1 VimwikiDiaryIndex
|
||||||
\ call vimwiki#diary#goto_diary_index(v:count1)
|
\ call vimwiki#diary#goto_diary_index(v:count1)
|
||||||
command! -count=1 VimwikiMakeDiaryNote
|
command! -count=1 VimwikiMakeDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1)
|
\ call vimwiki#diary#make_note(v:count)
|
||||||
command! -count=1 VimwikiTabMakeDiaryNote
|
command! -count=1 VimwikiTabMakeDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 1)
|
\ call vimwiki#diary#make_note(v:count, 1)
|
||||||
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 0,
|
\ call vimwiki#diary#make_note(v:count, 0,
|
||||||
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
||||||
command! -count=1 VimwikiMakeTomorrowDiaryNote
|
command! -count=1 VimwikiMakeTomorrowDiaryNote
|
||||||
\ call vimwiki#diary#make_note(v:count1, 0,
|
\ call vimwiki#diary#make_note(v:count, 0,
|
||||||
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
|
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
|
||||||
|
|
||||||
command! VimwikiDiaryGenerateLinks
|
command! VimwikiDiaryGenerateLinks
|
||||||
@ -341,7 +341,7 @@ function! s:build_menu(topmenu)
|
|||||||
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
||||||
\ ' :call vimwiki#base#goto_index('.idx.')<CR>'
|
\ ' :call vimwiki#base#goto_index('.idx.')<CR>'
|
||||||
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
||||||
\ ' :call vimwiki#diary#make_note('.idx.')<CR>'
|
\ ' :call vimwiki#diary#make_note('.(idx+1).')<CR>'
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user