From 777569f95fba78408d2ee0cdddcd39e08b51d351 Mon Sep 17 00:00:00 2001 From: mMontu Date: Tue, 12 Jul 2016 11:41:44 -0300 Subject: [PATCH 01/93] Workaround for slow folding methods (issue #225) --- doc/vimwiki.txt | 2 ++ plugin/vimwiki.vim | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 9cc5dd9..7192574 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2288,6 +2288,8 @@ Limitations: - 'list' is intended to work with lists nicely indented with 'shiftwidth'. - 'syntax' is only available for the default syntax so far. +The options above can be suffixed with ':quick' (e.g.: 'expr:quick') in order +to use some workarounds to make folds work faster. ------------------------------------------------------------------------------ *g:vimwiki_list_ignore_newline* diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index d7abb6c..90fb166 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -156,15 +156,15 @@ function! s:setup_buffer_enter() "{{{ " Settings foldmethod, foldexpr and foldtext are local to window. Thus in a " new tab with the same buffer folding is reset to vim defaults. So we " insist vimwiki folding here. - if g:vimwiki_folding ==? 'expr' + if g:vimwiki_folding =~? '^expr.*' setlocal fdm=expr setlocal foldexpr=VimwikiFoldLevel(v:lnum) setlocal foldtext=VimwikiFoldText() - elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists' + elseif g:vimwiki_folding =~? '^list.*' || g:vimwiki_folding ==? '^lists.*' setlocal fdm=expr setlocal foldexpr=VimwikiFoldListLevel(v:lnum) setlocal foldtext=VimwikiFoldText() - elseif g:vimwiki_folding ==? 'syntax' + elseif g:vimwiki_folding =~? '^syntax.*' setlocal fdm=syntax setlocal foldtext=VimwikiFoldText() else @@ -446,6 +446,14 @@ augroup vimwiki exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))' exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))' endif + if g:vimwiki_folding =~? ':quick$' + " from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text + " Don't screw up folds when inserting text that might affect them, until + " leaving insert mode. Foldmethod is local to the window. Protect against + " screwing up folding when switching between windows. + exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif' + exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif' + endif endfor augroup END "}}} From 4c5b0fec6ba270c6ac5a30e7ea41fcc31c95a998 Mon Sep 17 00:00:00 2001 From: Alex Thorne Date: Mon, 12 Dec 2016 22:20:52 +0000 Subject: [PATCH 02/93] Fix typo in docs --- doc/vimwiki.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 9cc5dd9..244519e 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -854,7 +854,7 @@ Raw URLs are also supported: > External files~ -The "file:" and "local:" schemes allow you to directly link to arbitray +The "file:" and "local:" schemes allow you to directly link to arbitrary resources using absolute or relative paths: > [[file:/home/somebody/a/b/c/music.mp3]] [[file:C:/Users/somebody/d/e/f/music.mp3]] From febf716bf5870a2e5318ec5bd6d2307a7e43c6bb Mon Sep 17 00:00:00 2001 From: Shafqat Bhuiyan Date: Tue, 13 Dec 2016 10:30:51 +1100 Subject: [PATCH 03/93] Fix example mapping for decreasing list item level --- doc/vimwiki.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 9cc5dd9..9119ddb 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -363,7 +363,7 @@ glh Decrease the level of a list item. gLh Decrease the level of a list item and all child items. To remap: > :map << VimwikiDecreaseLvlSingleItem - :map >>> VimwikiDecreaseLvlWholeItem + :map <<< VimwikiDecreaseLvlWholeItem < *vimwiki_glr* *vimwiki_gLr* glr Renumber list items if the cursor is on a numbered From 8507c9571680882e1e808ac251cba2d5562e0b4f Mon Sep 17 00:00:00 2001 From: Michael Thessel Date: Thu, 5 Jan 2017 22:01:48 -0800 Subject: [PATCH 04/93] Added config option to allow for newlines in text when exporting to HTML --- autoload/vimwiki/html.vim | 6 +++++- doc/vimwiki.txt | 13 +++++++++++++ plugin/vimwiki.vim | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 584985f..a35e422 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -979,7 +979,11 @@ function! s:process_tag_para(line, para) "{{{ let para = 1 endif let processed = 1 - call add(lines, a:line) + if g:vimwiki_text_ignore_newline == 1 + call add(lines, a:line) + else + call add(lines, a:line."
") + endif elseif para && a:line =~# '^\s*$' call add(lines, "

") let para = 0 diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 9cc5dd9..08cf581 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2302,6 +2302,19 @@ Value Description~ Default: 1 +------------------------------------------------------------------------------ +*g:vimwiki_text_ignore_newline* + +This is HTML related. +Convert newlines to
s in text. + +Value Description~ +0 Newlines in text are converted to
s. +1 Ignore newlines. + +Default: 1 + + ------------------------------------------------------------------------------ *g:vimwiki_use_calendar* diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index d7abb6c..ddb4b35 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -369,6 +369,7 @@ call s:default('ext2syntax', {}) " syntax map keyed on extension call s:default('hl_headers', 0) call s:default('hl_cb_checked', 0) call s:default('list_ignore_newline', 1) +call s:default('text_ignore_newline', 1) call s:default('listsyms', ' .oOX') call s:default('use_calendar', 1) call s:default('table_mappings', 1) From c857be2f8742ff812794498e4d371dd74d668340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= Date: Sun, 22 Jan 2017 20:16:10 +0100 Subject: [PATCH 05/93] Allow g:vimwiki_listsyms be larger than 5 elements (Issue #275) (#279) * Allow g:vimwiki_listsyms to be of arbitrary size * Update documentation * Add support for arbitrary size listsyms to vimwikihtml --- autoload/vimwiki/html.vim | 6 +++++- autoload/vimwiki/lst.vim | 13 ++++++------- doc/vimwiki.txt | 4 ++-- syntax/vimwiki.vim | 2 +- syntax/vimwiki_default.vim | 2 +- syntax/vimwiki_markdown.vim | 2 +- syntax/vimwiki_media.vim | 2 +- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 584985f..957fa97 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -860,7 +860,11 @@ function! s:process_tag_list(line, lists) "{{{ let chk = matchlist(a:line, a:rx_list) if !empty(chk) && len(chk[1]) > 0 let completion = index(g:vimwiki_listsyms_list, chk[1]) - if completion >= 0 && completion <=4 + let n = len(g:vimwiki_listsyms_list) + if completion == 0 + let st_tag = '
  • ' + elseif completion > 0 && completion < n + let completion = float2nr(round(completion / (n-1.0) * 3.0 + 0.5 )) let st_tag = '
  • ' endif endif diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index ee465e4..4a75f3f 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -693,7 +693,8 @@ function! s:get_rate(item) "{{{ return -1 endif let state = a:item.cb - return index(g:vimwiki_listsyms_list, state) * 25 + let n=len(g:vimwiki_listsyms_list) + return index(g:vimwiki_listsyms_list, state) * 100/(n-1) endfunction "}}} "Set state of the list item to [ ] or [o] or whatever @@ -729,16 +730,14 @@ endfunction "}}} "Returns: the appropriate symbol for a given percent rate function! s:rate_to_state(rate) "{{{ let state = '' + let n=len(g:vimwiki_listsyms_list) if a:rate == 100 - let state = g:vimwiki_listsyms_list[4] + let state = g:vimwiki_listsyms_list[n-1] elseif a:rate == 0 let state = g:vimwiki_listsyms_list[0] - elseif a:rate >= 67 - let state = g:vimwiki_listsyms_list[3] - elseif a:rate >= 34 - let state = g:vimwiki_listsyms_list[2] else - let state = g:vimwiki_listsyms_list[1] + let index = float2nr(ceil(a:rate/100.0*(n-2))) + let state = g:vimwiki_listsyms_list[index] endif return state endfunction "}}} diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 9cc5dd9..5a56331 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2245,11 +2245,11 @@ Default: 'Vimwiki' ------------------------------------------------------------------------------ *g:vimwiki_listsyms* -String of 5 symbols to show the progression of todo list items. +String of at least two symbols to show the progression of todo list items. Default value is ' .oOX'. The first char is for 0% done items. -The fifth is for 100% done items. +The last is for 100% done items. You can set it to some more fancy symbols like this: > diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index 0669fa7..ba500c5 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -413,7 +413,7 @@ execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/' execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/' if g:vimwiki_hl_cb_checked == 1 - execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[4].'\]\s.*$/ '. + execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemWithoutCB.'\s*\['.g:vimwiki_listsyms_list[-1].'\]\s.*$/ '. \ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell' elseif g:vimwiki_hl_cb_checked == 2 execute 'syntax match VimwikiCheckBoxDone /'.g:vimwiki_rxListItemAndChildren.'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell' diff --git a/syntax/vimwiki_default.vim b/syntax/vimwiki_default.vim index 6150f99..a90ea20 100644 --- a/syntax/vimwiki_default.vim +++ b/syntax/vimwiki_default.vim @@ -80,7 +80,7 @@ call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' -let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' +let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text let g:vimwiki_rxPreStart = '{{{' diff --git a/syntax/vimwiki_markdown.vim b/syntax/vimwiki_markdown.vim index c32c7d7..3ae9da0 100644 --- a/syntax/vimwiki_markdown.vim +++ b/syntax/vimwiki_markdown.vim @@ -77,7 +77,7 @@ call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' -let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' +let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text let g:vimwiki_rxPreStart = '```' diff --git a/syntax/vimwiki_media.vim b/syntax/vimwiki_media.vim index 9c0498e..a6f8e4a 100644 --- a/syntax/vimwiki_media.vim +++ b/syntax/vimwiki_media.vim @@ -58,7 +58,7 @@ call vimwiki#lst#setup_marker_infos() let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.g:vimwiki_listsyms.']\)\]\s\)\?' -let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*' +let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[-1].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*' " Preformatted text let g:vimwiki_rxPreStart = '
    '
    
    From 2eed86813d396a340c60d40e08a7d84ff57a93f3 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sun, 19 Feb 2017 21:50:35 +0100
    Subject: [PATCH 06/93] Update folding documentation to match current behaviour
    
    Ref #297
    Ref #117
    ---
     doc/vimwiki.txt | 58 +++++++++++++++++++++++++++++--------------------
     1 file changed, 34 insertions(+), 24 deletions(-)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 9cc5dd9..7ea4b8c 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -1281,40 +1281,50 @@ Tags-related commands and options:
     6. Folding/Outline                                           *vimwiki-folding*
     
     Vimwiki can fold or outline sections using headers and preformatted blocks.
    -Alternatively, one can fold list subitems instead.
    +Alternatively, one can fold list subitems instead. Folding is not enabled
    +by default, and requires the |g:vimwiki_folding| variable to be set.
    +
    +Example for list folding with |g:vimwiki_folding| set to 'list':
     
    -Example for list folding:
     = My current task =
    -  * [ ] Do stuff 1
    -    * [ ] Do substuff 1.1
    -    * [ ] Do substuff 1.2
    -      * [ ] Do substuff 1.2.1
    -      * [ ] Do substuff 1.2.2
    -    * [ ] Do substuff 1.3
    -  * [ ] Do stuff 2
    -  * [ ] Do stuff 3
    +* [ ] Do stuff 1
    +  * [ ] Do substuff 1.1
    +  * [ ] Do substuff 1.2
    +    * [ ] Do substuff 1.2.1
    +    * [ ] Do substuff 1.2.2
    +  * [ ] Do substuff 1.3
    +* [ ] Do stuff 2
    +* [ ] Do stuff 3
     
     Hit |zM| :
    -= My current task = [8] --------------------------------------~
    += My current task =
    +* [ ] Do stuff 1 [6] --------------------------------------~
    +* [ ] Do stuff 2
    +* [ ] Do stuff 3
     
     Hit |zr| :
    -= My current task =~
    -  * [ ] Do stuff 1 [5] --------------------------------------~
    -  * [ ] Do stuff 2~
    -  * [ ] Do stuff 3~
    += My current task =
    +* [ ] Do stuff 1
    +  * [ ] Do substuff 1.1
    +  * [ ] Do substuff 1.2 [3] -------------------------------~
    +  * [ ] Do substuff 1.3
    +* [ ] Do stuff 2
    +* [ ] Do stuff 3
     
    -Hit |zr| one more time:
    -= My current task =~
    -  * [ ] Do stuff 1~
    -    * [ ] Do substuff 1.1~
    -    * [ ] Do substuff 1.2 [2] -------------------------------~
    -    * [ ] Do substuff 1.3~
    -  * [ ] Do stuff 2~
    -  * [ ] Do stuff 3~
    +Hit |zr| one more time :
    += My current task =
    +* [ ] Do stuff 1
    +  * [ ] Do substuff 1.1
    +  * [ ] Do substuff 1.2
    +    * [ ] Do substuff 1.2.1
    +    * [ ] Do substuff 1.2.2
    +  * [ ] Do substuff 1.3
    +* [ ] Do stuff 2
    +* [ ] Do stuff 3
     
     Note: If you use the default Vimwiki syntax, folding on list items will work
     properly only if all of them are indented using the current 'shiftwidth'.
    -For MediaWiki, * or # should be in the first column.
    +For MediaWiki syntax, * or # should be in the first column.
     
     To turn folding on/off check |g:vimwiki_folding|.
     
    
    From 56cb06e73e9850e60b6eb53bad8bb98ded1ab872 Mon Sep 17 00:00:00 2001
    From: Daniel Schemala 
    Date: Wed, 1 Mar 2017 21:38:14 +0100
    Subject: [PATCH 07/93] Fix  under Windows
    
    It didn't do anything after you hit a link which jumps inside a buffer.
    This makes me realize that there are probably a lot more issues under
    Windows.
    ---
     autoload/vimwiki/base.vim | 6 +++---
     autoload/vimwiki/path.vim | 8 +++++++-
     2 files changed, 10 insertions(+), 4 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 748ccbd..1aa963a 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -247,7 +247,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
         let source_file = a:1
       else
         let source_wiki = g:vimwiki_current_idx
    -    let source_file = expand('%:p')
    +    let source_file = vimwiki#path#current_wiki_file()
       endif
     
       let link_text = a:link_text
    @@ -406,7 +406,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
             \ || link_infos.scheme =~# 'diary'
     
       let update_prev_link = is_wiki_link &&
    -        \ !vimwiki#path#is_equal(link_infos.filename, expand('%:p'))
    +        \ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
     
       let vimwiki_prev_link = []
       " update previous link for wiki pages
    @@ -414,7 +414,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
         if a:0
           let vimwiki_prev_link = [a:1, []]
         elseif &ft ==# 'vimwiki'
    -      let vimwiki_prev_link = [expand('%:p'), getpos('.')]
    +      let vimwiki_prev_link = [vimwiki#path#current_wiki_file(), getpos('.')]
         endif
       endif
     
    diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim
    index f57c6fb..9790316 100644
    --- a/autoload/vimwiki/path.vim
    +++ b/autoload/vimwiki/path.vim
    @@ -75,7 +75,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
     endfunction "}}}
     
     function! vimwiki#path#wikify_path(path) "{{{
    -  let result = resolve(expand(a:path, ':p'))
    +  let result = resolve(fnamemodify(a:path, ':p'))
       if vimwiki#u#is_windows()
         let result = substitute(result, '\\', '/', 'g')
       endif
    @@ -83,6 +83,12 @@ function! vimwiki#path#wikify_path(path) "{{{
       return result
     endfunction "}}}
     
    +
    +function! vimwiki#path#current_wiki_file()
    +  return vimwiki#path#wikify_path(expand('%:p'))
    +endfunction
    +
    +
     " Returns: the relative path from a:dir to a:file
     function! vimwiki#path#relpath(dir, file) "{{{
       let result = []
    
    From e4fe5ce09d7cfdf336cdef61394296768d79cf6d Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sun, 19 Mar 2017 10:17:21 +0100
    Subject: [PATCH 08/93] Add possibility to reuse a split when opening a link
    
    Also, refactor and simplify the corresponding functions (and finally
    remove the chat between long inactive developers in the comments!)
    
    Fix #316
    ---
     autoload/vimwiki/base.vim          | 90 +++++++++++++++++++-----------
     autoload/vimwiki/markdown_base.vim | 55 ------------------
     doc/vimwiki.txt                    | 31 ++++++++++
     ftplugin/vimwiki.vim               | 10 ++--
     4 files changed, 93 insertions(+), 93 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 1aa963a..0cd537a 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1220,57 +1220,81 @@ function! vimwiki#base#find_prev_link() "{{{
     endfunction " }}}
     
     " vimwiki#base#follow_link
    -function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass 
    -  " to VimwikiLinkHandler, or failing that, the default open_link handler
    -  if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link')
    -    " Syntax-specific links
    -    " XXX: @Stuart: do we still need it?
    -    " XXX: @Maxim: most likely!  I am still working on a seemless way to
    -    " integrate regexp's without complicating syntax/vimwiki.vim
    -    if a:0
    -      call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split, a:1)
    -    else
    -      call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
    +function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
    +  " Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
    +  " default open_link handler
    +
    +  " try WikiLink
    +  let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
    +        \ g:vimwiki_rxWikiLinkMatchUrl)
    +  " try WikiIncl
    +  if lnk == ""
    +    let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
    +          \ g:vimwiki_rxWikiInclMatchUrl)
    +  endif
    +  " try Weblink
    +  if lnk == ""
    +    let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
    +          \ g:vimwiki_rxWeblinkMatchUrl)
    +  endif
    +
    +  if lnk != ""    " cursor is indeed on a link
    +    let processed_by_user_defined_handler = VimwikiLinkHandler(lnk)
    +    if processed_by_user_defined_handler
    +      return
         endif
    -  else
    -    if a:split ==# "split"
    +
    +    if a:split ==# "hsplit"
           let cmd = ":split "
         elseif a:split ==# "vsplit"
           let cmd = ":vsplit "
    -    elseif a:split ==# "tabnew"
    +    elseif a:split ==# "tab"
           let cmd = ":tabnew "
         else
           let cmd = ":e "
         endif
     
    -    " try WikiLink
    -    let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
    -          \ g:vimwiki_rxWikiLinkMatchUrl)
    -    " try WikiIncl
    -    if lnk == ""
    -      let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
    -          \ g:vimwiki_rxWikiInclMatchUrl)
    -    endif
    -    " try Weblink
    -    if lnk == ""
    -      let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
    -            \ g:vimwiki_rxWeblinkMatchUrl)
    -    endif
    -
    -    if lnk != ""
    -      if !VimwikiLinkHandler(lnk)
    -        call vimwiki#base#open_link(cmd, lnk)
    +    " if we want to and can reuse a split window, jump to that window and open
    +    " the new file there
    +    if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && a:reuse
    +      let previous_window_nr = winnr('#')
    +      if previous_window_nr > 0 && previous_window_nr != winnr()
    +        execute previous_window_nr . 'wincmd w'
    +        let cmd = ':e'
           endif
    -      return
         endif
     
    +
    +    if VimwikiGet('syntax') == 'markdown'
    +      let processed_by_markdown_reflink = vimwiki#markdown_base#open_reflink(lnk)
    +      if processed_by_markdown_reflink
    +        return
    +      endif
    +
    +      " remove the extension from the filename if exists, because non-vimwiki
    +      " markdown files usually include the extension in links
    +      let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '')
    +    endif
    +
    +    let current_tab_page = tabpagenr()
    +
    +    call vimwiki#base#open_link(cmd, lnk)
    +
    +    if !a:move_cursor
    +      if (a:split ==# 'hsplit' || a:split ==# 'vsplit')
    +        execute 'wincmd p'
    +      elseif a:split ==# 'tab'
    +        execute 'tabnext ' . current_tab_page
    +      endif
    +    endif
    +
    +  else
         if a:0 > 0
           execute "normal! ".a:1
         else		
           call vimwiki#base#normalize_link(0)
         endif
       endif
    -
     endfunction " }}}
     
     " vimwiki#base#go_back_link
    diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
    index ef2eb36..a750cb0 100644
    --- a/autoload/vimwiki/markdown_base.vim
    +++ b/autoload/vimwiki/markdown_base.vim
    @@ -70,61 +70,6 @@ endfunction " }}}
     
     " WIKI link following functions {{{
     
    -" vimwiki#markdown_base#follow_link
    -function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass 
    -  " to VimwikiLinkHandler, or failing that, the default open_link handler
    -  " echom "markdown_base#follow_link"
    -
    -  if 0
    -    " Syntax-specific links
    -    " XXX: @Stuart: do we still need it?
    -    " XXX: @Maxim: most likely!  I am still working on a seemless way to
    -    " integrate regexp's without complicating syntax/vimwiki.vim
    -  else
    -    if a:split ==# "split"
    -      let cmd = ":split "
    -    elseif a:split ==# "vsplit"
    -      let cmd = ":vsplit "
    -    elseif a:split ==# "tabnew"
    -      let cmd = ":tabnew "
    -    else
    -      let cmd = ":e "
    -    endif
    -
    -    " try WikiLink
    -    let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
    -          \ g:vimwiki_rxWikiLinkMatchUrl)
    -    " try WikiIncl
    -    if lnk == ""
    -      let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
    -          \ g:vimwiki_rxWikiInclMatchUrl)
    -    endif
    -    " try Weblink
    -    if lnk == ""
    -      let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
    -            \ g:vimwiki_rxWeblinkMatchUrl)
    -    endif
    -
    -    if lnk != ""
    -      if !VimwikiLinkHandler(lnk)
    -        if !vimwiki#markdown_base#open_reflink(lnk)
    -          " remove the extension from the filename if exists
    -          let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '')
    -          call vimwiki#base#open_link(cmd, lnk)
    -        endif
    -      endif
    -      return
    -    endif
    -
    -    if a:0 > 0
    -      execute "normal! ".a:1
    -    else		
    -      call vimwiki#base#normalize_link(0)
    -    endif
    -  endif
    -
    -endfunction " }}}
    -
     " LINK functions {{{
     
     " s:normalize_link_syntax_n
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 5587388..983c713 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -594,6 +594,9 @@ il                      A single list item.
     ------------------------------------------------------------------------------
     4.2. Local commands                                   *vimwiki-local-commands*
     
    +These commands are only available (and meaningful) when you are currently in a
    +Vimwiki file.
    +
     *:VimwikiFollowLink*
         Follow wiki link (or create target wiki page if needed).
     
    @@ -742,6 +745,34 @@ il                      A single list item.
         their instances.  Supports |cmdline-completion|.  If
         no arguments (tags) are specified, outputs all tags.
     
    +------------------------------------------------------------------------------
    +4.3. Functions                                              *vimwiki-functions*
    +
    +Functions to interact with Vimwiki. (It's intended that most commands will be
    +replaced with corresponding function calls in the future.)
    +Warning: this is currently unstable and likely to change.
    +
    +
    +To map them to a key, use >
    + nnoremap  :call vimwiki#base#function_name(arg1, arg2)
    +
    +
    +vimwiki#base#follow_link({split}, {reuse}, {move_cursor})         *follow_link*
    +    Open the link under the cursor. {split} can have the following values:
    +        'nosplit'       open the link in the current window
    +        'vsplit'        open in a vertically split window
    +        'hsplit'        open in a horizontally split window
    +        'tab'           open in a new tab
    +
    +    If {reuse} is 1 and {split} one of 'vsplit' or 'hsplit', open the link in
    +    a possibly existing split window instead of making a new split.
    +
    +    If {move_cursor} is 1 the cursor moves to the window or tab with the
    +    opened link, otherwise, it stays in the window or tab with the link.
    +
    +    For example,  is per default mapped to
    +    vimwiki#base#follow_link('nosplit', 0, 1)
    +
     
     ==============================================================================
     5. Wiki syntax                                                *vimwiki-syntax*
    diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
    index 1f96ec2..3390b06 100644
    --- a/ftplugin/vimwiki.vim
    +++ b/ftplugin/vimwiki.vim
    @@ -264,14 +264,14 @@ command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
     command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
     command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
     command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
    -command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit')
    +command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
     command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
    -command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split')
    -command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
    +command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('hsplit', 0, 1)
    +command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', 0, 1)
     
     command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link()
     
    -command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
    +command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
     
     command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
     
    @@ -327,7 +327,7 @@ command! -buffer -nargs=* -complete=custom,vimwiki#tags#complete_tags
     if g:vimwiki_use_mouse
       nmap   
       nmap   
    -  nnoremap  <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\2-LeftMouse>")
    +  nnoremap  <2-LeftMouse> :call vimwiki#base#follow_link('nosplit', 0, 1, "\2-LeftMouse>")
       nnoremap   :VimwikiSplitLink
       nnoremap   :VimwikiVSplitLink
       nnoremap   :VimwikiGoBackLink
    
    From 065b7cbac08bd8163e324d7624793bed226bd7a6 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sun, 19 Mar 2017 10:26:25 +0100
    Subject: [PATCH 09/93] Small fix to the doc
    
    Don't use arbitrary tags, but always use the prefix 'vimwiki'.
    Ref #316
    ---
     doc/vimwiki.txt | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 983c713..493284c 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -755,9 +755,10 @@ Warning: this is currently unstable and likely to change.
     
     To map them to a key, use >
      nnoremap  :call vimwiki#base#function_name(arg1, arg2)
    +<
     
    -
    -vimwiki#base#follow_link({split}, {reuse}, {move_cursor})         *follow_link*
    +                                                          *vimwiki-follow_link*
    +vimwiki#base#follow_link({split}, {reuse}, {move_cursor})
         Open the link under the cursor. {split} can have the following values:
             'nosplit'       open the link in the current window
             'vsplit'        open in a vertically split window
    
    From dd4b9e12761b61a72f83b3af7c7378b41554e63b Mon Sep 17 00:00:00 2001
    From: sqlwwx 
    Date: Mon, 27 Mar 2017 20:47:48 +0800
    Subject: [PATCH 10/93] doc install by Vim packages
    
    ---
     README.md | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/README.md b/README.md
    index 5816229..6581b20 100644
    --- a/README.md
    +++ b/README.md
    @@ -122,6 +122,11 @@ Make sure you have these settings in your vimrc file:
     Without them Vimwiki will not work properly.
     
     
    +Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
    +------------------------------------------------------------------------------
    +
    +    git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
    +
     Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
     ------------------------------------------------------------------------------
     
    
    From 13f82dbaacbe47c934414da1a64a059e7b5ed212 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Fri, 31 Mar 2017 21:38:32 +0200
    Subject: [PATCH 11/93] Add option for enabling local folding settings
    
    Ref #321
    ---
     doc/vimwiki.txt    | 2 ++
     plugin/vimwiki.vim | 2 ++
     2 files changed, 4 insertions(+)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 493284c..b8c15e5 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -2321,6 +2321,8 @@ Value           Description~
     'expr'          Folding based on expression (folds sections and code blocks)
     'syntax'        Folding based on syntax (folds sections; slower than 'expr')
     'list'          Folding based on expression (folds list subitems; much slower)
    +'custom'        Leave the folding settings as they are (e.g. set by another
    +                plugin)
     
     Default: ''
     
    diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
    index ddb4b35..bcbf4de 100644
    --- a/plugin/vimwiki.vim
    +++ b/plugin/vimwiki.vim
    @@ -167,6 +167,8 @@ function! s:setup_buffer_enter() "{{{
       elseif g:vimwiki_folding ==? 'syntax'
         setlocal fdm=syntax
         setlocal foldtext=VimwikiFoldText()
    +  elseif g:vimwiki_folding ==? 'custom'
    +    " do nothing
       else
         setlocal fdm=manual
         normal! zE
    
    From 30ab7dbff0f1d4be0c821eeb6d0f6d70ef054d9b Mon Sep 17 00:00:00 2001
    From: Guilherme Salazar 
    Date: Tue, 4 Apr 2017 20:17:39 -0300
    Subject: [PATCH 12/93] fix issue in Markdown visual mode link creation
    
    ---
     autoload/vimwiki/markdown_base.vim | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
    index a750cb0..06477d8 100644
    --- a/autoload/vimwiki/markdown_base.vim
    +++ b/autoload/vimwiki/markdown_base.vim
    @@ -145,7 +145,7 @@ function! s:normalize_link_syntax_v() " {{{
         call setreg('"', link, 'v')
     
         " paste result
    -    norm! `>pgvd
    +    norm! `>""pgvd
     
       finally
         call setreg('"', rv, rt)
    
    From f54f72981decd379a4190c34391336431201ce4b Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Thu, 13 Apr 2017 20:33:56 +0200
    Subject: [PATCH 13/93] Add a clarifying note to the doc
    
    Ref #332
    ---
     doc/vimwiki.txt | 10 ++++++----
     1 file changed, 6 insertions(+), 4 deletions(-)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index b8c15e5..e0a4810 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -742,8 +742,9 @@ Vimwiki file.
     
     *:VimwikiGenerateTags* tagname1 tagname2 ...
         Creates or updates an overview on all tags of the wiki with links to all
    -    their instances.  Supports |cmdline-completion|.  If
    -    no arguments (tags) are specified, outputs all tags.
    +    their instances.  Supports |cmdline-completion|.  If no arguments (tags)
    +    are specified, outputs all tags.  To make this command work properly, make
    +    sure the tags have been built (see |vimwiki-build-tags|).
     
     ------------------------------------------------------------------------------
     4.3. Functions                                              *vimwiki-functions*
    @@ -1296,8 +1297,9 @@ which opens up a popup menu with all tags defined in the wiki starting with
     
     Tags are also treated as |vimwiki-anchors| (similar to bold text).
     
    -Note that tag search/jump/completion commands need certain metadata saved in
    -the wiki folder.  This metadata file can be manually updated by running
    +                                                          *vimwiki-build-tags*
    +Note that the tag search/jump/completion commands need certain metadata saved
    +in the wiki folder.  This metadata file can be manually updated by running
     |:VimwikiRebuildTags|.  When the option |vimwiki-option-auto_tags| is enabled,
     the tags metadata will be auto-updated on each page save.
     
    
    From ca95b3fc73528d558156d02650541e85b2ddf25b Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 15 Apr 2017 10:09:24 +0200
    Subject: [PATCH 14/93] Add some remarks about nested syntaxes to the doc
    
    Ref #329
    ---
     README.md       | 6 +++++-
     doc/vimwiki.txt | 7 +++++--
     2 files changed, 10 insertions(+), 3 deletions(-)
    
    diff --git a/README.md b/README.md
    index 6581b20..a407040 100644
    --- a/README.md
    +++ b/README.md
    @@ -2,7 +2,7 @@ A Personal Wiki For Vim
     ==============================================================================
     
     ![screenshot1](doc/screenshot_1.png)
    -![screenshot2](doc/screenshot_2.png)
    +![screenshot2](doc/screenshot_2.png) *
     
     Intro
     ------------------------------------------------------------------------------
    @@ -145,3 +145,7 @@ Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run
     Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/`
     
     Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed.
    +
    +----
    +\* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized)
    +and [lightline](https://github.com/itchyny/lightline.vim)
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index e0a4810..2585c5c 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -1177,7 +1177,8 @@ This might be useful for coloring program code with external JS tools
     such as Google's syntax highlighter.
     
     You can setup Vimwiki to highlight code snippets in preformatted text.
    -See |vimwiki-option-nested_syntaxes|
    +See |vimwiki-option-nested_syntaxes| and
    +|vimwiki-option-automatic_nested_syntaxes|.
     
     
     ------------------------------------------------------------------------------
    @@ -2074,7 +2075,9 @@ Just write your preformatted text in your file like this >
      my preformatted text
      }}}
     
    -where xxx is a Vim filetype.
    +where xxx is a filetype which is known to Vim. For example, for C++
    +highlighting, use "cpp" (not "c++"). For a list of known filetypes, type
    +":setf " and hit Ctrl+d.
     
     Note that you may have to reload the file (|:edit|) to see the highlight.
     
    
    From 39745ebcd317be5dd9a824a1217fa5dede01b105 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 15 Apr 2017 10:49:53 +0200
    Subject: [PATCH 15/93] Don't open all diary files when going to next day
    
    This is unnecessary and can be very slow when the user has many diary
    files.
    Ref #328
    ---
     autoload/vimwiki/diary.vim | 12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
    index 7d773e8..fcd176a 100644
    --- a/autoload/vimwiki/diary.vim
    +++ b/autoload/vimwiki/diary.vim
    @@ -43,7 +43,7 @@ function! s:get_position_links(link) "{{{
       let idx = -1
       let links = []
       if a:link =~# '^\d\{4}-\d\d-\d\d'
    -    let links = keys(s:get_diary_links())
    +    let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
         " include 'today' into links
         if index(links, s:diary_date_link()) == -1
           call add(links, s:diary_date_link())
    @@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
       return result
     endfun "}}}
     
    -fun! s:get_diary_links() "{{{
    +fun! s:get_diary_files() "{{{
       let rx = '^\d\{4}-\d\d-\d\d'
       let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
       let files = split(s_files, '\n')
    @@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{
       " remove backup files (.wiki~)
       call filter(files, 'v:val !~# ''.*\~$''')
     
    -  let links_with_captions = s:read_captions(files)
    -
    -  return links_with_captions
    +  return files
     endfun "}}}
     
     fun! s:group_links(links) "{{{
    @@ -129,7 +127,9 @@ endfunction "}}}
     function! s:format_diary() "{{{
       let result = []
     
    -  let g_files = s:group_links(s:get_diary_links())
    +
    +  let links_with_captions = s:read_captions(s:get_diary_files())
    +  let g_files = s:group_links(links_with_captions)
     
       for year in s:sort(keys(g_files))
         call add(result, '')
    
    From 8cdc1c15388cc7f4edb827ff15dbc31d592a79af Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 15 Apr 2017 21:22:21 +0200
    Subject: [PATCH 16/93] Don't throw an error when typing o
    
    Ref #255
    ---
     ftplugin/vimwiki.vim | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
    index 3390b06..9262c5e 100644
    --- a/ftplugin/vimwiki.vim
    +++ b/ftplugin/vimwiki.vim
    @@ -478,8 +478,8 @@ if !hasmapto('VimwikiListToggle', 'i')
     endif
     inoremap 
    -
    -2. installing MathJax locally (faster, no internet required). Choose a
    -folder on your hard drive and save MathJax in it. Then add to your HTML
    -template the following line:
    +1. installing MathJax locally (Recommended: faster, no internet required).
    +Choose a folder on your hard drive and save MathJax in it. Then add to your
    +HTML template the following line:
     
     
     
    @@ -1255,6 +1250,11 @@ template folder. For instance, a sensible folder structure could be:
     
     In this case,  would be "../mathjax" (without quotes).
     
    +2. Loading MathJax from a CDN-server (needs internet connection).
    +Add to your HTML template the following line:
    +
    +
    +
     
     ------------------------------------------------------------------------------
     5.9. Blockquotes                                  *vimwiki-syntax-blockquotes*
    
    From 37e4dfc2883c0dec5862df128e7f421e0795ce03 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Sun, 17 Sep 2017 01:10:14 +0100
    Subject: [PATCH 37/93] Add License-File
    
    Vimwiki currently has not License-File, and the license is only mentioned in the help-file. We should change this.
    ---
     LICENSE | 21 +++++++++++++++++++++
     1 file changed, 21 insertions(+)
     create mode 100644 LICENSE
    
    diff --git a/LICENSE b/LICENSE
    new file mode 100644
    index 0000000..be93eec
    --- /dev/null
    +++ b/LICENSE
    @@ -0,0 +1,21 @@
    +MIT License
    +
    +Copyright (c) 2008-2010 Maxim Kim
    +
    +Permission is hereby granted, free of charge, to any person obtaining a copy
    +of this software and associated documentation files (the "Software"), to deal
    +in the Software without restriction, including without limitation the rights
    +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +copies of the Software, and to permit persons to whom the Software is
    +furnished to do so, subject to the following conditions:
    +
    +The above copyright notice and this permission notice shall be included in all
    +copies or substantial portions of the Software.
    +
    +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    +SOFTWARE.
    
    From 742fc996928e6aa2f2053848aa151fdcccd0dfac Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Wed, 25 Oct 2017 02:11:01 +0200
    Subject: [PATCH 38/93] Add Copyright-attribution to Daniel Schemala
    
    ---
     LICENSE         | 1 +
     doc/vimwiki.txt | 1 +
     2 files changed, 2 insertions(+)
    
    diff --git a/LICENSE b/LICENSE
    index be93eec..cdf8546 100644
    --- a/LICENSE
    +++ b/LICENSE
    @@ -1,6 +1,7 @@
     MIT License
     
     Copyright (c) 2008-2010 Maxim Kim
    +              2013-2017 Daniel Schemala
     
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 6b89238..c5b227b 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -3105,6 +3105,7 @@ The MIT Licence
     http://www.opensource.org/licenses/mit-license.php
     
     Copyright (c) 2008-2010 Maxim Kim
    +              2013-2017 Daniel Schemala
     
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
    
    From ec3d554c0b824f0e10f455b17645d6a722520c5d Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Wed, 25 Oct 2017 13:10:23 +0200
    Subject: [PATCH 39/93] Update list of contributers
    
    ---
     doc/vimwiki.txt | 13 +++++++++++++
     1 file changed, 13 insertions(+)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index c5b227b..06f95b8 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -2854,6 +2854,19 @@ Contributors and their Github usernames in roughly chronological order:
         - @wangzq
         - Jinzhou Zhang (@lotabout)
         - Michael Riley (@optik-aper)
    +    - Irfan Sharif (@irfansharif)
    +    - John Conroy (@jconroy77)
    +    - Christian Rondeau (@christianrondeau)
    +    - Alex Thorne (@thornecc)
    +    - Shafqat Bhuiyan (@priomsrb)
    +    - Bradley Cicenas (@bcicen)
    +    - Michael Thessel (@MichaelThessel)
    +    - Michael F. Schönitzer (@nudin)
    +    - @sqlwwx
    +    - Guilherme Salazar (@salazar)
    +    - Daniel Trnka (@trnila)
    +    - Yuchen Pei (@ycpei)
    +    - @maqiv
     
     
     ==============================================================================
    
    From cf8e3e731929b872d154d631d5b067e4c100cc84 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Wed, 25 Oct 2017 13:45:00 +0200
    Subject: [PATCH 40/93] Unified spelling Licence -> License
    
    ---
     doc/vimwiki.txt | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
    index 06f95b8..323ccfe 100644
    --- a/doc/vimwiki.txt
    +++ b/doc/vimwiki.txt
    @@ -3114,7 +3114,7 @@ http://code.google.com/p/vimwiki/issues/list
     ==============================================================================
     16. License                                                  *vimwiki-license*
     
    -The MIT Licence
    +The MIT License
     http://www.opensource.org/licenses/mit-license.php
     
     Copyright (c) 2008-2010 Maxim Kim
    
    From d9a73b71173b418bc1ae64217aa4e2c65272541f Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Dawid=20Ci=C4=99=C5=BCarkiewicz?= 
    Date: Sat, 14 Oct 2017 23:12:47 -0700
    Subject: [PATCH 41/93] Fix diary index generation with custom file extensions
    
    Fix #302
    ---
     autoload/vimwiki/diary.vim | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
    index fcd176a..d6cd9e9 100644
    --- a/autoload/vimwiki/diary.vim
    +++ b/autoload/vimwiki/diary.vim
    @@ -65,7 +65,7 @@ fun! s:read_captions(files) "{{{
       let result = {}
       for fl in a:files
         " remove paths and extensions
    -    let fl_key = fnamemodify(fl, ':t:r')
    +    let fl_key = substitute(fnamemodify(fl, ':t'), VimwikiGet('ext').'$', '', '')
     
         if filereadable(fl)
           for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
    
    From eed4ceff1af6ae11f33ee589f7bf099fdc62fdd5 Mon Sep 17 00:00:00 2001
    From: Drew Hays 
    Date: Thu, 17 Aug 2017 23:53:40 -0700
    Subject: [PATCH 42/93] Escape the 'dot' in extension substitution
    
    This escapes the `.` preceding an extension (e.g. `.wiki`) so that it doesn't accidentally match any character.
    
    For example: `[vimwiki](vimwiki)` was opening the `vi.wiki` page, because of this rule.
    ---
     autoload/vimwiki/base.vim | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 0cd537a..4e3cde5 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1273,7 +1273,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
     
           " remove the extension from the filename if exists, because non-vimwiki
           " markdown files usually include the extension in links
    -      let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '')
    +      let lnk = substitute(lnk, '\'.VimwikiGet('ext').'$', '', '')
         endif
     
         let current_tab_page = tabpagenr()
    
    From 293e1f51eecfe93b9e519a5b10e059edf835ac35 Mon Sep 17 00:00:00 2001
    From: Daniel 
    Date: Sun, 18 Dec 2016 13:02:51 -0600
    Subject: [PATCH 43/93] Added the option to open vimwiki in a pane.
    
    1       tabedit
    2       split
    3       vsplit
    
    Similar to opening a tab,::
    
    vimwiki#base#goto_index(v:count1, 1)
    
    we can now open a split with::
    
    vimwiki#base#goto_index(v:count1, 2)
    
    and a vertical split with::
    
    vimwiki#base#goto_index(v:count1, 3)
    ---
     autoload/vimwiki/base.vim | 6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 4e3cde5..a246081 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1325,8 +1325,12 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
         let idx = 0
       endif
     
    -  if a:0
    +  if a:0 == 1
         let cmd = 'tabedit'
    +  elseif a:0 == 2
    +    let cmd = 'sp'
    +  elseif a:0 == 3
    +    let cmd = 'vsp'
       else
         let cmd = 'edit'
       endif
    
    From 734d0143675e64966881ee62f89391d3c2b4c06d Mon Sep 17 00:00:00 2001
    From: Daniel 
    Date: Sun, 18 Dec 2016 13:02:51 -0600
    Subject: [PATCH 44/93] Added the option to open vimwiki in a pane.
    
    1       tabedit
    2       split
    3       vsplit
    
    Similar to opening a tab,::
    
    vimwiki#base#goto_index(1, 1)
    
    we can now open a split with::
    
    vimwiki#base#goto_index(1, 2)
    
    and a vertical split with::
    
    vimwiki#base#goto_index(1, 3)
    ---
     autoload/vimwiki/base.vim | 12 +++++++-----
     1 file changed, 7 insertions(+), 5 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index a246081..07e3e72 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1325,16 +1325,18 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
         let idx = 0
       endif
     
    -  if a:0 == 1
    +  if a:1 == 1
         let cmd = 'tabedit'
    -  elseif a:0 == 2
    -    let cmd = 'sp'
    -  elseif a:0 == 3
    -    let cmd = 'vsp'
    +  elseif a:1 == 2
    +    let cmd = 'split'
    +  elseif a:1 == 3
    +    let cmd = 'vsplit'
       else
         let cmd = 'edit'
       endif
     
    +  echomsg 'Passed argument '.a:0.'. Using cmd '.cmd
    +
       call Validate_wiki_options(idx)
       call vimwiki#base#edit_file(cmd,
             \ VimwikiGet('path', idx).VimwikiGet('index', idx).
    
    From 95d4c095d0a615c9586df49d3bc0eedec8e4ea4d Mon Sep 17 00:00:00 2001
    From: Daniel 
    Date: Sun, 18 Dec 2016 13:02:51 -0600
    Subject: [PATCH 45/93] Added the option to open vimwiki in a pane.
    
    1       tabedit
    2       split
    3       vsplit
    
    Similar to opening a tab,::
    
    vimwiki#base#goto_index(v:count1, 1)
    
    we can now open a split with::
    
    vimwiki#base#goto_index(v:count1, 2)
    
    and a vertical split with::
    
    vimwiki#base#goto_index(v:count1, 3)
    ---
     autoload/vimwiki/base.vim | 2 --
     1 file changed, 2 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 07e3e72..ecc322b 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1335,8 +1335,6 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
         let cmd = 'edit'
       endif
     
    -  echomsg 'Passed argument '.a:0.'. Using cmd '.cmd
    -
       call Validate_wiki_options(idx)
       call vimwiki#base#edit_file(cmd,
             \ VimwikiGet('path', idx).VimwikiGet('index', idx).
    
    From 02e32489d7652189026c1d4b48bf88b6da98a739 Mon Sep 17 00:00:00 2001
    From: Daniel 
    Date: Sun, 18 Dec 2016 13:02:51 -0600
    Subject: [PATCH 46/93] Added the option to open vimwiki in a pane.
    
    1       tabedit
    2       split
    3       vsplit
    
    Similar to opening a tab,::
    
    vimwiki#base#goto_index(v:count1, 1)
    
    we can now open a split with::
    
    vimwiki#base#goto_index(v:count1, 2)
    
    and a vertical split with::
    
    vimwiki#base#goto_index(v:count1, 3)
    ---
     autoload/vimwiki/base.vim | 14 ++++++++------
     1 file changed, 8 insertions(+), 6 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index ecc322b..6f81453 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -1325,12 +1325,14 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
         let idx = 0
       endif
     
    -  if a:1 == 1
    -    let cmd = 'tabedit'
    -  elseif a:1 == 2
    -    let cmd = 'split'
    -  elseif a:1 == 3
    -    let cmd = 'vsplit'
    +  if a:0
    +    if a:1 == 1
    +      let cmd = 'tabedit'
    +    elseif a:1 == 2
    +      let cmd = 'split'
    +    elseif a:1 == 3
    +      let cmd = 'vsplit'
    +    endif
       else
         let cmd = 'edit'
       endif
    
    From b6d47e894d78bc9589a11cde501093fa04da1941 Mon Sep 17 00:00:00 2001
    From: Daniel Etrata 
    Date: Mon, 6 Nov 2017 21:08:52 -0600
    Subject: [PATCH 47/93] Give vimwiki#diary#make_note similar functionality
    
    ---
     autoload/vimwiki/diary.vim | 10 ++++++++--
     1 file changed, 8 insertions(+), 2 deletions(-)
    
    diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
    index d6cd9e9..2bc702b 100644
    --- a/autoload/vimwiki/diary.vim
    +++ b/autoload/vimwiki/diary.vim
    @@ -174,8 +174,14 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
     
       call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
     
    -  if a:0 && a:1 == 1
    -    let cmd = 'tabedit'
    +  if a:0
    +    if a:1 == 1
    +      let cmd = 'tabedit'
    +    elseif a:2 == 2
    +      let cmd = 'split'
    +    elseif a:3 == 3
    +      let cmd = 'vsplit'
    +    endif
       else
         let cmd = 'edit'
       endif
    
    From 91c382a034062e23571058f6b4cc9976016906af Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Fri, 10 Nov 2017 22:28:33 +0100
    Subject: [PATCH 48/93] Use a safe substitution-function everywhere
    
    ---
     autoload/vimwiki/base.vim          | 47 +++++++++++++++++-------------
     autoload/vimwiki/markdown_base.vim | 11 +++++--
     2 files changed, 36 insertions(+), 22 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 6f81453..62140ab 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -8,6 +8,13 @@ if exists("g:loaded_vimwiki_auto") || &cp
     endif
     let g:loaded_vimwiki_auto = 1
     
    +" s:safesubstitute
    +function! s:safesubstitute(text, search, replace, mode) "{{{
    +  " Substitute regexp but do not interpret replace
    +  let escaped = escape(a:replace, '\&')
    +  return substitute(a:text, a:search, escaped, a:mode)
    +endfunction " }}}
    +
     " s:vimwiki_get_known_syntaxes
     function! s:vimwiki_get_known_syntaxes() " {{{
       " Getting all syntaxes that different wikis could have
    @@ -465,7 +472,7 @@ function! vimwiki#base#generate_links() "{{{
         let abs_filepath = vimwiki#path#abs_path_of_link(link)
         if !s:is_diary_file(abs_filepath)
           call add(lines, bullet.
    -            \ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".link."'", ''))
    +            \ s:safesubstitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', link, ''))
         endif
       endfor
     
    @@ -677,13 +684,13 @@ function! s:jump_to_anchor(anchor) "{{{
       let segments = split(anchor, '#', 0)
       for segment in segments
     
    -    let anchor_header = substitute(
    +    let anchor_header = s:safesubstitute(
               \ g:vimwiki_{VimwikiGet('syntax')}_header_match,
    -          \ '__Header__', "\\='".segment."'", '')
    -    let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
    -          \ '__Text__', "\\='".segment."'", '')
    -    let anchor_tag = substitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match,
    -          \ '__Tag__', "\\='".segment."'", '')
    +          \ '__Header__', segment, '')
    +    let anchor_bold = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
    +          \ '__Text__', segment, '')
    +    let anchor_tag = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match,
    +          \ '__Tag__', segment, '')
     
         if         !search(anchor_tag, 'Wc')
               \ && !search(anchor_header, 'Wc')
    @@ -1176,8 +1183,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
     
       " write new listing
       let new_header = whitespaces_in_first_line
    -        \ . substitute(g:vimwiki_rxH1_Template,
    -        \ '__Header__', '\='."'".a:start_header."'", '')
    +        \ . s:safesubstitute(g:vimwiki_rxH1_Template,
    +        \ '__Header__', a:start_header, '')
       call append(start_lnum - 1, new_header)
       let start_lnum += 1
       let lines_diff += 1 + len(a:strings)
    @@ -1832,9 +1839,9 @@ function! vimwiki#base#table_of_contents(create)
       for [lvl, link, desc] in headers
         let esc_link = substitute(link, "'", "''", 'g')
         let esc_desc = substitute(desc, "'", "''", 'g')
    -    let link = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__',
    -          \ '\='."'".'#'.esc_link."'", '')
    -    let link = substitute(link, '__LinkDescription__', '\='."'".esc_desc."'", '')
    +    let link = s:safesubstitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__',
    +          \ '#'.esc_link, '')
    +    let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '')
         call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
       endfor
     
    @@ -1855,13 +1862,13 @@ endfunction
     function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
       let lnk = a:template
       if a:rxUrl != ""
    -    let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", 'g')
    +    let lnk = s:safesubstitute(lnk, '__LinkUrl__', a:rxUrl, 'g')
       endif
       if a:rxDesc != ""
    -    let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", 'g')
    +    let lnk = s:safesubstitute(lnk, '__LinkDescription__', a:rxDesc, 'g')
       endif
       if a:rxStyle != ""
    -    let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", 'g')
    +    let lnk = s:safesubstitute(lnk, '__LinkStyle__', a:rxStyle, 'g')
       endif
       return lnk
     endfunction " }}}
    @@ -1900,8 +1907,8 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
       if descr == ""
         let descr = s:clean_url(url)
       endif
    -  let lnk = substitute(template, '__LinkDescription__', '\="'.descr.'"', '')
    -  let lnk = substitute(lnk, '__LinkUrl__', '\="'.url.'"', '')
    +  let lnk = s:safesubstitute(template, '__LinkDescription__', descr, '')
    +  let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
       return lnk
     endfunction " }}}
     
    @@ -1909,7 +1916,7 @@ endfunction " }}}
     function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{
       let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template)
       let style = matchstr(a:str, a:rxStyle)
    -  let lnk = substitute(lnk, '__LinkStyle__', '\="'.style.'"', '')
    +  let lnk = s:safesubstitute(lnk, '__LinkStyle__', style, '')
       return lnk
     endfunction " }}}
     
    @@ -2001,8 +2008,8 @@ function! s:normalize_link_syntax_v() " {{{
         if s:is_diary_file(expand("%:p"))
           let sub = s:normalize_link_in_diary(@")
         else
    -      let sub = substitute(g:vimwiki_WikiLinkTemplate1,
    -            \ '__LinkUrl__', '\=' . "'" . @" . "'", '')
    +      let sub = s:safesubstitute(g:vimwiki_WikiLinkTemplate1,
    +            \ '__LinkUrl__', @", '')
         endif
     
         " Put substitution in register " and change text
    diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
    index 06477d8..01f2c96 100644
    --- a/autoload/vimwiki/markdown_base.vim
    +++ b/autoload/vimwiki/markdown_base.vim
    @@ -6,6 +6,13 @@
     
     " MISC helper functions {{{
     
    +" s:safesubstitute
    +function! s:safesubstitute(text, search, replace, mode) "{{{
    +  " Substitute regexp but do not interpret replace
    +  let escaped = escape(a:replace, '\&')
    +  return substitute(a:text, a:search, escaped, a:mode)
    +endfunction " }}}
    +
     " vimwiki#markdown_base#reset_mkd_refs
     function! vimwiki#markdown_base#reset_mkd_refs() "{{{
       call VimwikiClear('markdown_refs')
    @@ -139,8 +146,8 @@ function! s:normalize_link_syntax_v() " {{{
       try
         norm! gvy
         let visual_selection = @"
    -    let link = substitute(g:vimwiki_Weblink1Template, '__LinkUrl__', '\='."'".visual_selection."'", '')
    -    let link = substitute(link, '__LinkDescription__', '\='."'".visual_selection."'", '')
    +    let link = Safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '')
    +    let link = Safesubstitute(link, '__LinkDescription__', visual_selection, '')
     
         call setreg('"', link, 'v')
     
    
    From 074d8827620c0d1d0535f21808862659c611ceb1 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Sat, 4 Nov 2017 03:26:33 +0100
    Subject: [PATCH 49/93] Allow Backtick in Link
    
    ---
     autoload/vimwiki/base.vim | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 6f81453..9fdfaf5 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -840,7 +840,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
       " then
       " [[test*file]]...
       " you'll have E77: Too many file names
    -  let fname = escape(a:filename, '% *|#')
    +  let fname = escape(a:filename, '% *|#`')
       let dir = fnamemodify(a:filename, ":p:h")
     
       let ok = vimwiki#path#mkdir(dir, 1)
    
    From 4e16db926f86ebcd068bd3b2c65ba36ff1fed463 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 11 Nov 2017 21:52:07 +0100
    Subject: [PATCH 50/93] Fix more regression bugs
    
    ---
     autoload/vimwiki/base.vim |  8 ++++++--
     autoload/vimwiki/vars.vim | 13 ++++++++-----
     ftplugin/vimwiki.vim      |  3 ++-
     plugin/vimwiki.vim        |  7 ++++---
     syntax/vimwiki.vim        |  4 +++-
     5 files changed, 23 insertions(+), 12 deletions(-)
    
    diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
    index 6a87cf4..4bc45af 100644
    --- a/autoload/vimwiki/base.vim
    +++ b/autoload/vimwiki/base.vim
    @@ -378,7 +378,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
       " if current wiki is temporary -- was added by an arbitrary wiki file then do
       " not search wiki files in subdirectories. Or it would hang the system if
       " wiki file was created in $HOME or C:/ dirs.
    -  if vimwiki#vars#get_wikilocal('temp', wiki_nr)
    +  if vimwiki#vars#get_wikilocal('is_temporary_wiki', wiki_nr)
         let pattern = '*'.ext
       else
         let pattern = '**/*'.ext
    @@ -707,11 +707,15 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
       " getpos() directly after this command. Strange.
       if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p')))
         execute a:command.' '.fname
    +
    +    " If the opened file was not already loaded by Vim, an autocommand is
    +    " triggered at this point
    +
         " Make sure no other plugin takes ownership over the new file. Vimwiki
         " rules them all! Well, except for directories, which may be opened with
         " Netrw
         if &filetype != 'vimwiki' && fname !~ '\m/$'
    -      set filetype=vimwiki
    +      setfiletype vimwiki
         endif
       endif
       if a:anchor != ''
    diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
    index 2872796..93e77ba 100644
    --- a/autoload/vimwiki/vars.vim
    +++ b/autoload/vimwiki/vars.vim
    @@ -192,6 +192,7 @@ function! s:populate_wikilocal_options()
     
       let g:vimwiki_wikilocal_vars = []
     
    +  " set the wiki-local variables according to g:vimwiki_list (or the default settings)
       if exists('g:vimwiki_list')
         for users_options in g:vimwiki_list
           let new_wiki_settings = {}
    @@ -205,8 +206,7 @@ function! s:populate_wikilocal_options()
             endif
           endfor
     
    -      " is it a temporary wiki? No, it's not.
    -      let new_wiki_settings.temp = 0
    +      let new_wiki_settings.is_temporary_wiki = 0
     
           call add(g:vimwiki_wikilocal_vars, new_wiki_settings)
         endfor
    @@ -221,7 +221,7 @@ function! s:populate_wikilocal_options()
           let temporary_options_dict[key] = default_values[key]
         endif
       endfor
    -  let temporary_options_dict.temp = 1
    +  let temporary_options_dict.is_temporary_wiki = 1
       call add(g:vimwiki_wikilocal_vars, temporary_options_dict)
     
       call s:validate_settings()
    @@ -250,10 +250,13 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
       if !exists('g:vimwiki_syntax_variables')
         let g:vimwiki_syntax_variables = {}
       endif
    -  if !has_key(g:vimwiki_syntax_variables, a:syntax)
    -    let g:vimwiki_syntax_variables[a:syntax] = {}
    +
    +  if has_key(g:vimwiki_syntax_variables, a:syntax)
    +    return
       endif
     
    +  let g:vimwiki_syntax_variables[a:syntax] = {}
    +
       execute 'runtime! syntax/vimwiki_'.a:syntax.'.vim'
     
       " generic stuff
    diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
    index e5763f3..af6758b 100644
    --- a/ftplugin/vimwiki.vim
    +++ b/ftplugin/vimwiki.vim
    @@ -13,7 +13,8 @@ let b:did_ftplugin = 1  " Don't load another plugin for this buffer
     let b:undo_ftplugin = "setlocal ".
           \ "suffixesadd< isfname< formatlistpat< ".
           \ "formatoptions< foldtext< ".
    -      \ "foldmethod< foldexpr< commentstring< "
    +      \ "foldmethod< foldexpr< commentstring< tags< omnifunc< autoindent< ".
    +      \ "smartindent< cindent< comments< formatoptions<"
     " UNDO }}}
     
     " MISC STUFF {{{
    diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
    index 13797f8..0c25daf 100644
    --- a/plugin/vimwiki.vim
    +++ b/plugin/vimwiki.vim
    @@ -61,8 +61,9 @@ function! s:setup_new_wiki_buffer() "{{{
         endif
       endif
     
    -  " this makes that ftplugin/vimwiki.vim is sourced
    -  set filetype=vimwiki
    +  " this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
    +  " sourced
    +  setfiletype vimwiki
     
       " to force a rescan of the filesystem which may have changed
       " and update VimwikiLinks syntax group that depends on it;
    @@ -86,7 +87,7 @@ function! s:setup_buffer_enter() "{{{
       let &autowriteall = vimwiki#vars#get_global('autowriteall')
     
       if &filetype == ''
    -    set filetype=vimwiki
    +    setfiletype vimwiki
       elseif &syntax ==? 'vimwiki'
         " to force a rescan of the filesystem which may have changed
         " and update VimwikiLinks syntax group that depends on it;
    diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim
    index b6f6d48..0981aee 100644
    --- a/syntax/vimwiki.vim
    +++ b/syntax/vimwiki.vim
    @@ -311,7 +311,9 @@ if vimwiki#vars#get_global('hl_headers') == 0
       endfor
     else
       for s:i in range(1,6)
    -    execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='.vimwiki#vars#get_global('hcolor_guifg_'.&bg)[s:i-1].' gui=bold ctermfg='.vimwiki#vars#get_global('ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
    +    execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg='
    +          \ .vimwiki#vars#get_global('hcolor_guifg_'.&bg)[s:i-1].' gui=bold ctermfg='
    +          \ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold'
       endfor
     endif
     "}}}
    
    From c94af4b3f17711b068fa67814bcdeeda5a785181 Mon Sep 17 00:00:00 2001
    From: Keith Haber 
    Date: Tue, 14 Nov 2017 22:57:52 -0800
    Subject: [PATCH 51/93] Update argument handling in diary#make_note
    
    Fix an "Undefined variable: a:3" error that occurs when attempting to open
    a diary page with Calendar.vim.
    ---
     autoload/vimwiki/diary.vim | 7 +++----
     1 file changed, 3 insertions(+), 4 deletions(-)
    
    diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim
    index 2bc702b..109ae07 100644
    --- a/autoload/vimwiki/diary.vim
    +++ b/autoload/vimwiki/diary.vim
    @@ -174,16 +174,15 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
     
       call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
     
    +  let cmd = 'edit'
       if a:0
         if a:1 == 1
           let cmd = 'tabedit'
    -    elseif a:2 == 2
    +    elseif a:1 == 2
           let cmd = 'split'
    -    elseif a:3 == 3
    +    elseif a:1 == 3
           let cmd = 'vsplit'
         endif
    -  else
    -    let cmd = 'edit'
       endif
       if a:0>1
         let link = 'diary:'.a:2
    
    From 75fe1d4f003f77a33955f436e023a4ce9548cb69 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Michael=20F=2E=20Sch=C3=B6nitzer?= 
    Date: Mon, 4 Dec 2017 16:24:51 +0100
    Subject: [PATCH 52/93] Fix bug: unknown function SafeSubstitute
    
    ---
     autoload/vimwiki/markdown_base.vim | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
    index 01f2c96..41664e3 100644
    --- a/autoload/vimwiki/markdown_base.vim
    +++ b/autoload/vimwiki/markdown_base.vim
    @@ -146,8 +146,8 @@ function! s:normalize_link_syntax_v() " {{{
       try
         norm! gvy
         let visual_selection = @"
    -    let link = Safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '')
    -    let link = Safesubstitute(link, '__LinkDescription__', visual_selection, '')
    +    let link = s:safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '')
    +    let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
     
         call setreg('"', link, 'v')
     
    
    From 68ad4675a3f740f9ad116308a4230775b14ddf35 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 10 Feb 2018 21:41:07 +0100
    Subject: [PATCH 53/93] Remove b:undo_ftplugin to speed up buffer loading
    
    If this variable is present, then for some reason the complete ftplugin
    file is sourced everytime a Vimwiki buffer is entered, even if the
    buffer has been entered before, i.e. the guard b:did_ftplugin has no
    effect. (See /usr/share/vimXX/ftplugin.vim)
    Deleting these lines. I don't think undoing the settings is a common use
    case, anyway.
    ---
     ftplugin/vimwiki.vim | 9 ---------
     1 file changed, 9 deletions(-)
    
    diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
    index af6758b..b75ea1f 100644
    --- a/ftplugin/vimwiki.vim
    +++ b/ftplugin/vimwiki.vim
    @@ -8,15 +8,6 @@ endif
     let b:did_ftplugin = 1  " Don't load another plugin for this buffer
     
     
    -" UNDO list {{{
    -" Reset the following options to undo this plugin.
    -let b:undo_ftplugin = "setlocal ".
    -      \ "suffixesadd< isfname< formatlistpat< ".
    -      \ "formatoptions< foldtext< ".
    -      \ "foldmethod< foldexpr< commentstring< tags< omnifunc< autoindent< ".
    -      \ "smartindent< cindent< comments< formatoptions<"
    -" UNDO }}}
    -
     " MISC STUFF {{{
     
     setlocal commentstring=%%%s
    
    From 967b342b23f421d4d467b647d605f2c1577d4d04 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Sat, 10 Feb 2018 22:04:37 +0100
    Subject: [PATCH 54/93] Formatting
    
    ---
     plugin/vimwiki.vim |  5 ++++-
     syntax/vimwiki.vim | 17 ++++++++++-------
     2 files changed, 14 insertions(+), 8 deletions(-)
    
    diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
    index 0c25daf..c48a9aa 100644
    --- a/plugin/vimwiki.vim
    +++ b/plugin/vimwiki.vim
    @@ -83,6 +83,9 @@ function! s:setup_buffer_enter() "{{{
         return
       endif
     
    +  " 'autowriteall' is a global Vim option, so in order to change it only for
    +  " Vimwiki buffers, we need to set it here (when the cursor enters the buffer)
    +  " and reset it when the cursor leaves the buffer
       let s:vimwiki_autowriteall_saved = &autowriteall
       let &autowriteall = vimwiki#vars#get_global('autowriteall')
     
    @@ -166,7 +169,7 @@ endfunction " }}}
     
     
     " Initialization of Vimwiki starts here. Make sure everything below does not
    -" cause autoload/base to be loaded
    +" cause autoload/vimwiki/base.vim to be loaded
     
     call vimwiki#vars#init()
     
    diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim
    index 0981aee..44c07fe 100644
    --- a/syntax/vimwiki.vim
    +++ b/syntax/vimwiki.vim
    @@ -3,7 +3,7 @@
     " Home: https://github.com/vimwiki/vimwiki/
     
     " Quit if syntax file is already loaded
    -if version < 600
    +if v:version < 600
       syntax clear
     elseif exists("b:current_syntax")
       finish
    @@ -132,10 +132,12 @@ call s:add_target_syntax_ON(s:target, 'VimwikiLink')
     
     " Header levels, 1-6
     for s:i in range(1,6)
    -  
    -  execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
    -  execute 'syntax region VimwikiH'.s:i.'Folding start=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).
    -        \ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).'/me=s-1 transparent fold'
    +  execute 'syntax match VimwikiHeader'.s:i
    +      \ . ' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i, s:current_syntax).'/'
    +      \ . ' contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
    +  execute 'syntax region VimwikiH'.s:i.'Folding'
    +        \ . ' start=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_Start', s:current_syntax).'/'
    +        \ . ' end=/'.vimwiki#vars#get_syntaxlocal('rxH'.s:i.'_End', s:current_syntax).'/me=s-1 transparent fold'
     endfor
     
     
    @@ -233,8 +235,9 @@ execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine'
     execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_syntaxlocal('rxListItem').'/'
     
     if vimwiki#vars#get_global('hl_cb_checked') == 1
    -  execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'\s*\['.vimwiki#vars#get_syntaxlocal('listsyms_list')[4].'\]\s.*$/ '.
    -        \ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
    +  execute 'syntax match VimwikiCheckBoxDone '
    +        \ . ' /'.vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB').'\s*\['.vimwiki#vars#get_syntaxlocal('listsyms_list')[4].'\]\s.*$/'
    +        \ . ' contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
     elseif vimwiki#vars#get_global('hl_cb_checked') == 2
       execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_syntaxlocal('rxListItemAndChildren').'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
     endif
    
    From f48dce6f1d57246e05f0fc548a977e8136eb4ab4 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Wed, 14 Feb 2018 06:53:46 +0100
    Subject: [PATCH 55/93] Refactor then updating of the known wiki pages
    
    for the 'maxhi' option.
    ---
     autoload/vimwiki/vars.vim |  2 --
     plugin/vimwiki.vim        | 21 ++++++---------------
     2 files changed, 6 insertions(+), 17 deletions(-)
    
    diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
    index 93e77ba..ca45020 100644
    --- a/autoload/vimwiki/vars.vim
    +++ b/autoload/vimwiki/vars.vim
    @@ -566,8 +566,6 @@ function! vimwiki#vars#get_bufferlocal(key, ...)
             \ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
       elseif a:key ==# 'prev_link'
         call setbufvar(buffer, 'vimwiki_prev_link', [])
    -  elseif a:key ==# 'fs_rescan'
    -    call setbufvar(buffer, 'vimwiki_fs_rescan', 0)
       elseif a:key ==# 'markdown_refs'
         call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks())
       else
    diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
    index c48a9aa..8f7fa87 100644
    --- a/plugin/vimwiki.vim
    +++ b/plugin/vimwiki.vim
    @@ -61,17 +61,16 @@ function! s:setup_new_wiki_buffer() "{{{
         endif
       endif
     
    +  if vimwiki#vars#get_wikilocal('maxhi')
    +    call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1))
    +    call vimwiki#vars#set_bufferlocal('existing_wikidirs',
    +          \ vimwiki#base#get_wiki_directories(wiki_nr))
    +  endif
    +
       " this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
       " sourced
       setfiletype vimwiki
     
    -  " to force a rescan of the filesystem which may have changed
    -  " and update VimwikiLinks syntax group that depends on it;
    -  " 'fs_rescan' indicates that setup_filetype() has not been run
    -  if vimwiki#vars#get_bufferlocal('fs_rescan') == 1 && vimwiki#vars#get_wikilocal('maxhi')
    -    set syntax=vimwiki
    -  endif
    -  call vimwiki#vars#set_bufferlocal('fs_rescan', 1)
     endfunction "}}}
     
     
    @@ -91,14 +90,6 @@ function! s:setup_buffer_enter() "{{{
     
       if &filetype == ''
         setfiletype vimwiki
    -  elseif &syntax ==? 'vimwiki'
    -    " to force a rescan of the filesystem which may have changed
    -    " and update VimwikiLinks syntax group that depends on it;
    -    " 'fs_rescan' indicates that setup_filetype() has not been run
    -    if vimwiki#vars#get_bufferlocal('fs_rescan') == 1 && vimwiki#vars#get_wikilocal('maxhi')
    -      set syntax=vimwiki
    -    endif
    -    call vimwiki#vars#set_bufferlocal('fs_rescan', 1)
       endif
     
       " The settings foldmethod, foldexpr and foldtext are local to window. Thus in
    
    From 5419fad3f75f57c47a34671b0f1f03db8d79de03 Mon Sep 17 00:00:00 2001
    From: EinfachToll 
    Date: Thu, 15 Feb 2018 18:38:39 +0100
    Subject: [PATCH 56/93] Formatting and small refactorings
    
    ---
     autoload/vimwiki/vars.vim | 214 +++++++++++++++++++++++++-------------
     doc/vimwiki.txt           |  12 +--
     ftplugin/vimwiki.vim      |  15 ++-
     plugin/vimwiki.vim        |  97 +++++++++--------
     4 files changed, 208 insertions(+), 130 deletions(-)
    
    diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
    index ca45020..36fb9f5 100644
    --- a/autoload/vimwiki/vars.vim
    +++ b/autoload/vimwiki/vars.vim
    @@ -1,12 +1,31 @@
     " vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
     " Vimwiki autoload plugin file
    -" Desc: stuff concerning Vimwiki's state
     " Home: https://github.com/vimwiki/vimwiki/
     
    +" ------------------------------------------------------------------------------------------------
    +" This file provides functions to manage the various state variables which are needed during a
    +" Vimwiki session.
    +" They consist of:
    +"
    +" - global variables. These are stored in the dict g:vimwiki_global_vars. They consist mainly of
    +"   global user variables and syntax stuff which is the same for every syntax.
    +"
    +" - wiki-local variables. They are stored in g:vimwiki_wikilocal_vars which is a list of
    +"   dictionaries. One dict for every registered wiki. The last dictionary contains default values
    +"   (used for temporary wikis).
    +"
    +" - syntax variables. Stored in the dict g:vimwiki_syntax_variables which holds all the regexes and
    +"   other stuff which is needed for highlighting.
    +"
    +" - buffer-local variables. They are stored as buffer variables directly (b:foo)
    +
    +" As a developer, you should, if possible, only use the get_ and set_ functions for these types of
    +" variables, not the underlying dicts!
    +" ------------------------------------------------------------------------------------------------
    +
     
    -" copy the user's settings from variables of the form g:vimwiki_