[O] syncing with google calendar, file changed on disk

2012-09-13 Thread Tyler Smith
Hi,

Following the instructions from Worg (
http://orgmode.org/worg/org-tutorials/org-google-sync.html ), I've set
a cron job to download my google calendar, and use Eric Fraga's awk
script to convert it into google.org for inclusion in my agenda. This
works fine, and is currently my only syncing option as my access to
other web services (git, dropbox etc) is blocked at my workplace.

One small issue: the google calendar file changes regularly, even when
I haven't added or modified any appointments. As a consequence, I am
interrupted by Emacs reminding me that google.org has changed on disk,
and I need to respond before I can continue to browse my agenda. This
isn't a big deal, but maybe one of you know how to eliminate this
problem?

For the record, the sort of changes that I see are this:

~/.emacs.d/org$ diff google.org google.org-old
488c488
 ACTION:EMAIL
---
 ACTION:DISPLAY
490,491d489
 SUMMARY:Alarm notification
 ATTENDEE:mailto:x...@gmail.com
495c493
 ACTION:DISPLAY
---
 ACTION:EMAIL
496a495,496
 SUMMARY:Alarm notification
 ATTENDEE:mailto:x...@gmail.com


It seems the ACTION line switches back and forth between DISPLAY and
EMAIL. I don't understand the ics format to know what this means.

I have searched the mailing list and stackoverflow, but if this has
come up before I missed it. Thanks for your help,

Tyler



[O] syncing with google calendar, file changed on disk

2012-09-13 Thread Tyler Smith
Hi,

Following the instructions from Worg (
http://orgmode.org/worg/org-tutorials/org-google-sync.html ), I've set
a cron job to download my google calendar, and use Eric Fraga's awk
script to convert it into google.org for inclusion in my agenda. This
works fine, and is currently my only syncing option as my access to
other web services (git, dropbox etc) is blocked at my workplace.

One small issue: the google calendar file changes regularly, even when
I haven't added or modified any appointments. As a consequence, I am
interrupted by Emacs reminding me that google.org has changed on disk,
and I need to respond before I can continue to browse my agenda. This
isn't a big deal, but maybe one of you know how to eliminate this
problem?

For the record, the sort of changes that I see are this:

~/.emacs.d/org$ diff google.org google.org-old
488c488
 ACTION:EMAIL
---
 ACTION:DISPLAY
490,491d489
 SUMMARY:Alarm notification
 ATTENDEE:mailto:x...@gmail.com
495c493
 ACTION:DISPLAY
---
 ACTION:EMAIL
496a495,496
 SUMMARY:Alarm notification
 ATTENDEE:mailto:x...@gmail.com


It seems the ACTION line switches back and forth between DISPLAY and
EMAIL. I don't understand the ics format to know what this means.

I have searched the mailing list and stackoverflow, but if this has
come up before I missed it. Thanks for your help,

Tyler



Re: [O] syncing with google calendar, file changed on disk

2012-09-13 Thread Nick Dokos
Tyler Smith sedge...@gmail.com wrote:

 Hi,
 
 Following the instructions from Worg (
 http://orgmode.org/worg/org-tutorials/org-google-sync.html ), I've set
 a cron job to download my google calendar, and use Eric Fraga's awk
 script to convert it into google.org for inclusion in my agenda. This
 works fine, and is currently my only syncing option as my access to
 other web services (git, dropbox etc) is blocked at my workplace.
 
 One small issue: the google calendar file changes regularly, even when
 I haven't added or modified any appointments. As a consequence, I am
 interrupted by Emacs reminding me that google.org has changed on disk,
 and I need to respond before I can continue to browse my agenda. This
 isn't a big deal, but maybe one of you know how to eliminate this
 problem?
 
 For the record, the sort of changes that I see are this:
 
 ~/.emacs.d/org$ diff google.org google.org-old
 488c488
  ACTION:EMAIL
 ---
  ACTION:DISPLAY
 490,491d489
  SUMMARY:Alarm notification
  ATTENDEE:mailto:x...@gmail.com
 495c493
  ACTION:DISPLAY
 ---
  ACTION:EMAIL
 496a495,496
  SUMMARY:Alarm notification
  ATTENDEE:mailto:x...@gmail.com
 
 
 It seems the ACTION line switches back and forth between DISPLAY and
 EMAIL. I don't understand the ics format to know what this means.
 
 I have searched the mailing list and stackoverflow, but if this has
 come up before I missed it. Thanks for your help,
 

The brute force approach: make the cron job download to a different
file, diff the two and if the diff is just
ACTION:EMAIL--ACTION:DISPLAY lines and Alarm notification crud, then
throw away the downloaded file. If the diff is different, move the
downloaded file to google.org.

If you go this way, you might want to play around with different diff
formats to see which one is the easiest to parse for the minimal diff(s)
above.

Nick



Re: [O] syncing with google calendar, file changed on disk

2012-09-13 Thread Arun Persaud
Hi

I use the following bash script via cron to sync with google and revert
the buffer. I also keep my files in git, so there are some git commands
in here too:

#+BEGIN_SRC bash
#update calendar (this runs the awk script)
/home/arun/bin/google-get-calendar

#check if have any local changes, if so commit them
emacsclient -e (org-save-all-org-buffers)
git commit -am automatic update

# pull and push with rebase
git pull --rebase
git push

# git is synced now = auto-revert buffers
emacsclient -e (revbufs)

# export ics file, so that items show up on google
emacs --batch -l ~/.emacs  --eval '(defun ask-user-about-lock (file opp)
nil)' -f org-mycal-export

# copy to xxx.xxx.xxx, if ssh-agent knows about the key

if [ -e ~/.sshagent ] ; then
   . ~/.sshagent
fi

ssh-add -l |grep cf:c4:58  scp -v ~/org/org.ics
xxx.xxx.xxx:public_html/cryptic-file-name.ics

#+END_SRC

and the export is handled by:

#+BEGIN_SRC emacs-lisp
;;; org - google export via .ics
(setq org-icalendar-use-UTC-date-time nil)
(setq org-icalendar-timezone America/Los_Angeles)

(defun org-mycal-export-limit ()
  Limit the export to items that have a date, time and a range. Also
exclude certain categories.
  (setq org-tst-regexp \\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ...
[0-9]\\{2\\}:[0-9]\\{2\\}[^\r\n]*?\\))
  (setq org-tstr-regexp (concat org-tst-regexp --?-? org-tst-regexp))
  (save-excursion
; get categories
(setq mycategory (org-get-category))
; get start and end of tree
(org-back-to-heading t)
(setq mystart(point))
(org-end-of-subtree)
(setq myend  (point))
(goto-char mystart)
; search for timerange
(setq myresult (re-search-forward org-tstr-regexp myend t))
; search for categories to exclude
(setq mycatp (member mycategory org-export-exclude-category))
; return t if ok, nil when not ok
(if (and myresult (not mycatp)) t nil)))

(defun org-mycal-export ()
  (let ((org-icalendar-verify-function 'org-mycal-export-limit))
(org-export-icalendar-combine-agenda-files)))
#+END_SRC

HTH

Arun