Closed GoogleCodeExporter closed 9 years ago
@Maxim: Orphan wikis are working for me. Are you using the latest version?
I have added a note ("TODO: refactor") around the copied/duplicated code in
setup_filetype() and setup_buffer_enter().
Here's some session information with explanation for you to inspect. Hint: it
reads better in vimwiki!
-----------------------------
* Setup
* Install r6dad432a64c5
* Open vim
* Notice that I have only one wiki registered in `g:vimwiki_list`
* `:echo g:vimwiki_list`
{{{ vim
[{
'maxhi' : 1,
'css_name' : 'style.css',
'auto_export' : 0,
'diary_index' : 'LogBook',
'template_default' : '',
'nested_syntaxes' : {'vim': 'vim', 'css': 'css', 'R': 'R', 'javascript': 'javascript', 'xml': 'html', 'sh': 'sh', 'ascript': 'applescript', 'html': 'html', 'ruby': 'ruby', 'jscript': 'javascript', 'objc': 'objc', 'c++': 'cpp', 'python': 'python', 'bash': 'sh'},
'diary_sort' : 'desc',
'path' : '$NOTES/Notes/',
'diary_link_fmt' : '%Y-%m-%d',
'template_ext' : '',
'syntax' : 'markdown',
'custom_wiki2html' : '$BIN/trunk2html_wrapper.sh',
'index' : 'WikiIndex',
'diary_header' : 'Entries',
'ext' : '.md',
'path_html' : '$NOTES/Html/',
'temp' : 0,
'template_path' : '',
'diary_rel_path' : ''
}]
}}}
* Also, notice that I have initialized a mapping that associates extensions with a default syntax (see ":help ext2syntax")
* `:echo g:vimwiki_ext2syntax`
{{{ vim
{'.markdown': 'markdown', '.md': 'markdown', '.mkd': 'markdown', '.wiki': 'default'}
}}}
* Now, let's open my main page.
* `:e $NOTES/Home.md`
* `:echo g:vimwiki_current_idx`
{{{ vim
0
}}}
* Since this page belongs to the wiki registered in `g:vimwiki_list`, there is no need to create another wiki. Let's check that:
* `:echo g:vimwiki_list`
{{{ vim
[{
'maxhi' : 1,
'css_name' : 'style.css',
'auto_export' : 0,
'diary_index' : 'LogBook',
'template_default' : '',
'nested_syntaxes' : {'vim': 'vim', 'css': 'css', 'R': 'R', 'javascript': 'javascript', 'xml': 'html', 'sh': 'sh', 'ascript': 'applescript', 'html': 'html', 'ruby': 'ruby', 'jscript': 'javascript', 'objc': 'objc', 'c++': 'cpp', 'python': 'python', 'bash': 'sh'},
'diary_sort' : 'desc',
'path' : '$NOTES/Notes/',
'diary_link_fmt' : '%Y-%m-%d',
'template_ext' : '',
'syntax' : 'markdown',
'custom_wiki2html' : '$BIN/trunk2html_wrapper.sh',
'index' : 'WikiIndex',
'diary_header' : 'Entries',
'ext' : '.md',
'path_html' : '$NOTES/Html/',
'temp' : 0,
'template_path' : '',
'diary_rel_path' : ''
}]
}}}
* As a developer, it is useful to see what wiki state variables are active (g:vimwiki_current_XXX), and which have been cached with the buffer (b:vimwiki_XXX).
* `:VimwikiPrintWikiState`
{{{ vim
--- Internal Wiki State ---
- Options -
'b:vimwiki_maxhi': 1
'g:vimwiki_current_maxhi': 1
'b:vimwiki_css_name': 'style.css'
'g:vimwiki_current_css_name': 'style.css'
'b:vimwiki_auto_export': 0
'g:vimwiki_current_auto_export': 0
'b:vimwiki_diary_index': 'LogBook'
'g:vimwiki_current_diary_index': 'LogBook'
'b:vimwiki_template_default': ''
'g:vimwiki_current_template_default': ''
'b:vimwiki_nested_syntaxes': {'vim': 'vim', 'css': 'css', 'R': 'R', 'javascript': 'javascript', 'xml': 'html', 'sh': 'sh', 'ascript': 'applescript', 'html': 'html', 'r
uby': 'ruby', 'jscript': 'javascript', 'objc': 'objc', 'c++': 'cpp', 'python': 'python', 'bash': 'sh'}
'g:vimwiki_current_nested_syntaxes': {'vim': 'vim', 'css': 'css', 'R': 'R', 'javascript': 'javascript', 'xml': 'html', 'sh': 'sh', 'ascript': 'applescript', 'html': 'html', 'r
uby': 'ruby', 'jscript': 'javascript', 'objc': 'objc', 'c++': 'cpp', 'python': 'python', 'bash': 'sh'}
'b:vimwiki_diary_sort': 'desc'
'g:vimwiki_current_diary_sort': 'desc'
'b:vimwiki_path': '$NOTES/Notes/'
'g:vimwiki_current_path': '$NOTES/Notes/'
'b:vimwiki_diary_link_fmt': '%Y-%m-%d'
'g:vimwiki_current_diary_link_fmt': '%Y-%m-%d'
'b:vimwiki_template_ext': ''
'g:vimwiki_current_template_ext': ''
'b:vimwiki_syntax': 'markdown'
'g:vimwiki_current_syntax': 'markdown'
'b:vimwiki_custom_wiki2html': '$BIN/trunk2html_wrapper.sh'
'g:vimwiki_current_custom_wiki2html': '$BIN/trunk2html_wrapper.sh'
'b:vimwiki_index': 'WikiIndex'
'g:vimwiki_current_index': 'WikiIndex'
'b:vimwiki_diary_header': 'Entries'
'g:vimwiki_current_diary_header': 'Entries'
'b:vimwiki_ext': '.md'
'g:vimwiki_current_ext': '.md'
'b:vimwiki_path_html': '$NOTES/Html/'
'g:vimwiki_current_path_html': '$NOTES/Html/'
'b:vimwiki_temp': 0
'g:vimwiki_current_temp': 0
'b:vimwiki_template_path': ''
'g:vimwiki_current_template_path': ''
'b:vimwiki_diary_rel_path': ''
'g:vimwiki_current_diary_rel_path': ''
- Cached Variables -
'b:vimwiki_subdir': ''
'g:vimwiki_current_subdir': ''
'b:vimwiki_idx': 0
'g:vimwiki_current_idx': 0
}}}
* Now, when I open an orphan page (one that does not belong in one of the registered wikis), Vimwiki uses the extension to look up a syntax with which to initialize the orphan wiki. In fact, we will open two orphan pages to ensure that "g:vimwiki_ext2syntax" is working. (If "g:vimwiki_ext2syntax" is not defined, then the orphan wiki will be initialized with the default syntax). Then we'll check that the list of registered wikis has been extended, and that the orphan wiki path and syntax are correct.
* `:e $ORPHAN-WIKI/README.md`
* `:echo g:vimwiki_current_idx`
{{{ vim
1
}}}
* `:e $VIMWIKI-MASTER/tests/wiki/index.wiki`
* `:echo g:vimwiki_current_idx`
{{{ vim
2
}}}
* `:echo g:vimwiki_list`
{{{ vim
[{
'maxhi' : 1,
'css_name' : 'style.css',
'auto_export' : 0,
'diary_index' : 'LogBook',
'template_default' : '',
'nested_syntaxes' : {'vim': 'vim', 'css': 'css', 'R': 'R', 'javascript': 'javascript', 'xml': 'html', 'sh': 'sh', 'ascript': 'applescript', 'html': 'html', 'ruby': 'ruby', 'jscript': 'javascript', 'objc': 'objc', 'c++': 'cpp', 'python': 'python', 'bash': 'sh'},
'diary_sort' : 'desc',
'path' : '$NOTES/Notes/',
'diary_link_fmt' : '%Y-%m-%d',
'template_ext' : '',
'syntax' : 'markdown',
'custom_wiki2html' : '$BIN/trunk2html_wrapper.sh',
'index' : 'WikiIndex',
'diary_header' : 'Entries',
'ext' : '.md',
'path_html' : '$NOTES/Html/',
'temp' : 0,
'template_path' : '',
'diary_rel_path' : ''
}{
'maxhi' : 0,
'css_name' : 'style.css',
'auto_export' : 0,
'diary_index' : 'diary',
'template_default' : '',
'nested_syntaxes' : {},
'diary_sort' : 'desc',
'path' : '$ORPHAN/',
'diary_link_fmt' : '%Y-%m-%d',
'template_ext' : '',
'syntax' : 'markdown',
'custom_wiki2html' : '',
'index' : 'index',
'path_html' : '$ORPHAN_html/',
'ext' : '.md',
'diary_header' : 'Diary',
'temp' : 1,
'template_path' : '',
'diary_rel_path' : 'diary/'
}{
'maxhi' : 0,
'css_name' : 'style.css',
'auto_export' : 0,
'diary_index' : 'diary',
'template_default' : '',
'nested_syntaxes' : {},
'diary_sort' : 'desc',
'path' : '$VIMWIKI-MASTER/tests/wiki/',
'diary_link_fmt' : '%Y-%m-%d',
'template_ext' : '',
'syntax' : 'default',
'custom_wiki2html' : '',
'index' : 'index',
'path_html' : '$VIMWIKI-MASTER/tests/wiki_html/',
'ext' : '.wiki',
'diary_header' : 'Diary',
'temp' : 1,
'template_path' : '',
'diary_rel_path' : 'diary/'
}]
}}}
* Similarly, the wiki state variables (for "tests/wiki/index.md") are:
* `:VimwikiPrintWikiState`
{{{ vim
--- Internal Wiki State ---
- Options -
'b:vimwiki_maxhi': 0
'g:vimwiki_current_maxhi': 0
'b:vimwiki_css_name': 'style.css'
'g:vimwiki_current_css_name': 'style.css'
'b:vimwiki_auto_export': 0
'g:vimwiki_current_auto_export': 0
'b:vimwiki_diary_index': 'diary'
'g:vimwiki_current_diary_index': 'diary'
'b:vimwiki_template_default': ''
'g:vimwiki_current_template_default': ''
'b:vimwiki_nested_syntaxes': {}
'g:vimwiki_current_nested_syntaxes': {}
'b:vimwiki_diary_sort': 'desc'
'g:vimwiki_current_diary_sort': 'desc'
'b:vimwiki_path': '$VIMWIKI-MASTER/tests/wiki/'
'g:vimwiki_current_path': '$VIMWIKI-MASTER/tests/wiki/'
'b:vimwiki_diary_link_fmt': '%Y-%m-%d'
'g:vimwiki_current_diary_link_fmt': '%Y-%m-%d'
'b:vimwiki_template_ext': ''
'g:vimwiki_current_template_ext': ''
'b:vimwiki_syntax': 'default'
'g:vimwiki_current_syntax': 'default'
'b:vimwiki_custom_wiki2html': ''
'g:vimwiki_current_custom_wiki2html': ''
'b:vimwiki_index': 'index'
'g:vimwiki_current_index': 'index'
'b:vimwiki_diary_header': 'Diary'
'g:vimwiki_current_diary_header': 'Diary'
'b:vimwiki_ext': '.wiki'
'g:vimwiki_current_ext': '.wiki'
'b:vimwiki_path_html': '$VIMWIKI-MASTER/tests/wiki_html/'
'g:vimwiki_current_path_html': '$VIMWIKI-MASTER/tests/wiki_html/'
'b:vimwiki_temp': 1
'g:vimwiki_current_temp': 1
'b:vimwiki_template_path': ''
'g:vimwiki_current_template_path': ''
'b:vimwiki_diary_rel_path': 'diary/'
'g:vimwiki_current_diary_rel_path': 'diary/'
- Cached Variables -
'b:vimwiki_subdir': ''
'g:vimwiki_current_subdir': ''
'b:vimwiki_idx': 1
'g:vimwiki_current_idx': 1
}}}
* When we follow a link to a subdirectory (e.g. `[[subwiki1/wikilinks1]]`), notice how the "subdir" variable is updated accordingly.
{{{ vim
--- Internal Wiki State ---
- Options -
...
...
- Cached Variables -
'b:vimwiki_subdir': 'subwiki1/'
'g:vimwiki_current_subdir': 'subwiki1/'
'b:vimwiki_idx': 1
'g:vimwiki_current_idx': 1
}}}
Original comment by stu.andrews
on 9 May 2012 at 5:02
Hmm, I have checked again and it works for me too. False alarm. :)
Original comment by habamax
on 9 May 2012 at 6:57
Original issue reported on code.google.com by
habamax
on 9 May 2012 at 2:05