Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-26 Thread Samuel Loury
Melleus mell...@openmailbox.org writes:

 Richard Lawrence richard.lawre...@berkeley.edu writes:

 Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
 two-way file sync between *nix and Windows.  I've never tried it; has
 anyone else?

 I can recommend rsync (you can get it from Cygwin for Windows) for such
 things. No fancy GUIs though. It just works.
I have not tried it yet, but
https://github.com/dooblem/bsync/blob/master/README.md could be of some
help. I guess it does like unison but using rsync.

Also, if you handle big files also, you may try git-annex
(http://git-annex.branchable.com/). I could be used to simply
synchronize files with git config annex.largefiles 'exclude=*' and
git annex sync.

--
Konubinix
GPG Key: 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE  5C36 75D2 3CED 7439 106A


pgpnQ7lfyjwxH.pgp
Description: PGP signature


Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-26 Thread Thierry Banel
You can try GIT-ANNEX
https://git-annex.branchable.com/

It is a synchronizer built on top of GIT



Le 24/05/2014 07:11, Xebar Saram a écrit :
 Hi all

 i need to sync my main work TODO org file between my work PC and
 laptop i carry around on work related trips and when im at home. i
 have tried several methods buy really none of them work.

 i mainly used git over the last 6 months but that forces me to
 pull/commit/push manually each time i add something to either machine
 and that is really annoying. plus i get merge conflicts all the time

 I have tried dropbox at the past but again this causes conflicts, isnt
 reliable to me (on my linux laptop it doesn't always resume sync after
 sleep)

 I am using linux (arch linux on laptop  and debian on work PC to be
 precise)

 Also i use mobileorg on phones/tablets which works with various levels
 of success :)

 any advice would be hugely appreciated!

 thanks alot

 Z




Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-25 Thread Josh Berry
On Sat, May 24, 2014 at 1:11 AM, Xebar Saram zelt...@gmail.com wrote:

  need to sync my main work TODO org file between my work PC and laptop i
 carry around on work related trips and when im at home. i have tried
 several methods buy really none of them work.

 i mainly used git over the last 6 months but that forces me to
 pull/commit/push manually each time i add something to either machine and
 that is really annoying. plus i get merge conflicts all the time


I can't really help for the other items too easily, but have you tried
*not* syncing edits between a single files?  This would at least stop the
merge conflicts.

That is, if you had two sets of all of your .org files, one under
desktop/ and the other under laptop/, then you could setup a basic hook
in git that pushes/pulls on every change.  I believe org is good with the
refile commands that moving between the flies shouldn't be that much of a
burden, if you do that often.  Otherwise, things definitely work well for
agenda mode and such.

-josh


Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Richard Lawrence
Hi Xebar,

Xebar Saram zelt...@gmail.com writes:

 i mainly used git over the last 6 months but that forces me to
 pull/commit/push manually each time i add something to either machine and
 that is really annoying. plus i get merge conflicts all the time

 I have tried dropbox at the past but again this causes conflicts,
 isntreliable to me (on my
 linux laptop it doesn't always resume sync after sleep)

If neither git nor Dropbox works for you, I'm not sure this will be
helpful, but...

I personally use git for this.  To keep the effort of syncing and
merging low, I have a cron job set up to automatically commit in certain
repositories containing my Org files every hour.  It's just a
quick-and-dirty hack, but here it is:

#+BEGIN_SRC bash
#!/bin/bash
# Add org file changes to the repository
ROOT=$HOME
REPOS=org Documents/philosophy/dissertation Documents/philosophy/teaching 
Documents/philosophy/reading src/emacs

commit_and_push()
{
  for REPO in $REPOS
  do
  echo Repository: $ROOT/$REPO
  cd $ROOT/$REPO

  if [ ! -d .git ]; then
  echo Not a git repository; skipping
  continue
  fi
  if [ ! -r autocommits ]; then
  echo No autocommits file found; skipping
  continue
  fi

  # Remove deleted files
  git ls-files --deleted -z | xargs -0 git rm /dev/null 21

  # Add files on whitelist to commit for current branch
  while read FILE
  do
  git add $FILE
  done  autocommits

  git commit -m $(date) from $(hostname) by autocommit.sh
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git commit failed with exit status $STATUS
  fi

  # Push the current branch
  # requires branch.name.remote to be specified in git config
  # and ideally push.default = tracking 
  git push --porcelain
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git push failed with exit status $STATUS
  fi

  done
}

pull()
{
  for REPO in $REPOS
  do
  echo Repository: $REPO
  cd $ROOT/$REPO

  git status | grep 'modified:'
  if [ $? == 0 ]; then
  echo modified files present; fetching, but not pulling.
  CMD=fetch
  else
  CMD=pull
  fi

  git $CMD
  STATUS=$?
  if [ $STATUS != 0 ]; then
  echo git $CMD failed with exit status $STATUS
  fi
  done
}

case $1 in
  commit)
  commit_and_push
  ;;
  pull)
  pull
  ;;
  *)
  echo Usage: $0 {commit|pull}
  exit 1
  ;;
