Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurring Tasks #41

Open
dubbitywap opened this issue Jun 16, 2015 · 5 comments
Open

Recurring Tasks #41

dubbitywap opened this issue Jun 16, 2015 · 5 comments

Comments

@dubbitywap
Copy link

Hello,

I have been using the great simpletask android app. The app has a nice feature that allows for recurring tasks by adding to the task line the following:

"rec:7d" will automatically create the same task due 7 days after the completion date, "rec:2w" will create the same task due 2 weeks from the completion date, etc...

I was playing around with the txt.vim file and added an if statement to the todo#txt#mark_as_done() function which mimics this behavior:

function! todo#txt#mark_as_done()
    let current_line = getline('.')
    if (current_line =~ 'rec\:\d\{1,4\}[d,w,y]')
        let recurrence_time = split(split(current_line,"rec:")[1]," ")[0][:-2]
        let recurrence_unit = split(split(current_line,"rec:")[1]," ")[0][-1:]
        if (recurrence_unit == 'd')
            let no_of_days = recurrence_time
        endif
        if (recurrence_unit == 'w')
            let no_of_days = 7*recurrence_time
        endif
        normal! yy P j
        execute 's/\d\{2,4\}-\d\{2\}-\d\{2\}/' . strftime('%Y-%m-%d',localtime()+24*3600*no_of_days)
        normal! k
    endif
    call s:remove_priority()
    call todo#txt#prepend_date()
    normal! Ix 
endfunction

Right now, it only works for days and weeks. Let me know if this works for you and if you have any ideas on how to add month/year recurrence.

@sercxanto
Copy link

I had no look at the code, but 👍 for support of recurring tasks in todo.txt-vim !

@freitass
Copy link
Owner

@dubbitywap this sounds like a nice feature! Pull requests are welcome. :)

@fretep
Copy link

fretep commented Oct 2, 2017

I like this. I have personally been using "recur:", and have been working on a pull request for this (I didn't see this until just now), but if "rec:" is being used elsewhere then I'll update to use this syntax. Is there any documentation on the specifics of this syntax anywhere?

It also looks to me like you are basing the new due date off the current time, rather than the due date in the task. I personally would prefer the recurring date to be consistent, i.e. I regularly complete tasks before/after the due date, but I still like the date of the recurring task to stay on track, i.e. 7 days from when it was due, not when I completed it. Is that reasonable behavior, or would people prefer it to be based on the actual completion date?

@fullstopslash
Copy link

It's way more predicable to have a recurring task based on due times. I vote that method.

@fretep
Copy link

fretep commented Oct 21, 2017

I have implemented recurring tasks with the rec: keyword syntax in my fork. If anyone wanted to have a play with my fork and give me some feedback, that would be awesome. It might take me a few weeks to get a pull request ready for this fork as I think it is quite diverged from the fork I work on and I don't have a lot of time at the moment.

I've been using it for about a week or so now, and I have to say I'm loving it. I was manually handling recurrence previously, and had never seen another implementation handle recurring tasks.

In an effort to ensure compatibility with other implementations, I have used the same syntax as described here and here, with the exception of business/working days.

I made <LocalLeader>x aware of recurring tasks and added a new mapping [count]<LocalLeader>p to postpone tasks by [count] days, which is also recurrence aware.

I discovered the other implementations have a "strict" and "non-strict" mode, which addresses my previous question, and both recurring from the due date (strict mode) and recurring from the completion date (non-strict) modes are implemented.

dbeniamine added a commit to dbeniamine/todo.txt-vim that referenced this issue Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants