freitass / todo.txt-vim

Vim plugin for Todo.txt
486 stars 121 forks source link

Do not add several times date and priority #37

Closed thperret closed 9 years ago

thperret commented 9 years ago

When there is already a date on the current line using <localleader>d add a new one (becoming the new creation date). Adding a new date should replace the old one (or do nothing, with an option selecting the desired behaviour). The same happens with the priority so adding a priority should replace the old one. e.g.: when the priority is (D), using <localleader>a on the line should replace the priority by (A)

edit: PS: thanks for this awesome plugin!

freitass commented 9 years ago

@thperret thanks for the great suggestions! Please let me know if the behavior is ok.

thperret commented 9 years ago

Amazing! Just (rapidly) tested and everything looks great. Thanks.

thperret commented 9 years ago

Looks like I tested it too rapidly, just saw that with a new todo line you can't add the date if the g:todo_existing_date is set to nothing ('n'): in that case, <localleader>d really do nothing. The replace option works as expected.

freitass commented 9 years ago

I didn't quite understand the issue. What do you mean with "new todo line"? Can you provide an example? Thanks!

thperret commented 9 years ago

Oh sorry I didn't make myself clear. If you have something like:

new todo line
(A) 2015-05-10 old todo line with date
(B) 2015-05-12 another todo line with date

and you try to add the date on the first line with <localleader>d and with g:todo_existing_date='n' nothing will happen (no date is added to the line). But it doesn't happen with g:todo_existing_date='r' (in that case, the date is added)

thperret commented 9 years ago

Hi, with the new fix, the date is effectively added but there is an error when I run <localleader>d :

Error detected while processing function todo#txt#prepend_date:
line    2:
E15: Invalid expression: 
E15: Invalid expression: (current_line =~ '^\(([a-zA-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') &&

And furthermore, the date is modified whether you set the g:todo_existing_date to 'n' or 'r'

freitass commented 9 years ago

That's weird. I'll take a look at it later today. If it's not asking too much, could you provide (an) example(s) of the modified date issue? It'll help me to understand the issue and to create tests to prevent regressions. Thanks!

freitass commented 9 years ago

I didn't read your last sentence carefully and thought is was about a different bug. In the end it was all about an inappropriate line break which was fixed. Thanks again!

thperret commented 9 years ago

Thanks to you for all your quick fixes!

BTW, I was thinking about some ideas for your plugin (or maybe it would be more suitable for a new plugin depending on this one). Would you mind to talk about that by mail (it would be better than here)?

freitass commented 9 years ago

@thperret I wouldn't mind talking about them by mail, but by suggesting new features here on GitHub we give other people the opportunity to suggest improvements and even implement them (and hopefully submit a pull request).

To help you decide whether this new feature fits in this plugin or should be a new one, keep in mind that I try to keep this plugin as simple as possible and in conformance with Todo.txt's format.

Thank you for your contributions!