itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 72 forks source link

Automatic refresh of calendar #81

Closed petobens closed 9 years ago

petobens commented 9 years ago

Hi @itchyny . I was wondering if you could add the possiblity of automatically refreshing the calendar each time the app starts? I currently use the following (that seems to work):

function! s:RefreshCal()
    let timestamp_dir = g:calendar_cache_directory . '/timestamp'
    let file_list = globpath(timestamp_dir,'*', 0, 1)
    if empty(timestamp_dir)
        return
    endif
    " Delete Google calendar cache if not empty
    for item in file_list
        if exists(':VimProcBang') && s:is_win
            call vimproc#delete_trash(item)
        else
            execute delete(item)
        endif
    endfor
endfunction
nnoremap <silent> <Leader>ca :call <SID>RefreshCal()<CR>:Calendar -task
            \ -split=horizontal -position=below<CR>:wincmd J<bar>50 wincmd _<CR>

If you don't want to add something similar to this, just close the issue. Thank you in advance!

itchyny commented 9 years ago

If the app refreshes the calendars on its every startup, it will download the calendars again and again; I felt too annoyed that this process causes slowness on Vim. Sometimes I want to check the events quickly (and soon close the buffer) and the calendars are not updated that frequently. The app does automatically refresh the calendars if the last update is before 3 hours ago. The files under the timestamp directory are used for this feature (you may understand, I guess). I assume that users would not use both website interface and this app at the same time; if they liked this app, they would not update the event in the website, and that they would not switch that frequently between this app and their mobile devices.

petobens commented 9 years ago

Fair enough. Thanks for a great app!