emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: Diary synchronising with Google calendar


From: Eric S Fraga
Subject: [Orgmode] Re: Diary synchronising with Google calendar
Date: Wed, 07 Jul 2010 23:20:14 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

On Wed, 7 Jul 2010 23:19:04 +0200, Jordi Inglada <address@hidden> wrote:
> 
> Hi Eric,
> 
> I am sorry to ask this, but can you post detailed instructions on how
> to use your code? It seems that I am (at least) missing the
> "add-to-google-calendar" function.
> 
> Thanks.
> 
> Jordi

Jordi,

the original email had the emacs lisp defadvice function (see below)
as well as the activation of that function.  The advice is called
"add-to-google-calendar".  All you have to do is execute both bits,
not just the last line as the last line assumes you have defined the
advice already.

I hope that makes sense?

eric


#+begin_src emacs-lisp
(defadvice org-agenda-add-entry-to-org-agenda-diary-file 
  (after add-to-google-calendar)
  "Add a new Google calendar entry that mirrors the diary entry just created by 
org-mode."
  (let ((type (ad-get-arg 0))
        (text (ad-get-arg 1))
        (d1 (ad-get-arg 2))
        (year1 (nth 2 d1))
        (month1 (car d1))
        (day1 (nth 1 d1))
        (d2 (ad-get-arg 3))
        entry dates)
    (if (or (not (eq type 'block)) (not d2))
        (setq dates (format "%d-%02d-%02d" year1 month1 day1))
      (let ((year2 (nth 2 d2)) (month2 (car d2)) (day2 (nth 1 d2)) (repeats (-
(calendar-absolute-from-gregorian d1)
                                                                               
(calendar-absolute-from-gregorian d2))))
        (if (> repeats 0)
            (setq dates (format "%d-%02d-%02d every day for %d days" year1 
month1 day1 (abs repeats)))
          (setq dates (format "%d-%02d-%02d every day for %d days" year1 month1 
day1 (abs repeats))))
        ))
    (setq entry  (format "/usr/bin/google calendar add --cal org \"%s on %s\"" 
text dates))
    ;;(message entry)
    (if (not (string= "MYLAPTOPCOMPUTER" mail-host-address))
        (shell-command entry)
      (let ((offline "~/tmp/org2google-offline-entries"))
        (find-file offline)
        (goto-char (point-max))
        (insert (concat entry "\n"))
        (save-buffer)
        (kill-buffer (current-buffer))
        (message "Plain text written to %s" offline)))))
(ad-activate 'org-agenda-add-entry-to-org-agenda-diary-file)
#end_src
-- 
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29  570D C891 93D8 FFFC F67D

reply via email to

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