Refactor: Mutualize messaging (echo)

This commit is contained in:
Tinmarino 2020-08-09 16:06:35 -04:00
parent 188ead55db
commit 4b041a606a
8 changed files with 125 additions and 92 deletions

View File

@ -328,7 +328,7 @@ function! vimwiki#base#system_open_link(url) abort
return return
endif endif
endtry endtry
echomsg 'Vimwiki Error: Default Vimwiki link handler was unable to open the HTML file!' call vimwiki#u#error('Default Vimwiki link handler was unable to open the HTML file!')
endfunction endfunction
@ -343,12 +343,12 @@ function! vimwiki#base#open_link(cmd, link, ...) abort
if link_infos.filename ==? '' if link_infos.filename ==? ''
if link_infos.index == -1 if link_infos.index == -1
echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.' call vimwiki#u#error('No registered wiki ''' . link_infos.scheme . '''.')
elseif link_infos.index == -2 elseif link_infos.index == -2
" scheme field stores wiki name for this error case " scheme field stores wiki name for this error case
echom 'Vimwiki Error: No wiki found with name "' . link_infos.scheme . '"' call vimwiki#u#error('No wiki found with name "' . link_infos.scheme . '"')
else else
echomsg 'Vimwiki Error: Unable to resolve link!' call vimwiki#u#error('Unable to resolve link!')
endif endif
return return
endif endif
@ -509,7 +509,7 @@ function! vimwiki#base#backlinks() abort
endfor endfor
if empty(locations) if empty(locations)
echomsg 'Vimwiki: No other file links to this file' call vimwiki#u#echo('No other file links to this file')
else else
call setloclist(0, locations, 'r') call setloclist(0, locations, 'r')
lopen lopen
@ -967,7 +967,7 @@ function! vimwiki#base#check_links(range, line1, line2) abort
else else
let wiki_list = range(a:line1, a:line2) let wiki_list = range(a:line1, a:line2)
endif endif
echom 'Vimwiki Checking links in wikis ' . string(wiki_list) call vimwiki#u#echo('Checking links in wikis ' . string(wiki_list))
let anchors_of_files = {} let anchors_of_files = {}
let links_of_files = {} let links_of_files = {}
@ -1063,7 +1063,7 @@ function! vimwiki#base#check_links(range, line1, line2) abort
" Fill: QuickFix list " Fill: QuickFix list
if empty(errors) if empty(errors)
echomsg 'Vimwiki: All links are OK' call vimwiki#u#echo('All links are OK')
else else
call setqflist(errors, 'r') call setqflist(errors, 'r')
copen copen
@ -1084,8 +1084,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
let ok = vimwiki#path#mkdir(dir, 1) let ok = vimwiki#path#mkdir(dir, 1)
if !ok if !ok
echomsg ' ' call vimwiki#u#error('Unable to edit file in non-existent directory: '.dir)
echomsg 'Vimwiki Error: Unable to edit file in non-existent directory: '.dir
return return
endif endif
@ -1097,11 +1096,11 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
try try
execute a:command fname execute a:command fname
catch /E37:/ catch /E37:/
echomsg 'Vimwiki: Can''t leave the current buffer, because it is modified. Hint: Take a look at' call vimwiki#u#warn('Can''t leave the current buffer, because it is modified. Hint: Take a look at'
\ ''':h g:vimwiki_autowriteall'' to see how to save automatically.' \ . ''':h g:vimwiki_autowriteall'' to see how to save automatically.')
return return
catch /E325:/ catch /E325:/
echom 'Vimwiki: Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.' call vimwiki#u#warn('Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.')
return return
endtry endtry
" If the opened file was not already loaded by Vim, an autocommand is " If the opened file was not already loaded by Vim, an autocommand is
@ -1129,7 +1128,7 @@ endfunction
function! vimwiki#base#search_word(wikiRX, flags) abort function! vimwiki#base#search_word(wikiRX, flags) abort
let match_line = search(a:wikiRX, 's'.a:flags) let match_line = search(a:wikiRX, 's'.a:flags)
if match_line == 0 if match_line == 0
echomsg 'Vimwiki: Wiki link not found' call vimwiki#u#echo('Wiki link not found')
endif endif
endfunction endfunction
@ -1228,7 +1227,7 @@ endfunction
" Param: old: url regex of old path relative to wiki root " Param: old: url regex of old path relative to wiki root
" Param: new: url string of new path " Param: new: url string of new path
function! s:update_wiki_link(fname, old, new) abort function! s:update_wiki_link(fname, old, new) abort
echo 'Updating links in '.a:fname call vimwiki#u#echo('Updating links in '.a:fname)
let has_updates = 0 let has_updates = 0
let dest = [] let dest = []
for line in readfile(a:fname) for line in readfile(a:fname)
@ -1701,7 +1700,7 @@ function! vimwiki#base#goto_index(wnum, ...) abort
endif endif
if a:wnum > vimwiki#vars#number_of_wikis() if a:wnum > vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!' call vimwiki#u#error('Wiki '.a:wnum.' is not registered in your Vimwiki settings!')
return return
endif endif
@ -1736,14 +1735,14 @@ function! vimwiki#base#delete_link() abort
try try
call delete(fname) call delete(fname)
catch /.*/ catch /.*/
echomsg 'Vimwiki Error: Cannot delete "'.expand('%:t:r').'"!' call vimwiki#u#error('Cannot delete "'.expand('%:t:r').'"!')
return return
endtry endtry
call vimwiki#base#go_back_link() call vimwiki#base#go_back_link()
execute 'bdelete! '.escape(fname, ' ') execute 'bdelete! '.escape(fname, ' ')
" reread buffer => deleted wiki link should appear as non-existent " Reread buffer => deleted wiki link should appear as non-existent
if expand('%:p') !=? '' if expand('%:p') !=? ''
execute 'e' execute 'e'
endif endif
@ -1765,11 +1764,11 @@ function! s:input_rename_link() abort
" Guard: Check link " Guard: Check link
if new_link =~# '[/\\]' if new_link =~# '[/\\]'
echomsg 'Vimwiki Error: Cannot rename to a filename with path!' call vimwiki#u#error('Cannot rename to a filename with path!')
return return
endif endif
if substitute(new_link, '\s', '', 'g') ==? '' if substitute(new_link, '\s', '', 'g') ==? ''
echomsg 'Vimwiki Error: Cannot rename to an empty filename!' call vimwiki#u#error('Cannot rename to an empty filename!')
return return
endif endif
@ -1796,8 +1795,8 @@ function! vimwiki#base#rename_link(...) abort
" Clause: Check if there current buffer is a file (new buffer maybe) " Clause: Check if there current buffer is a file (new buffer maybe)
if glob(expand('%:p')) ==? '' if glob(expand('%:p')) ==? ''
echomsg 'Vimwiki Error: Cannot rename "'.expand('%:p'). call vimwiki#u#error('Cannot rename "'.expand('%:p')
\'". Current file does not exist! (New file? Save it before renaming.)' \ . '". Current file does not exist! (New file? Save it before renaming.)')
return return
endif endif
@ -1812,7 +1811,7 @@ function! vimwiki#base#rename_link(...) abort
" Guard: Do not rename if file with such name exists " Guard: Do not rename if file with such name exists
let fname = glob(new_fname) let fname = glob(new_fname)
if fname !=? '' if fname !=? ''
echomsg 'Vimwiki Error: Cannot rename to "'.new_fname.'". File with that name exist!' call vimwiki#u#error('Cannot rename to "'.new_fname.'". File with that name exist!')
return return
endif endif
@ -1828,13 +1827,13 @@ function! vimwiki#base#rename_link(...) abort
" Rename wiki link file " Rename wiki link file
try try
echomsg 'Vimwiki: Renaming '.wikiroot_path.old_fname.' to '.new_fname call vimwiki#u#echo('Renaming '.wikiroot_path.old_fname.' to '.new_fname)
let res = rename(expand('%:p'), expand(new_fname)) let res = rename(expand('%:p'), expand(new_fname))
if res != 0 if res != 0
throw 'Cannot rename!' throw 'Cannot rename!'
end end
catch /.*/ catch /.*/
echomsg 'Vimwiki Error: Cannot rename "'.expand('%:t:r').'" to "'.new_fname.'"' call vimwiki#u#error('Cannot rename "'.expand('%:t:r').'" to "'.new_fname.'"')
return return
endtry endtry
@ -1894,12 +1893,12 @@ function! vimwiki#base#rename_link(...) abort
exe 'bwipeout! ' . buf_old_info[2] exe 'bwipeout! ' . buf_old_info[2]
else else
" Should not happen " Should not happen
echomsg 'Vimwiki Error: New buffer is the same as old, so will not delete: ' call vimwiki#u#error('New buffer is the same as old, so will not delete: '
\ . buf_new_nb . '.Please open an issue if see this messsage' \ . buf_new_nb . '.Please open an issue if see this messsage')
endif endif
" Log success " Log success
echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname call vimwiki#u#echo(old_fname.' is renamed to '.new_fname)
" Restore prompt " Restore prompt
let &more = more_save let &more = more_save
@ -2354,7 +2353,7 @@ function! vimwiki#base#goto_parent_header() abort
if parent_header >= 0 if parent_header >= 0
call cursor(headers[parent_header][0], 1) call cursor(headers[parent_header][0], 1)
else else
echo 'Vimwiki: no parent header found' call vimwiki#u#echo('no parent header found')
endif endif
endfunction endfunction
@ -2368,7 +2367,7 @@ function! vimwiki#base#goto_next_header() abort
elseif current_header_index < 0 && !empty(headers) " we're above the first header elseif current_header_index < 0 && !empty(headers) " we're above the first header
call cursor(headers[0][0], 1) call cursor(headers[0][0], 1)
else else
echo 'Vimwiki: no next header found' call vimwiki#u#echo('no next header found')
endif endif
endfunction endfunction
@ -2384,7 +2383,7 @@ function! vimwiki#base#goto_prev_header() abort
if current_header_index >= 0 if current_header_index >= 0
call cursor(headers[current_header_index][0], 1) call cursor(headers[current_header_index][0], 1)
else else
echo 'Vimwiki: no previous header found' call vimwiki#u#echo('no previous header found')
endif endif
endfunction endfunction
@ -2399,7 +2398,7 @@ function! vimwiki#base#goto_sibling(direction) abort
\ headers[current_header_index][1] \ headers[current_header_index][1]
call cursor(headers[next_potential_sibling][0], 1) call cursor(headers[next_potential_sibling][0], 1)
else else
echo 'Vimwiki: no sibling header found' call vimwiki#u#echo('no sibling header found')
endif endif
endfunction endfunction
@ -2804,7 +2803,7 @@ endfunction
" Called by commands VimwikiSearch and VWS " Called by commands VimwikiSearch and VWS
function! vimwiki#base#search(search_pattern) abort function! vimwiki#base#search(search_pattern) abort
if empty(a:search_pattern) if empty(a:search_pattern)
echomsg 'Vimwiki Error: No search pattern given.' call vimwiki#u#error('No search pattern given.')
return return
endif endif
@ -2825,18 +2824,11 @@ function! vimwiki#base#search(search_pattern) abort
try try
execute cmd execute cmd
catch catch
echomsg 'VimwikiSearch: No match found.' call vimwiki#u#echo('Search: No match found.')
endtry endtry
endfunction endfunction
" Warn deprecated feature
function! vimwiki#base#deprecate(old, new) abort
echohl WarningMsg
echo a:old 'is deprecated and will be removed in future versions, use' a:new 'instead.'
echohl None
endfunction
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality " Load syntax-specific Wiki functionality
for s:syn in s:vimwiki_get_known_syntaxes() for s:syn in s:vimwiki_get_known_syntaxes()

