emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Arun Persaud
Subject: Re: [O] syncing with google calendar, file changed on disk
Date: Thu, 13 Sep 2012 09:52:27 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]