We can sync this stuff nicely. Save the org buffers, sync, then revert to pull in changes. I’m not sure why the revert always prompts.
There is documentation on all of this in the Emacs Lisp manual (see info:elisp#Asynchronous Processes or online version). The sentinel function is called when the process changes state, and =”finished\n”= indicates a successful exit.
We first save all Org buffers. This causes a git commit to occur.
Then we switch to
*Org Sync Output*, which creates it if it doesn’t
exist (as with
C-x b). That buffer gets erased. Then, the
subprocess is called and the sentinel is set up. Since it runs
asynchronously, the output is visible in the buffer as it goes.
I found an example online for the make-process as well. There they
(lambda (_process event) ...) for the sentinel.
progn lets me use a list of multiple actions under the
(defun jgoerzen/org-sync-sentinel (_process retcode) "Handle output from the org-sync" (if (equal retcode "finished\n") (progn (org-revert-all-org-buffers) (org-id-update-id-locations) (org-mobile-pull) (org-mobile-push) (org-save-all-org-buffers) (switch-to-buffer "*Org Sync Output*") (make-process :name "org-sync" :buffer "*Org Sync Output*" :command (cl-list* "make" (list "-C" "~/org" "push")) ) ) ) ) (defun jgoerzen/org-sync () "Sync org." (interactive) (org-save-all-org-buffers) (switch-to-buffer "*Org Sync Output*") (erase-buffer) (make-process :name "org-sync" :buffer "*Org Sync Output*" :command (cl-list* "make" (list "-C" "~/org")) :sentinel 'jgoerzen/org-sync-sentinel ) ) (global-set-key (kbd "C-c s") 'jgoerzen/org-sync)