emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* syncing with google calendar, file changed on disk
@ 2012-09-13 13:37 Tyler Smith
  0 siblings, 0 replies; 4+ messages in thread
From: Tyler Smith @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Emacs-orgmode

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:xxx@gmail.com
495c493
< ACTION:DISPLAY
---
> ACTION:EMAIL
496a495,496
> SUMMARY:Alarm notification
> ATTENDEE:mailto:xxx@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* syncing with google calendar, file changed on disk
@ 2012-09-13 15:24 Tyler Smith
  2012-09-13 15:39 ` Nick Dokos
  0 siblings, 1 reply; 4+ messages in thread
From: Tyler Smith @ 2012-09-13 15:24 UTC (permalink / raw)
  To: Emacs-orgmode

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:xxx@gmail.com
495c493
< ACTION:DISPLAY
---
> ACTION:EMAIL
496a495,496
> SUMMARY:Alarm notification
> ATTENDEE:mailto:xxx@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: syncing with google calendar, file changed on disk
  2012-09-13 15:24 syncing with google calendar, file changed on disk Tyler Smith
@ 2012-09-13 15:39 ` Nick Dokos
  2012-09-13 16:52   ` Arun Persaud
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Dokos @ 2012-09-13 15:39 UTC (permalink / raw)
  To: Tyler Smith; +Cc: Emacs-orgmode

Tyler Smith <sedgeboy@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:xxx@gmail.com
> 495c493
> < ACTION:DISPLAY
> ---
> > ACTION:EMAIL
> 496a495,496
> > SUMMARY:Alarm notification
> > ATTENDEE:mailto:xxx@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: syncing with google calendar, file changed on disk
  2012-09-13 15:39 ` Nick Dokos
@ 2012-09-13 16:52   ` Arun Persaud
  0 siblings, 0 replies; 4+ messages in thread
From: Arun Persaud @ 2012-09-13 16:52 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-13 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-13 15:24 syncing with google calendar, file changed on disk Tyler Smith
2012-09-13 15:39 ` Nick Dokos
2012-09-13 16:52   ` Arun Persaud
  -- strict thread matches above, loose matches on Subject: below --
2012-09-13 13:37 Tyler Smith

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).