AnthonyDiGirolamo / todotxt-machine

an interactive terminal based todo.txt file editor with an interface similar to mutt
https://pypi.python.org/pypi/todotxt-machine/
GNU General Public License v3.0
245 stars 37 forks source link

autorefresh todo list from disk #9

Open felipesere opened 10 years ago

felipesere commented 10 years ago

Hi, I wanted to use todotxt-machine as a view for my todo.txt. I'll be adding most of my todos from todo.txt-vim while keeping todotxt-machine open on a separate tab. Is it possible to make it refresh the list from the file?

fdlm commented 10 years ago

I started implementing this functionality, since I need it to be able to sync my todo.txt over multiple devices but want to keep the terminal with todotxt-machine open. Find the code here: ad28e62db994f3dcfc158093c5fc5496df11b8f8

There are however a few things that need to be discussed. First of all, how to handle the case where you entered a new todo item within todotxt-machine but did not save it yet (e.g. because you forgot), and a new todo item is added from somewhere else. In my current implementation, all unsaved changes are lost, which obviously is not the way to go.

A possibility to overcome this would be to automatically save the todo.txt file after every change. IMHO, this shouldn't be a problem, but people have asked to be able to explicitly specify when todotxt-machine should write changes to disk (see Issue #6), so I don't know...

Any opinions?

felipesere commented 10 years ago

I also started working on this :) In my variation I use watchdog to watch the filesystem.

Saving any modification straight to disk should be valid. It does not help if the file is also being manipulated by a remote client. Imagine having you file in dropbox. Once you phone syncs those changes into dropbox, conflicts should pop up. I would ignore "conflict resolution" for the time being.

I do think though that some refactoring is needed to make the code more manageable.

fdlm commented 10 years ago

Great!

Using watchdog, are you able to update the todo list without waiting for a keypress? That would be really great. The downside is of course that it introduces another dependency, but it might be worth it!

The sync problem you mentioned comes up regardless of which todo.txt manager you use when using simple cloud solutions like Dropbox. I don't see how one could solve it within the application. So, I agree, we should ignore it.

felipesere commented 10 years ago

Yeah, watchdog is pretty neat. As far as I can tell, it is multi-platform. I'll see if I can push my branch into a fork some time this week.

AnthonyDiGirolamo commented 10 years ago

Watchdog looks very cool, I'd be happy to merge a pull request with that functionality. I'm currently working on throwing away the screen.py file which is completely unmaintainable and using urwid for the ui.

matze commented 10 years ago

I'm currently working on throwing away the screen.py file which is completely unmaintainable and using urwid for the ui.

I hope you keep the UI elements as they are. I really appreciate the UI.

AnthonyDiGirolamo commented 10 years ago

I hope you keep the UI elements as they are. I really appreciate the UI.

I definitely want to keep the same ui appearance and feel.

AnthonyDiGirolamo commented 10 years ago

Hi felipesere, I've implemented reloading/reverting a todo.txt file from disk on a keypress (not automatically) implemented in the urwid branch now. Not all the original functionality is in the urwid branch. Hopefully that will help with implementing autoreloading.