From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Persaud Subject: Re: syncing with google calendar, file changed on disk Date: Thu, 13 Sep 2012 09:52:27 -0700 Message-ID: <50520F4B.4090302@lbl.gov> References: <10479.1347550796@alphaville> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCCgJ-0000L2-EQ for emacs-orgmode@gnu.org; Thu, 13 Sep 2012 12:54:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCCgI-0006XN-Aw for emacs-orgmode@gnu.org; Thu, 13 Sep 2012 12:54:23 -0400 Received: from ironport4.lbl.gov ([128.3.41.45]:55168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCCgI-0006Vz-4T for emacs-orgmode@gnu.org; Thu, 13 Sep 2012 12:54:22 -0400 Received: by dadi14 with SMTP id i14so2095751dad.0 for ; Thu, 13 Sep 2012 09:52:30 -0700 (PDT) In-Reply-To: <10479.1347550796@alphaville> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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/.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