From 37ef87b930f132e430026e611b30e3bf49540568 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 14 Dec 2014 14:49:06 +0100 Subject: [PATCH] Suppress an annoying error message when it's not the right time --- autoload/vimwiki/base.vim | 11 ++++++----- autoload/vimwiki/html.vim | 4 ++-- ftplugin/vimwiki.vim | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index e89f5ea..5adc1b7 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -241,10 +241,10 @@ function! vimwiki#base#invsubdir(subdir) " {{{ endfunction " }}} " vimwiki#base#resolve_scheme -function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme +function! vimwiki#base#resolve_scheme(lnk, as_html, ...) " {{{ Resolve scheme + let quiet = a:0 && a:1 ? 1 : 0 let lnk = a:lnk - " if link is schemeless add wikiN: scheme let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl let lnk = (is_schemeless ? 'wiki'.g:vimwiki_current_idx.':'.lnk : lnk) @@ -280,7 +280,9 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme if scheme =~ 'wiki\d\+' let idx = eval(matchstr(scheme, '\D\+\zs\d\+\ze')) if idx < 0 || idx >= len(g:vimwiki_list) - echom 'Vimwiki Error: Numbered scheme refers to a non-existent wiki!' + if !quiet + echom 'Vimwiki Error: Numbered scheme refers to a non-existent wiki!' + endif return [idx,'','','','','','', ''] endif @@ -532,7 +534,6 @@ function! vimwiki#base#backlinks() "{{{ for source_file in wikifiles let links = s:get_links(source_file, idx) for [target_file, _, lnum, col] in links - " echom source_file target_file " don't include links from the current file to itself if target_file == current_filename && target_file != source_file call add(locations, {'filename':source_file, 'lnum':lnum, 'col':col}) @@ -697,7 +698,7 @@ endfunction "}}} " belongs to the given wiki nr function! s:link_target(source_file, wiki_nr, link_text) "{{{ let [target_idx, scheme, path, subdir, lnk, ext, url, anchor] = - \ vimwiki#base#resolve_scheme(a:link_text, 0) + \ vimwiki#base#resolve_scheme(a:link_text, 0, 1) let source_dir = fnamemodify(a:source_file, ':p:h').'/' if lnk =~ '/$' " link to a directory diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 95861ee..c33d79c 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -375,7 +375,7 @@ function! s:tag_wikiincl(value) "{{{ let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2)) " resolve url let [idx, scheme, path, subdir, lnk, ext, url, anchor] = - \ vimwiki#base#resolve_scheme(url_0, 1) + \ vimwiki#base#resolve_scheme(url_0, 1, 1) " generate html output " TODO: migrate non-essential debugging messages into g:VimwikiLog if g:vimwiki_debug > 1 @@ -409,7 +409,7 @@ function! s:tag_wikilink(value) "{{{ " resolve url let [idx, scheme, path, subdir, lnk, ext, url, anchor] = - \ vimwiki#base#resolve_scheme(url, 1) + \ vimwiki#base#resolve_scheme(url, 1, 1) " generate html output " TODO: migrate non-essential debugging messages into g:VimwikiLog diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index f13a08e..8490984 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -85,7 +85,7 @@ function! Complete_wikifiles(findstart, base) let segments = split(a:base, '#', 1) let given_wikifile = segments[0]=='' ? expand('%:t:r') : segments[0] - let link_infos = vimwiki#base#resolve_scheme(given_wikifile.'#', 0) + let link_infos = vimwiki#base#resolve_scheme(given_wikifile.'#', 0, 1) let wikifile = link_infos[6] let syntax = VimwikiGet('syntax', link_infos[0]) let anchors = vimwiki#base#get_anchors(wikifile, syntax)