View File

@ -281,7 +281,7 @@ function! vimwiki#diary#make_note(wnum, ...) abort
endif endif
if wiki_nr >= vimwiki#vars#number_of_wikis() if wiki_nr >= vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!' call vimwiki#u#error('Wiki '.wiki_nr.' is not registered in g:vimwiki_list!')
return return
endif endif
@ -321,7 +321,7 @@ function! vimwiki#diary#goto_diary_index(wnum) abort
endif endif
if a:wnum > vimwiki#vars#number_of_wikis() if a:wnum > vimwiki#vars#number_of_wikis()
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!' call vimwiki#u#error('Wiki '.a:wnum.' is not registered in g:vimwiki_list!')
return return
endif endif
@ -471,7 +471,7 @@ function! vimwiki#diary#generate_diary_section() abort
\ 1, \ 1,
\ 1) \ 1)
else else
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!' call vimwiki#u#error('You can generate diary links only in a diary index page!')
endif endif
endfunction endfunction

View File

@ -145,7 +145,7 @@ function! s:get_html_template(template) abort
let lines = readfile(template_name) let lines = readfile(template_name)
return lines return lines
catch /E484/ catch /E484/
echomsg 'Vimwiki: HTML template '.template_name. ' does not exist!' call vimwiki#u#echo('HTML template '.template_name. ' does not exist!')
endtry endtry
endif endif
@ -203,7 +203,7 @@ function! s:delete_html_files(path) abort
try try
call delete(fname) call delete(fname)
catch catch
echomsg 'Vimwiki Error: Cannot delete '.fname call vimwiki#u#error('Cannot delete '.fname)
endtry endtry
endfor endfor
endfunction endfunction
@ -1640,9 +1640,9 @@ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) abort
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '. \ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ? \ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-')) \ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
" Echo if non void " Print if non void
if output !~? '^\s*$' if output !~? '^\s*$'
echomsg output call vimwiki#u#echo(string(output))
endif endif
endfunction endfunction
@ -1723,7 +1723,7 @@ function! s:convert_file_to_lines(wikifile, current_html_file) abort
let result['nohtml'] = nohtml let result['nohtml'] = nohtml
if nohtml if nohtml
echon "\r".'%nohtml placeholder found' call vimwiki#u#echo("\r".'%nohtml placeholder found', '', 'n')
return result return result
endif endif
@ -1808,7 +1808,7 @@ function! s:convert_file(path_html, wikifile) abort
return path_html.htmlfile return path_html.htmlfile
endif endif
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax' call vimwiki#u#error('Conversion to HTML is not supported for this syntax')
return '' return ''
endfunction endfunction
@ -1824,11 +1824,11 @@ endfunction
function! vimwiki#html#WikiAll2HTML(path_html, force) abort function! vimwiki#html#WikiAll2HTML(path_html, force) abort
if !s:syntax_supported() && !s:use_custom_wiki2html() if !s:syntax_supported() && !s:use_custom_wiki2html()
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax' call vimwiki#u#error('Conversion to HTML is not supported for this syntax')
return return
endif endif
echomsg 'Vimwiki: Saving Vimwiki files ...' call vimwiki#u#echo('Saving Vimwiki files ...')
let save_eventignore = &eventignore let save_eventignore = &eventignore
let &eventignore = 'all' let &eventignore = 'all'
try try
@ -1842,12 +1842,12 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
call vimwiki#path#mkdir(path_html) call vimwiki#path#mkdir(path_html)
if !vimwiki#vars#get_wikilocal('html_filename_parameterization') if !vimwiki#vars#get_wikilocal('html_filename_parameterization')
echomsg 'Vimwiki: Deleting non-wiki html files ...' call vimwiki#u#echo('Deleting non-wiki html files ...')
call s:delete_html_files(path_html) call s:delete_html_files(path_html)
endif endif
echomsg 'Vimwiki: Converting wiki to html files ...'
let setting_more = &more let setting_more = &more
call vimwiki#u#echo('Converting wiki to html files ...')
setlocal nomore setlocal nomore
" temporarily adjust current_subdir global state variable " temporarily adjust current_subdir global state variable
@ -1865,11 +1865,11 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir)) call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir))
if a:force || !s:is_html_uptodate(wikifile) if a:force || !s:is_html_uptodate(wikifile)
echomsg 'Vimwiki: Processing '.wikifile call vimwiki#u#echo('Processing '.wikifile)
call s:convert_file(path_html, wikifile) call s:convert_file(path_html, wikifile)
else else
echomsg 'Vimwiki: Skipping '.wikifile call vimwiki#u#echo('Skipping '.wikifile)
endif endif
endfor endfor
" reset 'subdir' state variable " reset 'subdir' state variable
@ -1878,10 +1878,10 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
let created = s:create_default_CSS(path_html) let created = s:create_default_CSS(path_html)
if created if created
echomsg 'Vimwiki: Default style.css has been created' call vimwiki#u#echo('Default style.css has been created')
endif endif
echomsg 'Vimwiki: HTML exported to '.path_html call vimwiki#u#echo('HTML exported to '.path_html)
echomsg 'Vimwiki: Done!' call vimwiki#u#echo('Done!')
let &more = setting_more let &more = setting_more
endfunction endfunction
@ -1995,7 +1995,7 @@ function! s:generate_rss(path) abort
endfunction endfunction
function! vimwiki#html#diary_rss() abort function! vimwiki#html#diary_rss() abort
echomsg 'Vimwiki: Saving RSS feed ...' call vimwiki#u#echo('Saving RSS feed ...')
let path_html = expand(vimwiki#vars#get_wikilocal('path_html')) let path_html = expand(vimwiki#vars#get_wikilocal('path_html'))
call vimwiki#path#mkdir(path_html) call vimwiki#path#mkdir(path_html)
call s:generate_rss(path_html) call s:generate_rss(path_html)

View File

@ -36,7 +36,6 @@ endfunction
" try markdown reference links " try markdown reference links
function! vimwiki#markdown_base#open_reflink(link) abort function! vimwiki#markdown_base#open_reflink(link) abort
" echom "vimwiki#markdown_base#open_reflink"
let link = a:link let link = a:link
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs') let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
if has_key(mkd_refs, link) if has_key(mkd_refs, link)

View File

@ -617,7 +617,6 @@ function! s:kbd_goto_prev_col(jumpup) abort
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a" let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>" " let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a" " let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd return cmd
endfunction endfunction
@ -645,7 +644,7 @@ function! vimwiki#tbl#kbd_tab() abort
let last = s:is_last_column(lnum, col('.')) let last = s:is_last_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum)) let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep "vimwiki#u#debug("DEBUG kbd_tab> last=".last.", is_sep=".is_sep)
if (is_sep || last) && !s:is_table(getline(lnum+1)) if (is_sep || last) && !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum))) let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 1) return s:kbd_create_new_row(cols, 1)
@ -662,7 +661,7 @@ function! vimwiki#tbl#kbd_shift_tab() abort
let first = s:is_first_column(lnum, col('.')) let first = s:is_first_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum)) let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> ".first "vimwiki#u#debug("kbd_tab> ".first)
if (is_sep || first) && !s:is_table(getline(lnum-1)) if (is_sep || first) && !s:is_table(getline(lnum-1))
return '' return ''
endif endif

