Emacs sync w/ Google Calendar and Contacts?

4,530

Solution 1

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.

Solution 2

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 ()
  (interactive)
  (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.

Solution 3

For integration with Google contacts there is Julien Danjou's script which you can see in action here (github repository is 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.

Solution 4

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

Share:
4,530

Related videos on Youtube

hpy
Author by

hpy

Updated on September 18, 2022

Comments

  • hpy
    hpy over 1 year

    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?

    • Steven D
      Steven D over 13 years
      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.
    • hpy
      hpy over 13 years
      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!!
    • Admin
      Admin over 13 years
      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.
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 13 years
      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.)
    • hpy
      hpy over 13 years
      I had no idea, sorry! Still looking for a good answer, though.