From 164a5c07f38ac14e66ff0a8e35e57e4bbf8c84c0 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Fri, 14 Apr 2023 11:57:16 -0400 Subject: [PATCH] Try to improve the org sync strategy Save org files upon changing todo state, but use a timer to prevent saving too many times when (e.g.) cycling through todo states. --- global.org | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/global.org b/global.org index 25528f7..ef9d78c 100644 --- a/global.org +++ b/global.org @@ -1404,6 +1404,17 @@ (add-hook 'auto-save-hook 'org-save-all-org-buffers-except-current) #+end_src + Also, we need to trigger saving once the state changes, so that we + are always able to sync the right state; saving runs with a timer + so that it is not triggered e.g. when cycling through states. The + problem with the current implementation is that we do not know + which buffer has been modified if the state has been changed using + the agenda, which is kind of the point… + #+begin_src emacs-lisp + (add-hook 'org-after-todo-state-change-hook + (lambda () + (when buffer-file-name (save-buffer-with-timer 5)))) + #+end_src *** Reverting stuff from orgzly #+begin_src emacs-lisp (defun org-revert-all-orgzly-buffers (&optional ALL)