View File

@ -3,6 +3,49 @@
" Description: Utility functions " Description: Utility functions
" Home: https://github.com/vimwiki/vimwiki/ " Home: https://github.com/vimwiki/vimwiki/
" Echo: msg
" :param: (1) <string> highlighting group
" :param: (2) <string> echo suffix (ex: 'n', 'm'
function! vimwiki#u#echo(msg, ...) abort
let hl_group = a:0 > 0 ? a:1 : ''
let echo_suffix = a:0 > 1 ? a:2 : ''
" Start highlighting
if hl_group !=# ''
exe 'echohl ' . hl_group
endif
" Print
let msg = substitute(a:msg, "'", "''", 'g')
exe 'echo'.echo_suffix . " 'Vimwiki: " . msg . "'"
" Stop highlighting
if hl_group !=# ''
echohl None
endif
endfunction
" Debug: msg
" let b:vimwiki_debug to trigger
function! vimwiki#u#debug(msg) abort
if !exists('b:vimwiki_debug') || b:vimwiki_debug == 0
return
endif
echomsg 'DEBUG: ' . a:msg
endfunction
" Warn: msg
function! vimwiki#u#warn(msg) abort
call vimwiki#u#echo('Warning: ' . a:msg, 'WarningMsg', '')
endfunction
" Error: msg
function! vimwiki#u#error(msg) abort
call vimwiki#u#echo('Error: ' . a:msg, 'Error', 'msg')
endfunction
" Warn: deprecated feature: old -> new
function! vimwiki#u#deprecate(old, new) abort
call vimwiki#u#warn('Deprecated: ' . a:old . ' is deprecated and '
\ . 'will be removed in future versions. Use ' . a:new . ' instead.')
endfunction
" Get visual selection text content, optionaly replace its content " Get visual selection text content, optionaly replace its content
" :param: Text to replace selection " :param: Text to replace selection
@ -264,7 +307,6 @@ function! vimwiki#u#hi_tag(tag_pre, tag_post, syntax_group, contains, ...) abort
\ opt_contains . \ opt_contains .
\ b:vimwiki_syntax_concealends . \ b:vimwiki_syntax_concealends .
\ opt_more \ opt_more
"echom cmd
exe cmd exe cmd
endfunction endfunction