esac

exit 0
#+END_SRC

This script requires a file called autocommits in each repository in
$REPOS which is a whitelist of files to autocommit changes in.  Most of
my Org files are on such a list.

I run this from Cron like:
#+BEGIN_SRC cron
0 * * * * ~/bin/autocommits.sh commit /dev/null 21 
#+END_SRC

To make sure my changes are saved before this script runs, I have in my .emacs:
#+BEGIN_SRC elisp
(run-at-time 00:59 3600 'org-save-all-org-buffers) ; cron commits on the hour
(add-hook 'before-save-hook 'org-update-all-dblocks)
#+END_SRC

And finally, to pull the autocommitted changes on a new machine:
$ autocommits.sh pull

So you still have to manually pull and fix any merge conflicts, but I
find that committing often generally keeps the work involved here
minimal (because I can't usually work on two machines at once!).

Hope that helps!

Best,
Richard




Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Richard Lawrence
Martin Schöön martin.sch...@gmail.com writes:

 What if, as is the case for me, work computer runs Win7 and home computer
 runs Linux?
 Now I use a manual 'system' which shouldn't be necessary, I think.

Well, I don't run Windows on any of my systems, so someone else probably
has better advice here.

I'm pretty sure git runs on Windows, and in theory you should be able to
do something similar to the Bash script/cron job setup I described using
batch files.  But I'm no expert on that.

Another alternative would be to write a short ELisp program to do the
same thing, using `run-at-time' and `shell-command'...though I don't
know how shell-command works on Windows.

Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
two-way file sync between *nix and Windows.  I've never tried it; has
anyone else?

-- 
Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)



Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Melleus
Richard Lawrence richard.lawre...@berkeley.edu writes:

 Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
 two-way file sync between *nix and Windows.  I've never tried it; has
 anyone else?

I can recommend rsync (you can get it from Cygwin for Windows) for such
things. No fancy GUIs though. It just works.




Re: [O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-24 Thread Ken Mankoff

Do you have auto-revert enabled for that file? At the top of a
dropbox-shared Org file I have this:

# -*- coding: utf-8; eval: (auto-revert-mode 1); -*-

I still find it a bit buggy, and also have this code snippet which I
execute whenever I begin editing in that Org file. I also try to
remember to save it when done.

#+BEGIN_SRC emacs-lisp :results none
(revert-buffer nil t)
#+END_SRC

  -k.

On 2014-05-24 at 01:11, Xebar Saram zelt...@gmail.com wrote:
 Hi all

 i need to sync my main work TODO org file between my work PC and laptop i
 carry around on work related trips and when im at home. i have tried
 several methods buy really none of them work.

 i mainly used git over the last 6 months but that forces me to
 pull/commit/push manually each time i add something to either machine and
 that is really annoying. plus i get merge conflicts all the time

 I have tried dropbox at the past but again this causes conflicts,
 isntreliable to me (on my
 linux laptop it doesn't always resume sync after sleep)

 I am using linux (arch linux on laptop  and debian on work PC to be precise)

 Also i use mobileorg on phones/tablets which works with various levels of
 success :)

 any advice would be hugely appreciated!

 thanks alot

 Z



[O] Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc

2014-05-23 Thread Xebar Saram
Hi all

i need to sync my main work TODO org file between my work PC and laptop i
carry around on work related trips and when im at home. i have tried
several methods buy really none of them work.

i mainly used git over the last 6 months but that forces me to
pull/commit/push manually each time i add something to either machine and
that is really annoying. plus i get merge conflicts all the time

I have tried dropbox at the past but again this causes conflicts,
isntreliable to me (on my
linux laptop it doesn't always resume sync after sleep)

I am using linux (arch linux on laptop  and debian on work PC to be precise)

Also i use mobileorg on phones/tablets which works with various levels of
success :)

any advice would be hugely appreciated!

thanks alot

Z