qqzsxyz / vimwiki

Automatically exported from code.google.com/p/vimwiki
0 stars 0 forks source link

Open daily diary entry doesn't work from non-wiki or empty files #290

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open vim or vim test.txt
2. try to go to diary entry (<leader>w<leader>w or <leader>w<leader>t)

What is the expected output? What do you see instead?
Except to get to the daily diary entry. However, these errors are displayed 
instead:
Error detected while processing function 
vimwiki#diary#make_note..<SNR>31_make_date_link..<SNR>31_add_link..<SNR>31_forma
t_diary:   
line    3:
E121: Undefined variable: g:vimwiki_rxH1_Template
E116: Invalid arguments for function substitute(g:vimwiki_rxH1_Template, 
'__Header__', VimwikiGet('diary_header'), ''))
E116: Invalid arguments for function add
Error detected while processing function 
vimwiki#diary#make_note..<SNR>31_make_date_link..<SNR>31_add_link..<SNR>31_forma
t_diary..<SNR>31_ge
t_diary_links..<SNR>31_read_captions:
line    8:
E121: Undefined variable: g:vimwiki_rxHeader
E15: Invalid expression: line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
E121: Undefined variable: g:vimwiki_rxHeader
...............

What version of the product are you using? On what operating system?
Development version, rev 474 (from today 2012/03/15) on linux

Please provide any additional information below.
<leader>w<leader>i works great to get to the diary index from an empty file. 
The ww and wt also work find once another wiki/diary file is opened.

Thanks!
Scott

Original issue reported on code.google.com by firecat4...@gmail.com on 15 Mar 2012 at 6:47

GoogleCodeExporter commented 8 years ago

Original comment by habamax on 15 Mar 2012 at 6:58

GoogleCodeExporter commented 8 years ago
The problem occurs b/c vimwiki#diary#make_note()  eventually tries to access 
g:vimwiki_rxHeader before it has been defined.  

Variables related to syntax are defined when the chosen syntax file 
vimwiki_xxx.vim is first read.

If the user has not yet opened a vimwiki file, then these variables will not 
yet be initialized.

I have provided a temporary fix in rb3e447292365, where 
vimwiki#diary#goto_index() is called whenever make_note() is called, ensuring 
that the syntax file is loaded.  The user will briefly see the index file flash 
on the screen, before the a new blank note is displayed.

Should we try to detect whether the syntax file has not yet been read, and 
force it to be read directly ??

Original comment by stu.andrews on 16 Mar 2012 at 3:24

GoogleCodeExporter commented 8 years ago
Well...this must be a regression because it works just fine in the stable 
version. :)

Thanks,
Scott

Original comment by firecat4...@gmail.com on 16 Mar 2012 at 4:10

GoogleCodeExporter commented 8 years ago
firecat4153: that is right.

Stuart, I think calling vimwiki#diary#goto_index() is a good solution here.

Original comment by habamax on 16 Mar 2012 at 6:08

GoogleCodeExporter commented 8 years ago
Sorry about the mixup with branches.   Please ignore the earlier revision on 
the link-properties branch.  I've applied the same patch to the trunk in 
r3f8159f103a8.

Thanks for catching this bug.  The reason that this error cropped up is because 
the previous implementation was agnostic about the user's chosen syntax ... it 
assumed the user had syntax='default'.  I made changes to the dev version to 
make it syntax-aware; in particular, to create headings in the diary's index 
page using the chosen syntax.

- Stu

Original comment by stu.andrews on 16 Mar 2012 at 10:13

GoogleCodeExporter commented 8 years ago

Original comment by habamax on 17 Mar 2012 at 6:49

GoogleCodeExporter commented 8 years ago
This is fixed without calling goto_index.

Original comment by habamax on 3 May 2012 at 4:40