View File

@ -239,8 +239,8 @@ function! s:read_global_settings_from_user() abort
for month in range(1, 12) for month in range(1, 12)
if !has_key(users_value, month) || type(users_value[month]) != type('') || if !has_key(users_value, month) || type(users_value[month]) != type('') ||
\ empty(users_value[month]) \ empty(users_value[month])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is' call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key) \ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
break break
endif endif
endfor endfor
@ -249,8 +249,8 @@ function! s:read_global_settings_from_user() abort
let users_value = g:vimwiki_global_vars[key] let users_value = g:vimwiki_global_vars[key]
for ext in keys(users_value) for ext in keys(users_value)
if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1 if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is' call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key) \ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
break break
endif endif
endfor endfor
@ -343,7 +343,7 @@ endfunction
" Populate local variable <- user & default " Populate local variable <- user & default
" Called: s:vimwiki#vars#init " Called: s:vimwiki#vars#init
function! s:populate_wikilocal_options() abort function! s:populate_wikilocal_options() abort
" Warning Dev: if type is dict, " Dev: if type is dict,
" -- the default dict gets extended and not replaced: keys are not deleted " -- the default dict gets extended and not replaced: keys are not deleted
" Init local variable container " Init local variable container
@ -481,8 +481,8 @@ function! s:populate_wikilocal_options() abort
for keyword in keys(users_value) for keyword in keys(users_value)
if type(keyword) != type('') || empty(keyword) || type(users_value[keyword]) != type('') || if type(keyword) != type('') || empty(keyword) || type(users_value[keyword]) != type('') ||
\ empty(users_value[keyword]) \ empty(users_value[keyword])
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is' call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key) \ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
break break
endif endif
endfor endfor
@ -493,7 +493,7 @@ endfunction
" Helper, Check user setting " Helper, Check user setting
" warn user with echo message if not good type " warn user with message if not good type
" Param: 1: key <string>: varaible name " Param: 1: key <string>: varaible name
" Param: 2: vimwiki_key <obj>: user value " Param: 2: vimwiki_key <obj>: user value
" Param: 3: value_infod <dict>: type and default value " Param: 3: value_infod <dict>: type and default value
@ -514,44 +514,44 @@ function! s:check_users_value(key, users_value, value_infos, comes_from_global_v
\ 'vimwiki-option-' \ 'vimwiki-option-'
if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type
echom printf('Vimwiki Error: The provided value of the option %s is a %s, ' . call vimwiki#u#error(printf('The provided value of the option %s is a %s, ' .
\ 'but expected is a %s. See '':h '.help_text.'%s''.', setting_origin, \ 'but expected is a %s. See '':h '.help_text.'%s''.', setting_origin,
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key) \ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key))
endif endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') && if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') &&
\ a:users_value < a:value_infos.min \ a:users_value < a:value_infos.min
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is' call vimwiki#u#error(printf('The provided value ''%i'' of the option %s is'
\ . ' too small. The minimum value is %i. See '':h '.help_text.'%s''.', a:users_value, \ . ' too small. The minimum value is %i. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.min, a:key) \ setting_origin, a:value_infos.min, a:key))
endif endif
if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') && if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') &&
\ a:users_value > a:value_infos.max \ a:users_value > a:value_infos.max
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is' call vimwiki#u#error(printf('The provided value ''%i'' of the option %s is'
\ . ' too large. The maximum value is %i. See '':h '.help_text.'%s''.', a:users_value, \ . ' too large. The maximum value is %i. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.max, a:key) \ setting_origin, a:value_infos.max, a:key))
endif endif
if has_key(a:value_infos, 'possible_values') && if has_key(a:value_infos, 'possible_values') &&
\ index(a:value_infos.possible_values, a:users_value) == -1 \ index(a:value_infos.possible_values, a:users_value) == -1
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s is' call vimwiki#u#error(printf('The provided value ''%s'' of the option %s is'
\ . ' invalid. Allowed values are %s. See '':h '.help_text.'%s''.', a:users_value, \ . ' invalid. Allowed values are %s. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, string(a:value_infos.possible_values), a:key) \ setting_origin, string(a:value_infos.possible_values), a:key))
endif endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'length') && if a:value_infos.type == type('') && has_key(a:value_infos, 'length') &&
\ strwidth(a:users_value) != a:value_infos.length \ strwidth(a:users_value) != a:value_infos.length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must' call vimwiki#u#error(printf('The provided value ''%s'' of the option %s must'
\ . ' contain exactly %i character(s) but has %i. See '':h '.help_text.'_%s''.', \ . ' contain exactly %i character(s) but has %i. See '':h '.help_text.'_%s''.',
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key) \ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key))
endif endif
if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') && if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') &&
\ strwidth(a:users_value) < a:value_infos.min_length \ strwidth(a:users_value) < a:value_infos.min_length
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must' call vimwiki#u#error(printf('The provided value ''%s'' of the option %s must'
\ . ' have at least %d character(s) but has %d. See '':h '.help_text.'%s''.', a:users_value, \ . ' have at least %d character(s) but has %d. See '':h '.help_text.'%s''.', a:users_value,
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key) \ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key))
endif endif
endfunction endfunction
@ -851,9 +851,9 @@ function! s:populate_list_vars(wiki) abort
" Guard: Check if listym_rejected is in listsyms " Guard: Check if listym_rejected is in listsyms
if match(a:wiki.listsyms, '[' . a:wiki.listsym_rejected . ']') != -1 if match(a:wiki.listsyms, '[' . a:wiki.listsym_rejected . ']') != -1
echomsg 'Vimwiki Warning: the value of listsym_rejected (''' call vimwiki#u#warn('the value of listsym_rejected ('''
\ . a:wiki.listsym_rejected . ''') must not be a part of listsyms (''' \ . a:wiki.listsym_rejected . ''') must not be a part of listsyms ('''
\ . a:wiki.listsyms . ''')' \ . a:wiki.listsyms . ''')')
endif endif
let a:wiki.rxListItemWithoutCB = let a:wiki.rxListItemWithoutCB =
@ -1121,7 +1121,7 @@ function! vimwiki#vars#get_bufferlocal(key, ...) abort
elseif a:key ==# 'markdown_refs' elseif a:key ==# 'markdown_refs'
call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks()) call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks())
else else
echoerr 'Vimwiki Error: unknown buffer variable ' . string(a:key) call vimwiki#u#echo('unknown buffer variable ' . string(a:key))
endif endif
return getbufvar(buffer, 'vimwiki_'.a:key) return getbufvar(buffer, 'vimwiki_'.a:key)

