Added placeholders for tags on-page-save analysis

This commit is contained in:
Ivan Tishchenko 2015-01-03 00:59:18 +03:00
parent 7f5e517162
commit 19cc1b873a
2 changed files with 62 additions and 0 deletions

View File

@ -1928,6 +1928,61 @@ endfunction "}}}
" }}}
" TAGS functions {{{
" vimwiki#base#update_tags
" Update tags metadata.
" a:full_rebuild == 1: re-scan entire wiki
" a:full_rebuild == 0: only re-scan current page
function! vimwiki#base#update_tags(full_rebuild) "{{{
if a:full_rebuild
throw 'vimwiki#base#update_tags1: full rebuild not supported yet'
endif
"
let page_name = expand('%:t:r')
" Collect tags in current file
let tags = vimwiki#base#scan_tags(getline(1, '$'))
" Load metadata file
let metadata = vimwiki#base#load_tags_metadata()
" Drop old tags
let metadata = vimwiki#base#remove_page_from_tags(metadata, page_name)
" Merge in the new ones
let metadata = vimwiki#base#merge_tags(metadata, tags)
" Save
call vimwiki#base#write_tags_metadata(metadata)
endfunction " }}}
" vimwiki#base#scan_tags
" Scans the list (argument) and produces tags metadata dictionary.
function! vimwiki#base#scan_tags(lines) "{{{
return {}
endfunction " }}}
" vimwiki#base#load_tags_metadata
" Loads tags metadata from file, returns a dictionary
function! vimwiki#base#load_tags_metadata() "{{{
return []
endfunction " }}}
" vimwiki#base#remove_page_from_tags
" Removes all entries for given page from metadata in-place. Returns updated
" metadata (just in case).
function! vimwiki#base#remove_page_from_tags(metadata, page_name) "{{{
return []
endfunction " }}}
" vimwiki#base#merge_tags
" Merges two tags metadata objects into (new) one.
function! vimwiki#base#merge_tags(metadata1, metadata2) "{{{
return []
endfunction " }}}
" vimwiki#base#write_tags_metadata
" Saves metadata object into a file. Throws exceptions in case of problems.
function! vimwiki#base#write_tags_metadata(metadata) "{{{
endfunction " }}}
" }}}
" Command completion functions {{{
" vimwiki#base#complete_links_escaped

View File

@ -618,6 +618,13 @@ if VimwikiGet('auto_toc')
au BufWritePre <buffer> call vimwiki#base#table_of_contents(0)
augroup END
endif
if VimwikiGet('auto_tags')
" Automatically update tags metadata on page write.
augroup vimwiki
au BufWritePost <buffer> call vimwiki#base#update_tags(0)
augroup END
endif
" AUTOCOMMANDS }}}
" PASTE, CAT URL {{{