gnu-emacs-sources
[Top][All Lists]
Advanced

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

Gnus: Sending attached iCalendar events to korganizer


From: Christoph Conrad
Subject: Gnus: Sending attached iCalendar events to korganizer
Date: Fri, 21 Dec 2007 17:57:14 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50

Hi,

i modified a function from Dave Goldberg converting attached iCalendar
events to write them to a diary file, so that they are send to a running
korganizer now. I tested it with CVS GNU Emacs, but probably it will
work with GNU Emacs 22 (i hope so).

;; Sending iCalendar diary events to a running korganizer.
;; 2007 Christoph Conrad <mailto-rot13:address@hidden>

;; Originally by Dave Goldberg writing ical diary events to an emacs
;; diary file. The only part exhanged is the icalendar-import-buffer
;; part, see below.

(require 'icalendar)

(defun cc-korganizer-icalendar-handle-part (handle)
  (when (equal (car (mm-handle-type handle)) "text/calendar")
    (with-temp-buffer
      (insert (mm-get-part handle))
      (goto-char (point-min))
      (let* ((e
              (car (icalendar--all-events (icalendar--read-element nil nil))))
             (subject (icalendar--convert-string-for-import
                       (or (icalendar--get-event-property e 'SUMMARY)
                           "No Subject")))
             (dtstart (icalendar--get-event-property e 'DTSTART))
             (dtstart-dec (icalendar--decode-isodatetime dtstart))
             (start-d (icalendar--datetime-to-diary-date dtstart-dec))
             (start-t (icalendar--datetime-to-colontime dtstart-dec)))
        (when (y-or-n-p
               (format
                "Add appointment for \"%s\" on %s at %s to diary? "
                subject start-d start-t))
          ;; Original part from Dave Goldberg
          ;; for writing to diary file
          ;; (icalendar-import-buffer
          ;;  (expand-file-name "~/ical-diary") t nil))
          ;; New part by Christoph following
          (let ((file-name
                 (make-temp-file "gnus-ical")))
            (write-region (point-min) (point-max) file-name)
            (if (> 0 (shell-command "dcop korganizer"))
                (message "extract-ical: korganizer should be running.")
              (if (= 0 (shell-command
                        (concat "dcop korganizer "
                                "KOrganizerIface mergeURL " file-name)))
                  (message "extract-ical: Successfully send to korganizer.")
                (message "extract-ical: Problem sending event to korganizer.")))
            (delete-file file-name)))))))

(setq gnus-article-mime-part-function 'cc-korganizer-icalendar-handle-part)

With kind regards,
Christoph


reply via email to

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