An Emacs pkg to merge changes in shared Emacs/Orgzly Org notes.
It's possible that Emacs and Orgzly mobile app can modify the same Org note shared via $cloud. Currently there is no good way to resolve those changes. git is a good solution and on the Orgzly todo list. Until that feature is avail here is a wrapper around Emacs Ediff to merge changes manually and keep the shared note file in sync.
emacs ediff org-mode orgzly dropbox cloud sync
(later will be avail on MELPA if all goes well)
;; dependancies: make sure f & s & dash pkgs installed
(add-to-list 'load-path "/path/to/ogmerge")
(require 'ogmerge)
The first two need to be looked at closely and set correctly in your Emacs init file. The rest of the defaults are probably fine.
(defvar ogmerge-local-dir (f-canonical org-directory)
"Local org dir aka Emacs org dir.")
(defvar ogmerge-remote-dir (f-canonical org-orgzly-directory)
"Remote org dir aka upstream in cloud (aka Orgzly Save path in Dropbox).")
(defvar ogmerge-backup? t
"Pre destructive op, make an emergency backup copy in subdir ogmerge-backup-dir.")
(defvar ogmerge-backup-dir ".ogmerge-bkup"
"Name of subdir for emergency copies.")
(defvar ogmerge-verbose t
"Get more output to *messages*.")
WARNING - this is immature software and thus needs more real world testing so make sure you have backups of any data files you can't afford to lose (at least until you are convinced yourself it is solid or at least the emergency backup copies it makes are solid (see init var ogmerge-backup? and ogmerge-backup-dir)).
- Orgzly Save (long-press Forced if needbe) note to $cloud
- Emacs run ogmerge-ediff (and answer filename prompt with shared org note (base) filename)
- ediff merge/resolve changed chunks
- ediff save/overwrite (save-buffer) merged buf to same local file (answer 'y' to prompts to overwrite)
- ediff quit
- Emacs ogmerge-push local file to $cloud (orgzly) dir (and answer filename prompt with shared org note (base) filename)
- Orgzly Load note
- Repeat above for each Orgzly instance
- After all of them done, Orgzly Load all instances (except last one synced in step 1)
- ediff skillz def a plus here. But if not currently avail then this is good way to learn it. It's def a non-trivial -- UI-wise and concept-wise -- Emacs app.
- Typically in ediff you'll choose file A or file B for each change chunk, but for this type of merge (2 way) sometimes (appended chunks in A&B for example) you may want both and thus you should hand edit the merge buf (better way?).
- Orgzly likes adding blank lines so don't ediff merge them out on Emacs else u will keep seeing them come back -- zombielike -- to haunt you and must re-merge again and again.
- BTW if you don't dig your ediff config try mines
;; don't start another frame
;; this is done by default in preluse
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; put windows side by side
(setq ediff-split-window-function (quote split-window-horizontally))
;; revert windows on exit - needs winner mode
(winner-mode)
(add-hook 'ediff-after-quit-hook-internal 'winner-undo)
(add-hook 'ediff-prepare-buffer-hook #'show-all)
- Only tested with Dropbox as $cloud so far
- Only real world tested for 8 weeks by 1 person (need users/testers!)
- Only tested with shared file between one Emacs and 1&2 Orgzly Android devices
CASK_EMACS=/usr/local/Cellar/emacs/24.5/bin/emacs cask emacs --batch --script test/ogmerge-test.el
ogmerge-test-ediff ... PASS.
ogmerge-test-push ... PASS.
ogmerge-test-pull ... PASS.
ogmerge-test-savecopy ... PASS.
- Mac OS Homebrew installed cask 0.7.4 seems not to have latest fixes from github bundled so if cask emacs fails, try swapping in bin/cask from github (works for /me:-)
- should offer -- when possible -- auto merge option? Don't think it's possible w/2way merge. See Live-to-merge link below.
Ogmerge is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Ogmerge is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
https://www.gnu.org/software/emacs/manual/html_node/ediff/
http://blog.plasticscm.com/2010/11/live-to-merge-merge-to-live.html?m=1