emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Arun Persaud <apersaud@lbl.gov>
To: emacs-orgmode@gnu.org
Subject: Re: syncing with google calendar, file changed on disk
Date: Thu, 13 Sep 2012 09:52:27 -0700	[thread overview]
Message-ID: <50520F4B.4090302@lbl.gov> (raw)
In-Reply-To: <10479.1347550796@alphaville>

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	other threads:[~2012-09-13 16:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-09-13 13:37 Tyler Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50520F4B.4090302@lbl.gov \
    --to=apersaud@lbl.gov \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).