Closed skervim closed 4 years ago
Thanks. The problem is most likely due to external calls to the date
utilitity. Which system are you on? Linux, BSD, MacOS, ...? What's the output of date --version
in a terminal?
Thanks for the prompt answer. The output of date --version
is:
date (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.
My system is Linux (Ubuntu 18.04).
Suddenly it works. ~Strangely, I cannot reproduce the error anymore, although it occured consistently over the last three days when I tried.~
Now, I tested creating a weekly summary of daily entries from a couple of months ago to test whether it only doesn't work for me to create a weekly summary when i'm inside the journal entry of "today". That worked and suddenly it also works from within the journal entry from "today".
Update: I could reproduce the error now. It only occurs when I got to the daily entry with
`n` <leader>w<leader>w |<plug>(wiki-journal)| [GLOBAL]
and then try :WikiJournalToWeek
. It does not occur when I directly open a diary entry via the terminal vim 2020-04-02.md
and than try the creation.
Ok, so, the following steps reproduce the issue for you?
<leader>w<leader>w
to open todays journal entry:WikiJournalToWeek
Do you get any error messages? If so, could you copy them here?
Yes, those 3 steps reproduce the issue. Then an empty file opens and I just noticed an error message for the first time (the error does not appear immediately but only after clicking the enter key):
Error detected while processing function wiki#link#open:
line 4:
E716: Key not present in Dictionary: open, a:000, l:link)
E116: Invalid arguments for function call
E488: Trailing characters
And I realize that after :WikiJournalToWeek
the file name changes from 2020-04-02.md
to 2020-04-02’.md
.
That does help somewhat, but not enough. It is difficult to debug without actually seeing what is happening on my end. Would you be able to add some debug code?
diff --git a/autoload/wiki/journal.vim b/autoload/wiki/journal.vim
index 6b2a973..483d88d 100644
--- a/autoload/wiki/journal.vim
+++ b/autoload/wiki/journal.vim
@@ -53,9 +53,12 @@ function! wiki#journal#freq(frq) abort " {{{1
let l:fmt = g:wiki_journal.date_format.daily
let l:rx = wiki#date#format_to_regex(l:fmt)
let l:date = l:filedate =~# l:rx ? l:filedate : strftime(l:fmt)
+ unsilent echom 'date' l:date "\n"
- call wiki#url#parse('journal:'
- \ . wiki#date#format(l:date, g:wiki_journal.date_format[a:frq])).open()
+ let l:newdate = wiki#date#format(l:date, g:wiki_journal.date_format[a:frq])
+ unsilent echom 'newdate' l:newdate "\n"
+
+ call wiki#url#parse('journal:' . l:newdate).open()
endfunction
" }}}1
If you apply the above patch, it should show some relevant output, I think. You might need to do :messages
after running the command to see the output. Could you report the output here?
The output after applying the patch is:
date /home/skervim/wiki/journal/2020-04-02
newdate date: invalid date ‘/home/skervim/wiki/journal/2020-04-02’
Next patch:
diff --git a/autoload/wiki/date.vim b/autoload/wiki/date.vim
index 2dba81a..28a216a 100644
--- a/autoload/wiki/date.vim
+++ b/autoload/wiki/date.vim
@@ -153,6 +153,8 @@ endfunction
" Utility functions for running GNU date or similar shell commands
"
function! s:date(date, format) abort " {{{1
+ unsilent echom 'gnudate' s:gnu_date
+ unsilent echom a:date '|' a:format "\n"
if s:gnu_date
return systemlist(printf('date +"%s" -d "%s"', a:format, a:date))[0]
else
This should show which parameters are passed to the date
utility.
gnudate 1
/home/skervim/wiki/journal/2020-04-02 | %Y_w%V
Ah, ok. I think I see now. Can you test latest version?
It works! Thank you very much for the quick and successful fix!
Great, happy to hear it! :)
I want to write daily journal entries and then use
:WikiJournalToWeek
in order to create a weekly summary. When doing so, instead of a weekly summary markdown file (expected) my journal directory contains a folder with name'date: invalid date ‘'
(observed).My wiki.vim configuration looks as follows: