Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to use Emacs to sync with Google Calendar and Google Contacts, ideally keeping a local copy so I can access them offline?

share|improve this question
1  
What are you currently using in emacs to store contacts? bbdb? Also, what do you use for your calendar program in emacs? My answer will differ for say org-mode vs diary mode. –  Steven D Sep 10 '10 at 15:37
    
Actually I am just starting, and am planning to use bbdb for contacts. I was planning to use diary mode for calendar, but now that I know of and read about org-mode that might be a good option, too. Thanks!! –  hpy Sep 10 '10 at 18:08
    
This would be a great option, if it's even possible, I would like to know. Building an outlook client into emacs would definitely be cool. –  Thomas Sep 10 '10 at 19:32
1  
Also asked at Super User. Don't do this! (Exception: when the question hasn't had any good answer at a site, and then link to the original question.) –  Gilles Sep 10 '10 at 20:23
    
I had no idea, sorry! Still looking for a good answer, though. –  hpy Sep 10 '10 at 21:12

4 Answers 4

up vote 3 down vote accepted

Unfortunately, I am unable to give a complete answer. All I have is advice about some possible paths to wander down.

The easiest route would be if the emacs-g-client that Gilles mentioned in the SU version of this question works. If that doesn't work, I would look into the following:

  • At the very least you should be able to get some calendar functionality by accessing your google calendar using ical. The function icalendar-import-file can import an ical file to a emacs diary file (icalendar-import-file documentation). Thus, in your .emacs file you could have a bit of emacs lisp to get the google calendar ical file and import it into your diary. If you do end up using org-mode there are a number of ways to integrate org-mode with diary-mode.

  • I think that the ultimate goal would be to make use of the gdata api. I don't think that there is an easy way to get access to Google contacts outside of this api. There is a command line utility that supports a wide range of functionality using this api called Google CL, which could theoretically be used inside some emacs lisp functions to provide full access to your contacts, calendar, and many other Google-hosted services. This however, would likely be much more difficult than just a few lines thrown into your .emacs.

share|improve this answer

emacs-calfw can synchronize with calendars in iCal (.ics) format such as Google Calendar.

share|improve this answer

For integration with Google contacts there is Julien Danjou's script which you can see in action here:

The google-contacts for Emacs extension allows to display your Google Contacts directly inside Emacs.

Note that it is likely to only work with at least Emacs 24, since it's using oauth2 which is part of GNU ELPA.

share|improve this answer

For Google Calendar, I have a one way sync setup successfully. Emacs fetches my calendars at startup and transfers it in the emacs diary. This is then displayed by org-mode in the agenda, but you can set it up anyway you want.

For sending back to Google Calendar, I have yet setup anything as I don't need it that much. However, I think it would be pretty easy to have a function that adds an entry in the diary and calls googlecl to add an entry in your google calendar.

To fetch the calendars, I have the following in my .emacs (not that this is not my code, it comes from the org-mode mailing list, but I can't remember where I found it exactly):

(setq mark-diary-entries-in-calendar t)
(defun getcal (url)
  "Download ics file and add to diary"
  (let ((tmpfile (url-file-local-copy url)))
    (icalendar-import-file tmpfile "~/diary" t)
    (kill-buffer (car (last (split-string tmpfile "/"))))
    )
  )
(setq google-calendars '(
                         "http://www.google.com/calendar/ical/DFSDFSDFSDFASD/basic.ics"
                         "http://www.google.com/calendar/ical/SDFSADFSADFASD/basic.ics"
                         ))
(defun getcals ()
  (Find-file "~/diary")
  (flush-lines "^[& ]")
  (dolist (url google-calendars) (getcal url))
  (kill-buffer "diary"))

Replace "http://www.google.com/calendar/ical/DFSDFSDFSDFASD/basic.ics" with the urls to the calendars you want to fetch (you find it at the bottom of the setup page of each calendar in google calendar). You can add as many as you wish.

Now, you can just call (getcals) when you want to fetch the calendars. You can put this in your .emacs to do it at startup, but it might stall your startup.

To have org-mode display the diary entries in the agenda, just add (setq org-agenda-include-diary t) in your .emacs. See the org-mode manual for details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.