JulienMasson / org-gtasks

Org sync with Google Tasks
GNU General Public License v3.0
49 stars 16 forks source link

Persist across emacs restarts #15

Closed carwin closed 2 years ago

carwin commented 2 years ago

I'm not sure if the title is the best way to describe this, but after I restart Emacs, I'm unable to run org-gtrasks-push-current from the file(s) that org-gtasks originally pulled in. It appears that there are no task lists on a fresh boot, I have to run org-gtasks and go through the minibuffer prompts to get everything connecting again.

I'm sure I'm missing something, but is there a way I can circumvent this / keep the contexts of my lists across restarts of Emacs?

Clausinho commented 2 years ago

I also experience this. I am suspecting that the exposed functions weren't updated to use the functions that the minibuffer uses?

JulienMasson commented 2 years ago

Hi @carwin, @Clausinho, sorry for the late reply, just came back from vacations.

I'm unable to run org-gtrasks-push-current from the file(s) that org-gtasks originally pulled in. It appears that there are no task lists on a fresh boot, I have to run org-gtasks and go through the minibuffer prompts to get everything connecting again.

After fresh restart, tasklists for each account is empty (C-h v org-gtasks-accounts). That is expected because I did not implement mechanism to save tasklists infos.

However when you call org-gtasks-push-current, if no tasklist is found you should have in minibuffer the following prompt: "No tasklist found, do you want pull this account ?"

The limitation of the current implementation is that you must pull first an account before pushing something on this account.

carwin commented 2 years ago

Thanks for the reply @JulienMasson - it sounds like this is all working as expected then.

For some context,

I've been using this package as part of a workflow where certain tasks get duplicated into a specific Org file on capture, which gets synced up to Google Tasks. Basically, all captures go into an inbox.org and some of them also get dumped into my_gtasks.org. The challenge I've been having is that changes can happen bi-bidirectionally - sometimes things get added to Google Tasks externally (via other integrations) and sometimes tasks are added in Emacs while I'm offline. Tasks added by me directly through the capture process are my priority.

For that reason, I need to ensure that my local file doesn't get overwritten by the org-gtasks-pull- functions, which seem to always prefer content from GTasks.

One way I've been trying to handle this is by just pulling as soon as Emacs starts so I'm always synced up when I start working, but as you described above, there are no tasklists on restart.

I've had mild success doing this:

;; hook this into the startup hook or something similar, and perhaps
;; run the pull command behind the scenes if we get a tasklist we know about.
(org-gtasks-fetch-tasklists (org-gtasks-find-account-by-name "ACCOUNT_NAME"))

but results have been spotty and I haven't yet dug into why.

Would you be opposed to a feature request for persisting task lists? If that's not something you want this package to do, would you be open to adjusting the way the pull functions work or adding some kind of org-gtasks-refile-local-on-pull type function to avoid overwriting local content?

JulienMasson commented 2 years ago

@carwin okay I see your point, I have a different workflow.

I use mainly my phone and I want Emacs updated with that.

In my case everytime I org-gtasks-pull first.

However we should not have this limitation.

So I've added a new action fetch in a dedicated branch: https://github.com/JulienMasson/org-gtasks/pull/17

The goal is to able to fetch all infos without updating org files. If I'm correct, this is what you're looking for.

I've tested different scenarios, it seems okay.

Can you please tell me if that work for you ?

With this patch, you can do that during the startup:

(dolist (account org-gtasks-accounts)
  (org-gtasks-check-token account)
  (org-gtasks-fetch account "ALL"))

Thanks

carwin commented 2 years ago

Thanks @JulienMasson - looks like I missed the notification for you last comment, but I did get the issue closed notification. This should work great, thank you!

JulienMasson commented 2 years ago

@carwin no problem, the commit merged https://github.com/JulienMasson/org-gtasks/pull/17 should help you in your workflow :)