Compare commits
79 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71505569c0 | ||
|
|
6d1d2d035a | ||
|
|
491c3c7fba | ||
|
|
70b05c2c76 | ||
|
|
a778ef5590 | ||
|
|
03fe8bb167 | ||
|
|
aa618973e2 | ||
|
|
7b9c9815a4 | ||
|
|
57d45200c8 | ||
|
|
484c12771e | ||
|
|
f77215ca80 | ||
|
|
849a7d5f61 | ||
|
|
0e2b110903 | ||
|
|
aad48b0231 | ||
|
|
81e64682d0 | ||
|
|
303ab65237 | ||
|
|
c2eb67f1a6 | ||
|
|
85c215b4cc | ||
|
|
3e3251f8b5 | ||
|
|
0863e1434e | ||
|
|
ca8ae307d3 | ||
|
|
95d97151c5 | ||
|
|
1e3a5e58ae | ||
|
|
89570cbaef | ||
|
|
4548961329 | ||
|
|
8dd24d0b68 | ||
|
|
e2a02d4f30 | ||
|
|
595fc0b49e | ||
|
|
a612ebeaf1 | ||
|
|
17a2345675 | ||
|
|
e13eb4bb9c | ||
|
|
d769f12710 | ||
|
|
2535cf2ece | ||
|
|
eb7f7cb8f4 | ||
|
|
87a6c371dd | ||
|
|
29a6ea4b1d | ||
|
|
03501dfe42 | ||
|
|
fc0b4c3272 | ||
|
|
b87c7dd98d | ||
|
|
7232106f45 | ||
|
|
6e1bcc0e1a | ||
|
|
03f5575363 | ||
|
|
b3d9e18b08 | ||
|
|
a98711da91 | ||
|
|
0a917143c5 | ||
|
|
c13a277e2a | ||
|
|
421916b25d | ||
|
|
8da977113b | ||
|
|
2a04312e8d | ||
|
|
85b2e86b73 | ||
|
|
1e465dd931 | ||
|
|
79e4d352a2 | ||
|
|
ddbcdd823f | ||
|
|
77cfafb9f0 | ||
|
|
fbc45c5c8c | ||
|
|
6c5a37e6c6 | ||
|
|
25a63d5ecd | ||
|
|
04210abd70 | ||
|
|
649f962211 | ||
|
|
b1ed8608d1 | ||
|
|
f30ac979a1 | ||
|
|
40faa56012 | ||
|
|
51c821b5da | ||
|
|
6c073cdb42 | ||
|
|
e508140f90 | ||
|
|
d0080e66f9 | ||
|
|
e071156b8d | ||
|
|
1f8b706d8e | ||
|
|
0e3c5cb2b6 | ||
|
|
32188000f9 | ||
|
|
1cc11c56ad | ||
|
|
639fcd85a2 | ||
|
|
b8a5bd64ca | ||
|
|
95ed508741 | ||
|
|
05b5be07d2 | ||
|
|
08fcb4ccdb | ||
|
|
e817f5eca8 | ||
|
|
2d83ed8dc2 | ||
|
|
52e1527e9b |
0
.gitmodules
vendored
0
.gitmodules
vendored
@@ -28,17 +28,24 @@
|
|||||||
|
|
||||||
## Release notes
|
## Release notes
|
||||||
|
|
||||||
v0.7.4 includes the overduedate support from Guilherme Victal (see pull
|
+ v0.8 Incorporates Fretep's work on overdue dates (PR#13 and PR#16) witch
|
||||||
[request #45 on freitass version](https://github.com/freitass/todo.txt-vim/pull/45)),
|
removes python dependency, allow to control the cursor position after a sort by
|
||||||
it highlight dates in overdue tasks as an Error. It depends on a
|
todo (see (sort)[#sort] and/or issue #15) and fixes bug when sorting a file
|
||||||
Python library, however, and as such will only be able to work if your version
|
containing only lines with due:date (issue #14).
|
||||||
of Vim was compiled with the `+python` option (as most common versions do).
|
|
||||||
|
|
||||||
If your Vim installation does **not** have Python support, this plugin **will work just fine** but this feature will be disabled.
|
+ v0.7.6 Incorporates [Sietse's work](https://github.com/sietse/todo.txt-vim/commit/57d45200c8b033d31c9191ee0eb0711c801cdb1d) to make cancel and mark as done mapping repeatable using [vim-repeat](https://github.com/tpope/vim-repeat).
|
||||||
|
+ v0.7.5 Incorporates [Fievel's work](https://github.com/fievel/todo.txt-vim/commit/0863e1434e9a89ace06c4856b6cb32ba9906e3de) to make overduedates work on python3.
|
||||||
|
+ v0.7.4 includes the overduedate support from Guilherme Victal (see pull
|
||||||
|
|
||||||
|
[request #45 on freitass version](https://github.com/freitass/todo.txt-vim/pull/45)),
|
||||||
|
it highlight dates in overdue tasks as an Error. It depends on a
|
||||||
|
Python library, however, and as such will only be able to work if your version
|
||||||
|
of Vim was compiled with the `+python` option (as most common versions do).
|
||||||
|
|
||||||
|
If your Vim installation does **not** have Python support, this plugin **will work just fine** but this feature will be disabled.
|
||||||
|
|
||||||
|
|
||||||
Since v0.7.3, `TodoComplete` is replaced by `todo#Complete`, you might need to
|
+ Since v0.7.3, `TodoComplete` is replaced by `todo#Complete`, you might need to update your vimrc (see [completion](#completion)).
|
||||||
update your vimrc (see [completion](#completion)).
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@@ -213,6 +220,19 @@ prevent this behavior, add the following line to your vimrc
|
|||||||
+ `<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
+ `<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
||||||
sorted by at the beginning of the file, the rest of the file is not modified.
|
sorted by at the beginning of the file, the rest of the file is not modified.
|
||||||
|
|
||||||
|
When you sort by due dates, at the end of the sort, your cursor will be placed
|
||||||
|
at the top of the file. This behavior can be set with the following global
|
||||||
|
variable :
|
||||||
|
|
||||||
|
let g:TodoTxtSortDueDateCursorPos = "top"
|
||||||
|
|
||||||
|
Possible values are :
|
||||||
|
|
||||||
|
+ `top` (default): The first line of the buffer, i.e. your most outstanding task
|
||||||
|
+ `lastdue`: The last task with a due:date set
|
||||||
|
+ `notoverdue`: The first task that is not overdue (requires #13)
|
||||||
|
+ `bottom`: The last line of the buffer
|
||||||
|
|
||||||
### Priorities
|
### Priorities
|
||||||
|
|
||||||
+ `<LocalLeader>j` : Lower the priority of the current line
|
+ `<LocalLeader>j` : Lower the priority of the current line
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ function! todo#RemovePriority()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! todo#PrependDate()
|
function! todo#PrependDate()
|
||||||
|
if (getline(".") =~ '\v^\(')
|
||||||
|
execute "normal! 0f)a\<space>\<esc>l\"=strftime(\"%Y-%m-%d\")\<esc>P"
|
||||||
|
else
|
||||||
normal! 0"=strftime("%Y-%m-%d ")
|
normal! 0"=strftime("%Y-%m-%d ")
|
||||||
|
P
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -137,29 +141,76 @@ function! todo#Sort()
|
|||||||
silent! %s/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
silent! %s/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
||||||
sort n /^x\s*/
|
sort n /^x\s*/
|
||||||
silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
|
silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
|
||||||
|
else
|
||||||
|
let oldcursor=getpos(".")
|
||||||
|
silent normal gg
|
||||||
|
let l:first=search('^\s*x')
|
||||||
|
if l:first != 0
|
||||||
|
sort /^./r
|
||||||
|
" at this point done tasks are at the end
|
||||||
|
let l:first=search('^\s*x')
|
||||||
|
let l:last=search('^\s*x','b')
|
||||||
|
let l:diff=l:last-l:first+1
|
||||||
|
" Cut the done lines
|
||||||
|
execute ':'.l:first.'d a '.l:diff
|
||||||
endif
|
endif
|
||||||
sort /@[a-zA-Z]*/ r
|
sort /@[a-zA-Z]*/ r
|
||||||
sort /+[a-zA-Z]*/ r
|
sort /+[a-zA-Z]*/ r
|
||||||
|
sort /\v([A-Z])/ r
|
||||||
|
if l:first != 0
|
||||||
|
silent normal G"ap
|
||||||
|
execute ':'.l:first.','.l:last.'sort /@[a-zA-Z]*/ r'
|
||||||
|
execute ':'.l:first.','.l:last.'sort /+[a-zA-Z]*/ r'
|
||||||
|
execute ':'.l:first.','.l:last.'sort /\v([A-Z])/ r'
|
||||||
|
endif
|
||||||
call cursor(oldcursor)
|
call cursor(oldcursor)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! todo#SortDue()
|
function! todo#SortDue()
|
||||||
silent! %s/\([dD][uU][eE]:\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
" Check how many lines have a due:date on them
|
||||||
" Sort adding entries with due dates add the beginning
|
let l:tasksWithDueDate = 0
|
||||||
sort n /[dD][uU][eE]:/
|
silent! %global/\v\c^[^x].*<due:\d{4}-\d{2}-\d{2}>/let l:tasksWithDueDate += 1
|
||||||
" Count the number of lines
|
if l:tasksWithDueDate == 0
|
||||||
silent normal gg
|
" No tasks with a due:date: No need to modify the buffer at all
|
||||||
execute "/[dD][uU][eE]:"
|
" Also means we don't need to cater for no matches on searches below
|
||||||
let l:first=getpos(".")[1]
|
return
|
||||||
silent normal N
|
endif
|
||||||
let l:last=getpos(".")[1]
|
" FIXME: There is a small chance that due:\d{8} might legitimately exist in the buffer
|
||||||
|
" We modify due:yyyy-mm-dd to yyyymmdd which would then mean we would alter the buffer
|
||||||
|
" in an unexpected way, altering user data. Not sure how to deal with this at the moment.
|
||||||
|
" I'm going to throw an exception, and if this is a problem we can revisit.
|
||||||
|
silent %global/\v\c<due:\d{8}>/throw "Text matching 'due:\\d\\{8\\}' exists in the buffer, this function cannot sort your buffer"
|
||||||
|
" Turn the due:date from due:yyyy-mm-dd to due:yyyymmdd so we can do a numeric sort
|
||||||
|
silent! %substitute/\v<(due:\d{4})\-(\d{2})\-(\d{2})>/\1\2\3/ei
|
||||||
|
" Sort all the lines with due: by numeric yyyymmdd, they will end up in ascending order at the bottom of the buffer
|
||||||
|
sort in /^[^x].*\<due:/
|
||||||
|
" Determine the line number of the first task with a due:date
|
||||||
let l:firstLineWithDue = line("$") - l:tasksWithDueDate + 1
|
let l:firstLineWithDue = line("$") - l:tasksWithDueDate + 1
|
||||||
" Put the sorted lines at the beginning of the file
|
" Put the sorted lines at the beginning of the file
|
||||||
execute ':'.l:first
|
if l:firstLineWithDue > 1
|
||||||
execute ':d'.l:diff
|
" ...but only if the whole file didn't get sorted.
|
||||||
silent normal gg
|
execute l:firstLineWithDue . ",$move 0"
|
||||||
silent normal P
|
endif
|
||||||
|
" Change the due:yyyymmdd back to due:yyyy-mm-dd.
|
||||||
|
silent! %substitute/\v<(due:\d{4})(\d{2})(\d{2})>/\1-\2-\3/ei
|
||||||
|
" Cursor is now on the last task with a due:date
|
||||||
|
" Let's check a global for a user preference on the cursor position.
|
||||||
|
if exists("g:TodoTxtSortDueDateCursorPos")
|
||||||
|
if g:TodoTxtSortDueDateCursorPos ==? "top"
|
||||||
|
normal gg
|
||||||
|
elseif g:TodoTxtSortDueDateCursorPos ==? "lastdue"
|
||||||
|
" Nothing to do
|
||||||
|
elseif g:TodoTxtSortDueDateCursorPos ==? "notoverdue"
|
||||||
|
" Let's try to put the cursor on the first non-overdue task
|
||||||
|
let l:overduePat = todo#GetDateRegexForPastDates()
|
||||||
|
execute ":silent! ?\\v<due:" . l:overduePat . ">?+1"
|
||||||
|
elseif g:TodoTxtSortDueDateCursorPos ==? "bottom"
|
||||||
|
silent normal G
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" Default: Top of the document
|
||||||
|
normal gg
|
||||||
endif
|
endif
|
||||||
" TODO: add time sorting (YYYY-MM-DD HH:MM)
|
" TODO: add time sorting (YYYY-MM-DD HH:MM)
|
||||||
endfunction
|
endfunction
|
||||||
@@ -331,7 +382,7 @@ fun! todo#Complete(findstart, base)
|
|||||||
let res = []
|
let res = []
|
||||||
for bufnr in range(1,bufnr('$'))
|
for bufnr in range(1,bufnr('$'))
|
||||||
let lines=getbufline(bufnr,1,"$")
|
let lines=getbufline(bufnr,1,"$")
|
||||||
for line in lines
|
for line in lines
|
||||||
if line =~ " ".a:base
|
if line =~ " ".a:base
|
||||||
" init temporary item
|
" init temporary item
|
||||||
let item={}
|
let item={}
|
||||||
|
|||||||
24
doc/todo.txt
24
doc/todo.txt
@@ -31,6 +31,17 @@ Table of Contents *TodoTxt-Contents* ~
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
1. Release notes *TodoTxt-ReleaseNotes* ~
|
1. Release notes *TodoTxt-ReleaseNotes* ~
|
||||||
|
|
||||||
|
v0.8 Incorporates Fretep's work on overdue dates (PR#13 and PR#16) witch removes
|
||||||
|
python dependency, allow to control the cursor position after a sort by todo
|
||||||
|
(see |TodoTxt-Sort| and/or issue #15) and fixes bug when sorting a file
|
||||||
|
containing only lines with due:date (issue #14).
|
||||||
|
|
||||||
|
v0.7.6 Incorporates [Sietse's work](https://github.com/sietse/todo.txt-vim/commit/57d45200c8b033d31c9191ee0eb0711c801cdb1d) to make cancel and mark as done mapping repeatable using [vim-repeat](https://github.com/tpope/vim-repeat).
|
||||||
|
|
||||||
|
v0.7.5 Incorporates Fievel's work
|
||||||
|
(https://github.com/fievel/todo.txt-vim/commit/0863e1434e9a89ace06c4856b6cb32ba9906e3de)
|
||||||
|
to make overduedates work on python3.
|
||||||
|
|
||||||
v0.7.4 includes the overduedate support from Guilherme Victal (see pull
|
v0.7.4 includes the overduedate support from Guilherme Victal (see pull
|
||||||
request #45 on freitass version (https://github.com/freitass/todo.txt-vim/pull/45)),
|
request #45 on freitass version (https://github.com/freitass/todo.txt-vim/pull/45)),
|
||||||
it highlight dates in overdue tasks as an Error. It depends on a
|
it highlight dates in overdue tasks as an Error. It depends on a
|
||||||
@@ -224,6 +235,19 @@ prevent this behavior, add the following line to your vimrc
|
|||||||
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
||||||
sorted by at the beginning of the file, the rest of the file is not modified.
|
sorted by at the beginning of the file, the rest of the file is not modified.
|
||||||
|
|
||||||
|
When you sort by due dates, at the end of the sort, your cursor will be placed
|
||||||
|
at the top of the file. This behavior can be set with the following global
|
||||||
|
variable :
|
||||||
|
|
||||||
|
let g:TodoTxtSortDueDateCursorPos = "top"
|
||||||
|
|
||||||
|
Possible values are :
|
||||||
|
|
||||||
|
+ `top` (default): The first line of the buffer, i.e. your most outstanding task
|
||||||
|
+ `lastdue`: The last task with a due:date set
|
||||||
|
+ `notoverdue`: The first task that is not overdue (requires #13)
|
||||||
|
+ `bottom`: The last line of the buffer
|
||||||
|
|
||||||
6.2 Priorities *TodoTxt-Priorities*
|
6.2 Priorities *TodoTxt-Priorities*
|
||||||
|
|
||||||
`<LocalLeader>j` : Lower the priority of the current line
|
`<LocalLeader>j` : Lower the priority of the current line
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ set cpo&vim
|
|||||||
if exists("g:Todo_txt_loaded")
|
if exists("g:Todo_txt_loaded")
|
||||||
finish
|
finish
|
||||||
else
|
else
|
||||||
let g:Todo_txt_loaded=0.7.4
|
let g:Todo_txt_loaded=0.8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" General options {{{1
|
" General options {{{1
|
||||||
@@ -54,12 +54,15 @@ if !exists("g:Todo_txt_do_not_map")
|
|||||||
noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
|
noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
|
||||||
|
|
||||||
" Mark done {{{2
|
" Mark done {{{2
|
||||||
noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
|
noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR>
|
||||||
|
\:call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
|
||||||
|
nmap <localleader>x <Plug>DoToggleMarkAsDone
|
||||||
|
" noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
|
||||||
|
|
||||||
" Mark done {{{2
|
" Mark done {{{2
|
||||||
noremap <script> <silent> <buffer> <localleader>C :call todo#ToggleMarkAsDone('Cancelled')<CR>
|
noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR>
|
||||||
|
\:call repeat#set("\<Plug>DoCancel")<CR>
|
||||||
|
nmap <localleader>C <Plug>DoCancel
|
||||||
|
|
||||||
" Mark all done {{{2
|
" Mark all done {{{2
|
||||||
noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
|
noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# File: __init__.py
|
|
||||||
# Author: Guilherme Victal <guilherme at victal.eti.br>
|
|
||||||
# Description: Dateregex library entry point
|
|
||||||
# License: Vim license
|
|
||||||
# Website: http://github.com/freitass/todo.txt-vim
|
|
||||||
# Version: 0.1
|
|
||||||
|
|
||||||
from after import regex_date_after
|
|
||||||
from before import regex_date_before
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# File: after.py
|
|
||||||
# Author: Guilherme Victal <guilherme at victal.eti.br>
|
|
||||||
# Description: Generates regexes after a certain date
|
|
||||||
# License: Vim license
|
|
||||||
# Website: http://github.com/freitass/todo.txt-vim
|
|
||||||
# Version: 0.1
|
|
||||||
|
|
||||||
from datetime import date, timedelta, MAXYEAR
|
|
||||||
|
|
||||||
|
|
||||||
def _year_regex_after(year):
|
|
||||||
if int(year) > MAXYEAR:
|
|
||||||
return None
|
|
||||||
|
|
||||||
year_regex = r'(\d+\d{%s}' % len(year)
|
|
||||||
for idx, digit in enumerate(year):
|
|
||||||
if digit != '9':
|
|
||||||
regex = '|' + year[0:idx]
|
|
||||||
regex += '9' if digit == '8' else '[%s-9]' % str(int(digit) + 1)
|
|
||||||
if idx < len(year) - 1:
|
|
||||||
regex += '\d{%s}' % (len(year) - (idx + 1))
|
|
||||||
year_regex += regex
|
|
||||||
|
|
||||||
year_regex += ')'
|
|
||||||
return '-'.join((year_regex, r'\d{2}', r'\d{2}'))
|
|
||||||
|
|
||||||
|
|
||||||
def _month_regex_after(year, month):
|
|
||||||
if month == '12':
|
|
||||||
return None
|
|
||||||
|
|
||||||
digit1, digit2 = month
|
|
||||||
if digit1 == '1':
|
|
||||||
month_regex = r'12' if month == '11' else r'1[12]'
|
|
||||||
else:
|
|
||||||
month_regex = r'1[0-2]'
|
|
||||||
if digit2 != '9':
|
|
||||||
if digit2 == '8':
|
|
||||||
month_regex = r'(' + month_regex + r'|09)'
|
|
||||||
else:
|
|
||||||
month_regex = r'(' + month_regex + r'|0[%s-9])'
|
|
||||||
month_regex = month_regex % str(int(digit2) + 1)
|
|
||||||
return '-'.join((year, month_regex, r'\d{2}'))
|
|
||||||
|
|
||||||
def _day_regex_after(year, month, day):
|
|
||||||
last_month_day = str((date(int(year), (int(month) + 1) % 12, 1) + - date.resolution).day)
|
|
||||||
if day == last_month_day:
|
|
||||||
return None
|
|
||||||
day_regex = r'('
|
|
||||||
digit1, digit2 = day
|
|
||||||
last_digit1, last_digit2 = last_month_day
|
|
||||||
if digit1 == last_digit1:
|
|
||||||
day_regex = last_month_day if int(digit2) == int(last_digit2) - 1 else last_digit1 + r'[%s-%s]' % (str(int(digit2) + 1), last_digit2)
|
|
||||||
else:
|
|
||||||
day_regex = r'('
|
|
||||||
day_regex += last_digit1 if int(digit1) == int(last_digit1) - 1 else r'[%s-%s]' % (str(int(digit1) + 1), last_digit1)
|
|
||||||
day_regex +=r'\d'
|
|
||||||
if digit2 < '9':
|
|
||||||
day_regex += '|' + digit1
|
|
||||||
day_regex += '9' if digit2 == '8' else r'[%s-9]' % str(int(digit2) + 1)
|
|
||||||
|
|
||||||
day_regex += ')'
|
|
||||||
return '-'.join((year, month, day_regex))
|
|
||||||
|
|
||||||
|
|
||||||
def regex_date_after(given_date):
|
|
||||||
year, month, day = given_date.isoformat().split('-')
|
|
||||||
|
|
||||||
year_regex = _year_regex_after(year)
|
|
||||||
month_regex = _month_regex_after(year, month)
|
|
||||||
day_regex = _day_regex_after(year, month, day)
|
|
||||||
|
|
||||||
date_regex = '(' + year_regex if year_regex else '('
|
|
||||||
date_regex += ('|' + month_regex) if month_regex else ''
|
|
||||||
date_regex += ('|' + day_regex) if day_regex else ''
|
|
||||||
date_regex += ')'
|
|
||||||
return date_regex
|
|
||||||
|
|
||||||
|
|
||||||
def __main():
|
|
||||||
import re
|
|
||||||
date_regex = regex_date_after(date(1999,12,31))
|
|
||||||
print(date_regex)
|
|
||||||
pattern = re.compile(date_regex)
|
|
||||||
|
|
||||||
|
|
||||||
d = date.today() + date.resolution
|
|
||||||
assert pattern.match(date.strftime(d, '%Y-%m-%d')) is not None
|
|
||||||
print(date.strftime(d, '%Y-%m-%d') + ' is okay')
|
|
||||||
d += date.resolution
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
__main()
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# File: before.py
|
|
||||||
# Author: Guilherme Victal <guilherme at victal.eti.br>
|
|
||||||
# Description: Generates regexes before a certain date
|
|
||||||
# License: Vim license
|
|
||||||
# Website: http://github.com/freitass/todo.txt-vim
|
|
||||||
# Version: 0.1
|
|
||||||
|
|
||||||
from datetime import date, timedelta, MINYEAR
|
|
||||||
|
|
||||||
def _year_regex_before(year):
|
|
||||||
if int(year) <= MINYEAR:
|
|
||||||
return None
|
|
||||||
year_regex = r'('
|
|
||||||
year_regex += r'\d{1,%s}' % str(len(year) - 1) if len(year) > 1 else ''
|
|
||||||
for idx, digit in enumerate(year):
|
|
||||||
if digit != '0':
|
|
||||||
regex = '|' + year[0:idx]
|
|
||||||
regex += '0' if digit == '1' else '[0-%s]' % str(int(digit) - 1)
|
|
||||||
if idx < len(year) - 1:
|
|
||||||
regex += '\d{%s}' % (len(year) - (idx + 1))
|
|
||||||
year_regex += regex
|
|
||||||
|
|
||||||
year_regex += ')'
|
|
||||||
return '-'.join((year_regex, r'\d{2}', r'\d{2}'))
|
|
||||||
|
|
||||||
def _month_regex_before(year, month):
|
|
||||||
if month == '01':
|
|
||||||
return None
|
|
||||||
|
|
||||||
digit1, digit2 = month
|
|
||||||
if digit1 == '0':
|
|
||||||
month_regex = '01' if month == '02' else r'0[1-%s]' % str(int(digit2) - 1)
|
|
||||||
elif month == '10':
|
|
||||||
month_regex = r'0\d'
|
|
||||||
elif month == '11':
|
|
||||||
month_regex = r'(0\d|10)'
|
|
||||||
else:
|
|
||||||
month_regex = r'(0\d|1[01])'
|
|
||||||
|
|
||||||
return '-'.join((year, month_regex, r'\d{2}'))
|
|
||||||
|
|
||||||
def _day_regex_before(year, month, day):
|
|
||||||
if day == '01':
|
|
||||||
return None
|
|
||||||
last_month_day = str((date(int(year), (int(month) + 1) % 12, 1) + - date.resolution).day)
|
|
||||||
last_digit1, last_digit2 = last_month_day
|
|
||||||
|
|
||||||
digit1, digit2 = day
|
|
||||||
if digit1 == '0':
|
|
||||||
day_regex = '01' if day == '02' else r'0[1-%s]' % str(int(digit2) - 1)
|
|
||||||
else:
|
|
||||||
day_regex = r'('
|
|
||||||
day_regex += '0' if digit1 == '1' else r'[0-%s]' % str(int(digit1) - 1)
|
|
||||||
day_regex += r'\d'
|
|
||||||
if digit2 != '0':
|
|
||||||
day_regex += '|'
|
|
||||||
day_regex += digit1
|
|
||||||
day_regex += '0' if digit2 == '1' else r'[0-%s]' % str(int(digit2) - 1)
|
|
||||||
day_regex += ')'
|
|
||||||
|
|
||||||
return '-'.join((year, month, day_regex))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def regex_date_before(given_date):
|
|
||||||
year, month, day = given_date.isoformat().split('-')
|
|
||||||
|
|
||||||
year_regex = _year_regex_before(year)
|
|
||||||
month_regex = _month_regex_before(year, month)
|
|
||||||
day_regex = _day_regex_before(year, month, day)
|
|
||||||
|
|
||||||
date_regex = '(' + year_regex if year_regex else '('
|
|
||||||
date_regex += ('|' + month_regex) if month_regex else ''
|
|
||||||
date_regex += ('|' + day_regex) if day_regex else ''
|
|
||||||
date_regex += ')'
|
|
||||||
return date_regex
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env python2
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# File: todo.py
|
|
||||||
# Description: Todo.txt overdue date syntax script
|
|
||||||
# License: Vim license
|
|
||||||
# Website: http://github.com/freitass/todo.txt-vim
|
|
||||||
# Version: 0.1
|
|
||||||
|
|
||||||
import vim
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
dateregex_dir = os.path.join(vim.eval('s:script_dir'), 'dateregex')
|
|
||||||
if os.path.isdir(dateregex_dir):
|
|
||||||
sys.path.insert(0, dateregex_dir)
|
|
||||||
|
|
||||||
def add_due_date_syntax_highlight():
|
|
||||||
try:
|
|
||||||
from dateregex import regex_date_before
|
|
||||||
except ImportError:
|
|
||||||
print("dateregex module not found. Overdue dates won't be highlighted")
|
|
||||||
return
|
|
||||||
|
|
||||||
regex = regex_date_before(date.today())
|
|
||||||
regex = r'(^|<)due:%s(>|$)' % regex
|
|
||||||
|
|
||||||
vim.command("syntax match OverDueDate '\\v%s'" % regex)
|
|
||||||
vim.command("highlight default link OverDueDate Error")
|
|
||||||
|
|
||||||
add_due_date_syntax_highlight()
|
|
||||||
179
syntax/todo.vim
179
syntax/todo.vim
@@ -9,33 +9,33 @@ if exists("b:current_syntax")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,OverDueDate
|
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoOverDueDate
|
||||||
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
|
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
|
||||||
syntax match TodoKey '\S*\S:\S\S*' contains=TodoDate
|
syntax match TodoKey '\S*\S:\S\S*' contains=TodoDate
|
||||||
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
|
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
|
||||||
@@ -51,12 +51,123 @@ highlight default link TodoDate PreProc
|
|||||||
highlight default link TodoProject Special
|
highlight default link TodoProject Special
|
||||||
highlight default link TodoContext Special
|
highlight default link TodoContext Special
|
||||||
|
|
||||||
if has('python')
|
function! todo#GetDateRegexForPastDates(...)
|
||||||
let b:curdir = expand('<sfile>:p:h')
|
" Build a RegExp to match all dates prior to a reference date.
|
||||||
let s:script_dir = b:curdir . "/python/"
|
"
|
||||||
execute "pyfile " . s:script_dir. "todo.py"
|
" Optionally accepts a (year, month, day) for the date, otherwise assumes the
|
||||||
else
|
" reference date is the current date.
|
||||||
echom "Your version of vim has no python support. Overdue dates won't be highlighted"
|
"
|
||||||
endif
|
" In the end, the RegExp will look something like:
|
||||||
|
" =todo#GetDateRegexForPastDates(2017, 09, 15)
|
||||||
|
" \v(([01]\d{3}|200\d|201[0-6])\-\d{2}\-\d{2}|(2017\-(0[0-8])\-\d{2})|(2017\-09\-0\d)|(2017\-09\-1[0-4]))
|
||||||
|
"
|
||||||
|
" We split the RegExp into a few alternation groups:
|
||||||
|
" 1. All dates prior to 2000, dates before this are not supported
|
||||||
|
" 2. All previous decades for the reference date century
|
||||||
|
" 3. The current decade up to the year prior to the reference year
|
||||||
|
" 4. All months for the reference year up to the end of the previous month
|
||||||
|
" 5. Days of the month part 1.
|
||||||
|
" 6. Days of the month part 2.
|
||||||
|
"
|
||||||
|
" Will not work on reference dates past 2099, or before 2000.
|
||||||
|
"
|
||||||
|
" Invalid months and days are not checked, i.e. 2015-14-67 will match.
|
||||||
|
"
|
||||||
|
" Years must be 4 digits.
|
||||||
|
"
|
||||||
|
|
||||||
|
" Get the reference date
|
||||||
|
let l:day=strftime("%d")
|
||||||
|
let l:month=strftime("%m")
|
||||||
|
let l:year=strftime("%Y")
|
||||||
|
if a:0 >= 1
|
||||||
|
let l:year=a:1
|
||||||
|
endif
|
||||||
|
if a:0 >= 2
|
||||||
|
let l:month=a:2
|
||||||
|
endif
|
||||||
|
if a:0 >= 3
|
||||||
|
let l:day=a:3
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Use very magic mode, and start an alternation
|
||||||
|
let l:overdueRex = '\v('
|
||||||
|
|
||||||
|
" PART 1: 0000-1999
|
||||||
|
" This sucker is static and won't change to year 3000. I'm not coding for the year 3000.
|
||||||
|
let l:overdueRex = l:overdueRex . '([01]\d{3}'
|
||||||
|
|
||||||
|
" PART 2. All previous decades for the reference date century
|
||||||
|
" i.e. for 2017: "200\d", for 2035: "20[0-2]\d"
|
||||||
|
" for 2000: skip
|
||||||
|
let l:decade = strpart(l:year, 2, 1) " i.e. the 1 from 2017
|
||||||
|
if l:decade > 0
|
||||||
|
let l:overdueRex = l:overdueRex . '|20'
|
||||||
|
if l:decade > 1
|
||||||
|
let l:overdueRex = l:overdueRex . '[0-' . (l:decade - 1) . ']'
|
||||||
|
else
|
||||||
|
let l:overdueRex = l:overdueRex . '0'
|
||||||
|
endif
|
||||||
|
let l:overdueRex = l:overdueRex . '\d'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" PART 3: This decade, to previous year
|
||||||
|
" i.e. for 2017: "201[0-6]", for 2035: "203[0-4]", for 2000: skip
|
||||||
|
let l:y = strpart(l:year, 3, 1) " Last digit of the year, i.e. 7 for 2017
|
||||||
|
if l:y > 0
|
||||||
|
if l:y > 1
|
||||||
|
let l:overdueRex = l:overdueRex . '|20' . l:decade . '[0-' . (l:y - 1) . ']'
|
||||||
|
else
|
||||||
|
let l:overdueRex = l:overdueRex . '|20' . l:decade . '0'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let l:overdueRex = l:overdueRex . ')\-\d{2}\-\d{2}|'
|
||||||
|
|
||||||
|
" PART 4: All months to the end of the previous month
|
||||||
|
" i.e. for a date of 2017-09-07, "2017-(0[1-8])-\d{2}"
|
||||||
|
" for 2017-11-30: "2017-(0\d|1[0-1])-\d{2}"
|
||||||
|
" for 2017-01-20: skip
|
||||||
|
" This only applies if the reference date is not in January
|
||||||
|
if l:month > 1
|
||||||
|
let l:overdueRex = l:overdueRex . '(' . l:year . '\-(0'
|
||||||
|
if l:month > 10
|
||||||
|
let l:overdueRex = l:overdueRex . '\d|1'
|
||||||
|
endif
|
||||||
|
let l:y = strpart(printf('%02d', l:month), 1, 1) " Second digit of the month
|
||||||
|
let l:overdueRex = l:overdueRex . '[0-' . (l:y - 1) . '])\-\d{2})|'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" PART 5. Days of the month part 1.
|
||||||
|
" i.e. for 2017-09-07: skip
|
||||||
|
" for 2017-12-29: "2017-12-[0-1]\d"
|
||||||
|
let l:y = strpart(printf('%02d', l:day), 0, 1) " First digit of the day
|
||||||
|
if l:y > 0
|
||||||
|
if l:y > 1
|
||||||
|
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-[0-' . (l:y - 1) . ']\d)|'
|
||||||
|
else
|
||||||
|
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-0\d)|'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" PART 6. Days of the month part 2.
|
||||||
|
" i.e. for 2017-09-07: "2017-09-0[0-6]"
|
||||||
|
" for 2017-12-29: "2017-12-2[0-8]"
|
||||||
|
let l:y = strpart(printf('%02d', l:day), 0, 1) " First digit of the day
|
||||||
|
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-' . l:y
|
||||||
|
let l:y = strpart(printf('%02d', l:day), 1, 1) " Last digit of the day
|
||||||
|
if l:y > 0
|
||||||
|
let l:overdueRex = l:overdueRex . '[0-' . (l:y - 1) . ']'
|
||||||
|
else
|
||||||
|
let l:overdueRex = l:overdueRex . '0'
|
||||||
|
endif
|
||||||
|
let l:overdueRex = l:overdueRex . ')'
|
||||||
|
|
||||||
|
let l:overdueRex = l:overdueRex . ')'
|
||||||
|
|
||||||
|
return l:overdueRex
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
execute 'syntax match TodoOverDueDate /\v\c<due:' . todo#GetDateRegexForPastDates() . '>/'
|
||||||
|
highlight default link TodoOverDueDate Error
|
||||||
|
|
||||||
let b:current_syntax = "todo"
|
let b:current_syntax = "todo"
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
# lorem_ipsum
|
|
||||||
example task
|
|
||||||
# end_lorem_ipsum
|
|
||||||
|
|
||||||
# date_after_priority
|
|
||||||
(A) Call Mom
|
|
||||||
# end_date_after_priority
|
|
||||||
|
|
||||||
# date_after_priority_visual
|
|
||||||
(A) Call Mom
|
|
||||||
(B) Call Dad
|
|
||||||
# end_date_after_priority_visual
|
|
||||||
|
|
||||||
# existing_date_no_priority
|
|
||||||
2014-05-06 example task
|
|
||||||
# end_existing_date_no_priority
|
|
||||||
|
|
||||||
# existing_date_after_priority
|
|
||||||
(A) 2014-05-06 Call Mom
|
|
||||||
# end_existing_date_after_priority
|
|
||||||
|
|
||||||
# existing_date_do_nothing
|
|
||||||
2014-05-06 example task
|
|
||||||
# end_existing_date_do_nothing
|
|
||||||
|
|
||||||
# non_existing_date_do_nothing
|
|
||||||
new todo line
|
|
||||||
# end_non_existing_date_do_nothing
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:context = todo#txt#__context__()
|
|
||||||
let s:context['data'] = s:here . '/tc_date.todo.txt'
|
|
||||||
let s:tc = unittest#testcase#new('Date', s:context)
|
|
||||||
|
|
||||||
let s:TODAY = strftime("%Y-%m-%d")
|
|
||||||
|
|
||||||
function! s:tc.test_current_date()
|
|
||||||
call self.assert_equal(s:TODAY, self.call('s:get_current_date', []))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:DATE_INSERTED = [
|
|
||||||
\ s:TODAY . ' example task',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:DATE_INSERTED_AFTER_PRIORITY = [
|
|
||||||
\ '(A) ' . s:TODAY . ' Call Mom',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:DATE_INSERTED_AFTER_PRIORITY_VISUAL = [
|
|
||||||
\ '(A) ' . s:TODAY . ' Call Mom',
|
|
||||||
\ '(B) ' . s:TODAY . ' Call Dad',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:DATE_INSERTED_DO_NOTHING = [
|
|
||||||
\ '2014-05-06 example task',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:NON_EXISTING_DATE_INSERTED_DO_NOTHING = [
|
|
||||||
\ s:TODAY . ' new todo line',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_insert_date_normal_mode()
|
|
||||||
call self.data.goto('lorem_ipsum')
|
|
||||||
call todo#txt#replace_date()
|
|
||||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_date_insert_mode()
|
|
||||||
call self.data.goto('lorem_ipsum')
|
|
||||||
execute 'normal idate '
|
|
||||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_date_visual_mode()
|
|
||||||
call self.data.visual_execute('call todo#txt#replace_date()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_date_after_priority_normal_mode()
|
|
||||||
call self.data.execute('call todo#txt#replace_date()', 'date_after_priority')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('date_after_priority'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_date_after_priority_visual_mode()
|
|
||||||
call self.data.visual_execute('call todo#txt#replace_date()', 'date_after_priority_visual')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY_VISUAL, self.data.get('date_after_priority_visual'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_with_existing_date()
|
|
||||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_no_priority')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('existing_date_no_priority'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
|
||||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_after_priority')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('existing_date_after_priority'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
|
||||||
let g:todo_existing_date = 'n'
|
|
||||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_do_nothing')
|
|
||||||
call self.assert_equal(s:DATE_INSERTED_DO_NOTHING, self.data.get('existing_date_do_nothing'))
|
|
||||||
unlet g:todo_existing_date
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
|
||||||
let g:todo_existing_date = 'n'
|
|
||||||
call self.data.execute('call todo#txt#replace_date()', 'non_existing_date_do_nothing')
|
|
||||||
call self.assert_equal(s:NON_EXISTING_DATE_INSERTED_DO_NOTHING, self.data.get('non_existing_date_do_nothing'))
|
|
||||||
unlet g:todo_existing_date
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# lorem_ipsum
|
|
||||||
first task to be marked as done
|
|
||||||
second task to be marked as done
|
|
||||||
2015-05-20 third task to be marked as done
|
|
||||||
# end_lorem_ipsum
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:context = todo#txt#__context__()
|
|
||||||
let s:context['data'] = s:here . '/tc_mark_as_done.todo.txt'
|
|
||||||
let s:tc = unittest#testcase#new('Mark As Done', s:context)
|
|
||||||
|
|
||||||
let s:TODAY = strftime("%Y-%m-%d")
|
|
||||||
|
|
||||||
let s:FIRST_TASK_DONE = [
|
|
||||||
\ 'x ' . s:TODAY . ' first task to be marked as done',
|
|
||||||
\ 'second task to be marked as done',
|
|
||||||
\ '2015-05-20 third task to be marked as done',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:ALL_TASKS_DONE = [
|
|
||||||
\ 'x ' . s:TODAY . ' first task to be marked as done',
|
|
||||||
\ 'x ' . s:TODAY . ' second task to be marked as done',
|
|
||||||
\ 'x ' . s:TODAY . ' 2015-05-20 third task to be marked as done',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_mark_as_done()
|
|
||||||
call self.data.goto('lorem_ipsum')
|
|
||||||
call todo#txt#mark_as_done()
|
|
||||||
call self.assert_equal(s:FIRST_TASK_DONE, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_mark_range_as_done()
|
|
||||||
call self.data.execute('call todo#txt#mark_as_done()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:ALL_TASKS_DONE, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_mark_selection_as_done()
|
|
||||||
call self.data.visual_execute('call todo#txt#mark_as_done()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:ALL_TASKS_DONE, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# insert_priority
|
|
||||||
example task
|
|
||||||
# end_insert_priority
|
|
||||||
|
|
||||||
# replace_priority
|
|
||||||
(A) example task
|
|
||||||
# end_replace_priority
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:context = todo#txt#__context__()
|
|
||||||
let s:context['data'] = s:here . '/tc_priority.todo.txt'
|
|
||||||
let s:tc = unittest#testcase#new('Priority', s:context)
|
|
||||||
|
|
||||||
let s:TODAY = strftime("%Y-%m-%d")
|
|
||||||
|
|
||||||
let s:PRIORITY_INSERTED = [
|
|
||||||
\ '(A) example task',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:PRIORITY_REPLACED = [
|
|
||||||
\ '(C) example task',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_insert_priority()
|
|
||||||
call self.data.goto('insert_priority')
|
|
||||||
call todo#txt#prioritize_add('A')
|
|
||||||
call self.assert_equal(s:PRIORITY_INSERTED, self.data.get('insert_priority'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_replace_priority()
|
|
||||||
call self.data.goto('replace_priority')
|
|
||||||
call todo#txt#prioritize_add('C')
|
|
||||||
call self.assert_equal(s:PRIORITY_REPLACED, self.data.get('replace_priority'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# lorem_ipsum
|
|
||||||
(B) Linear regression Rnet=Qh@Qle. @cons_emp_model
|
|
||||||
(B) Review key questions. @benchmarking
|
|
||||||
(A) simple model first @cons_emp_model
|
|
||||||
# end_lorem_ipsum
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:tc = unittest#testcase#new('Sort Context',
|
|
||||||
\ { 'data': s:here . '/tc_sort_context.todo.txt' })
|
|
||||||
|
|
||||||
let s:LEADER = mapleader
|
|
||||||
|
|
||||||
let s:SORTED_TASKS = [
|
|
||||||
\ '(B) Review key questions. @benchmarking',
|
|
||||||
\ '(B) Linear regression Rnet=Qh@Qle. @cons_emp_model',
|
|
||||||
\ '(A) simple model first @cons_emp_model',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_sort_by_context()
|
|
||||||
call self.data.visual_execute('call todo#txt#sort_by_context()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# lorem_ipsum
|
|
||||||
(B) 2013-03-15 2015-03-17
|
|
||||||
(B) 2012-04-16 2015-04-16
|
|
||||||
(A) 2013-03-16 2013-03-10
|
|
||||||
# end_lorem_ipsum
|
|
||||||
# task_with_no_date
|
|
||||||
2013-03-15 task with date
|
|
||||||
task with no date
|
|
||||||
2013-03-15 task with date
|
|
||||||
2013-03-15 task with date
|
|
||||||
task with no date
|
|
||||||
# end_task_with_no_date
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:tc = unittest#testcase#new('Sort Date',
|
|
||||||
\ { 'data': s:here . '/tc_sort_date.todo.txt' })
|
|
||||||
|
|
||||||
let s:LEADER = mapleader
|
|
||||||
|
|
||||||
let s:SORTED_TASKS = [
|
|
||||||
\ '(B) 2012-04-16 2015-04-16',
|
|
||||||
\ '(B) 2013-03-15 2015-03-17',
|
|
||||||
\ '(A) 2013-03-16 2013-03-10',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:SORTED_TASKS_WITH_NO_DATE = [
|
|
||||||
\ '2013-03-15 task with date',
|
|
||||||
\ '2013-03-15 task with date',
|
|
||||||
\ '2013-03-15 task with date',
|
|
||||||
\ 'task with no date',
|
|
||||||
\ 'task with no date',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_sort_by_date()
|
|
||||||
call self.data.visual_execute('call todo#txt#sort_by_date()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tc.test_sort_by_date_with_tasks_without_date()
|
|
||||||
call self.data.visual_execute('call todo#txt#sort_by_date()', 'task_with_no_date')
|
|
||||||
call self.assert_equal(s:SORTED_TASKS_WITH_NO_DATE, self.data.get('task_with_no_date'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# lorem_ipsum
|
|
||||||
(B) Linear regression Rnet=Qh+Qle. +cons_emp_model
|
|
||||||
(B) Review key questions. +benchmarking
|
|
||||||
(A) simple model first +cons_emp_model
|
|
||||||
# end_lorem_ipsum
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
let s:here = expand('<sfile>:p:h')
|
|
||||||
let s:tc = unittest#testcase#new('Sort Project',
|
|
||||||
\ { 'data': s:here . '/tc_sort_project.todo.txt' })
|
|
||||||
|
|
||||||
let s:LEADER = mapleader
|
|
||||||
|
|
||||||
let s:SORTED_TASKS = [
|
|
||||||
\ '(B) Review key questions. +benchmarking',
|
|
||||||
\ '(B) Linear regression Rnet=Qh+Qle. +cons_emp_model',
|
|
||||||
\ '(A) simple model first +cons_emp_model',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
function! s:tc.test_sort_by_project()
|
|
||||||
call self.data.visual_execute('call todo#txt#sort_by_project()', 'lorem_ipsum')
|
|
||||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet s:tc
|
|
||||||
Reference in New Issue
Block a user