View File

@ -256,17 +256,19 @@ endfunction
command! -buffer Vimwiki2HTML command! -buffer Vimwiki2HTML
\ if filewritable(expand('%')) | silent noautocmd w | endif \ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar> \ <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), \ let res = vimwiki#html#Wiki2HTML(
\ expand('%')) \ expand(vimwiki#vars#get_wikilocal('path_html')), expand('%'))
\ <bar> \ <bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: ' \ if res != '' | call vimwiki#u#echo('HTML conversion is done, output: '
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif \ . expand(vimwiki#vars#get_wikilocal('path_html'))) | endif
command! -buffer Vimwiki2HTMLBrowse command! -buffer Vimwiki2HTMLBrowse
\ if filewritable(expand('%')) | silent noautocmd w | endif \ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar> \ <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML( \ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(vimwiki#vars#get_wikilocal('path_html')), \ expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))) \ expand('%')))
command! -buffer -bang VimwikiAll2HTML command! -buffer -bang VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), <bang>0) \ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), <bang>0)
@ -566,7 +568,6 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists)
endif endif
endif endif
" Not used
function! s:CR(normal, just_mrkr) abort function! s:CR(normal, just_mrkr) abort
let res = vimwiki#tbl#kbd_cr() let res = vimwiki#tbl#kbd_cr()
if res !=? '' if res !=? ''