From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Google calendar to org mode script and a feature request for agenda Date: Tue, 29 Jun 2010 23:28:56 +0100 Message-ID: <87d3v95v87.wl%ucecesf@ucl.ac.uk> Reply-To: Eric S Fraga Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Tue_Jun_29_23:28:56_2010-1" Return-path: Received: from [140.186.70.92] (port=42029 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTjIl-0001Zh-FX for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 18:29:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTjIj-0003WF-QO for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 18:29:11 -0400 Received: from vscane-c.ucl.ac.uk ([144.82.108.43]:49194) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTjIj-0003VB-Jf for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 18:29:09 -0400 Received: from 79-74-7-130.dynamic.dsl.as9105.com ([79.74.7.130] helo=esf.ucl.ac.uk) by vscane-c.ucl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.60) (envelope-from ) id 1OTjIX-0004yc-Ve for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 23:28:59 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode mailing list --Multipart_Tue_Jun_29_23:28:56_2010-1 Content-Type: text/plain; charset=US-ASCII Hello, I finally got myself an Android phone (and am loving it, especially with an "all you can eat" data plan :-). I have tried mobileorg for Android but it's obviously early days and it's actually not really what I want. However, I am very happy with the Google syncing provided by the phone, both for email and for the calendar. This has caused me to revisit the possibility of a smoother integration between Google's calendar and org-mode. First, I have created an awk script (yes, I'm dating myself: I do use awk in preference to perl et al.) which allows me to convert the iCal export from Google calendar to a sequence of org headlines (see attached). It's a preliminary version and seems to translate what I need: simple day and timed events, mostly those that I will tend to do on the phone as opposed to when I'm at my computer. I'm not trying for a comprehensive translation program here... but I'm putting it on the list in case anybody finds it useful. I use this script as follows: wget [address specified by google for my calendar] --> basic.ics awk -f ical2org.awk < basic.ics >> googlecalendar.org this appends any entries in my specific google calendar to the given org file. When I go the other way (creating an ics file from org), I import the org items into a different calendar on google. When entries have been synced, I typically delete the original entries placed in google to avoid them being downloaded over and over again [1]. * A feature request: time prompt for insert diary agenda function Anyway, my increased use of google's calendar, has highlighted a short-coming (?) of the agenda view (or more strictly speaking, the iCal exporter): entries in which the time of appointment, say, is on the headline but the date is on the following line, say, get converted to "day" events as opposed to day+time events. I.e. something like * 11am meeting with colleages <2010-06-30 Wed> does not get exported as a timed event. Obviously, the easy solution is to put the time in the date stamp. However, I like using the "insert diary" function in the agenda view for defining appointments and this doesn't allow the time to be specified other than in a headline. Would it be possible to enhance the insert diary function to prompt for a time (and while we're at it, tags as well)? Thanks, eric Footnotes: [1] it may be possible to use the unique ID for each event to avoid creating duplicates... something to look at in the future. --Multipart_Tue_Jun_29_23:28:56_2010-1 Content-Type: text/plain; charset=US-ASCII Content-Disposition: attachment; filename="ical2org.awk" Content-Transfer-Encoding: 7bit # awk script for converting an iCal formatted file to a sequence of org-mode headings. # this may not work in general but seems to work for day and timed events from Google's # calendar, which is really all I need right now... # # Eric S Fraga, 20100629 BEGIN { # use a colon to separate the type of data line from the actual contents FS = ":"; entry = "" headline = "" id = "" indescription = 0; } # any line that starts at the left with a non-space character is a new data field /^[A-Z]/ {indescription = 0;} # this type of entry represents a day entry, not timed, with date stamp YYYYMMDD /^DTSTART;VALUE=DATE/ { date = gensub("([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9]).*[\r]", "\\1-\\2-\\3", "g", $2) #print date } # this represents a timed entry with date and time stamp YYYYMMDDTHHMMSS # we ignore the seconds /^DTSTART:/ { #print $0 date = gensub("([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])T([0-9][0-9])([0-9][0-9]).*[\r]", "\\1-\\2-\\3 \\4:\\5", "g", $2); # print date; } # The description will the contents of the entry in org-mode. # this line may be continued and as I do not know if other lines may be continued, # we only process continuation lines that come immediately after this one /^DESCRIPTION/ { entry = gensub("\r", "", "g", $2); indescription = 1; } # continuation lines (at least from Google) start with two spaces # if the continuation is after a description, append the entry /^ / { # print "** continuation line: " $0 if (indescription) { entry = entry gensub("\r", "", "g", $0); } } # the summary will be the org heading /^SUMMARY/ { headline = gensub("(.*)[\r]", "\\1", "g", $2); } # the unique ID will be stored as a property of the entry /^UID/ { id = gensub("(.*)[\r]", "\\1", "g", $2); } # when we reach the end of the event line, we output everything we # have collected so far, creating a top level org headline with the # date/time stamp, unique ID property and the contents, if any /^END:VEVENT/ { print "* " headline print " :PROPERTIES:" print " :ID: " id print " :END:" print " <" date ">" # for the entry, convert all embedded "\n" strings to actual newlines print "" print gensub("\\\\n", "\n", "g", entry); # need 4 backslash to get one in the pattern! headline = "" date = "" entry = "" indescription = 0 } END { print strftime("* COMMENT ical2org finished at [%Y-%m-%d %H:%M]"); } --Multipart_Tue_Jun_29_23:28:56_2010-1 Content-Type: text/plain; charset=US-ASCII -- Eric S Fraga GnuPG: 8F5C 279D 3907 E14A 5C29 570D C891 93D8 FFFC F67D --Multipart_Tue_Jun_29_23:28:56_2010-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Multipart_Tue_Jun_29_23:28:56_2010-1--