emacs-wiki-discuss
[Top][All Lists]
Advanced

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

[emacs-wiki-discuss] [NEW] planner-ical.el


From: Chris Parsons
Subject: [emacs-wiki-discuss] [NEW] planner-ical.el
Date: Wed, 13 Jul 2005 21:38:58 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Hi all,

I've written an extension to planner which enables partial support of
the iCalendar RFC2445, as used by Apple's iCal, Mozilla Calendar, Lotus
Notes and others[1]. I'd like to submit for inclusion in the main tree
if it meets standards.

Currently there's a tiny featureset: I've only included the ability to
export a set of VTODO's. They import fine into PHPICalendar, but I'm not
able to test on other platforms.

Feedback and future development would be appreciated - I've no immediate
plans to expand this further, as it does what I need to further my
mission of getting planner tasks printed nicely on index cards for a
hipster (via an extension to my SVG Planner stuff[2]).

Hope somebody else finds this useful. Excuse any novice coding; I'm
still fairly new to lisp.

Chris

PS: Had no list messages for the last two days - not sure why, so
apologies if I don't respond straight away.

[1] See http://en.wikipedia.org/wiki/ICalendar for more on the iCal format.

[2] http://www.edendevelopment.co.uk/svgplanner

;;; planner-ical.el --- Import/Export planner tasks in the icalendar standard 
(RFC 2445)

;; Copyright (C) 2005 Chris Parsons

;; Emacs Lisp Archive Entry
;; Filename: planner-ical.el
;; Author: Chris Parsons <address@hidden>
;; Maintainer: Chris Parsons <address@hidden>
;; Keywords: planner, ical
;; URL: http://sacha.free.net.ph/notebook/wiki/PlannerMode.php

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This module allows you to export planner tasks and notes in the
;; icalendar format (RFC 2445). For a description of the standard, see
;; http://www.ietf.org/rfc/rfc2445.txt.
;; 
;; In future, it is hoped that tasks will be importable also.
;; 
;; Note that this is very early days - currently we only export VTODO
;; items from just one page.

(require 'planner)
(require 'icalendar)

;;; Code:

;;;_+ User variables

(defgroup planner-ical nil
  "iCal (RFC 2445) support for planner.el."
  :prefix "planner-ical"
  :group 'planner)

(defcustom planner-ical-export-buffer "*Planner iCal Export*"
  "Buffer name for iCal exports from `planner-ical-export'."
  :type 'string
  :group 'planner-timeclock-summary)

(defun planner-ical-export-page (page)
        "Export all the planner files to ICAL-FILENAME.
ICAL-FILENAME is cleared prior to the operation starting."
  (interactive (list (planner-read-name (planner-file-alist) "Enter the page to 
export: ")))
  (switch-to-buffer (get-buffer-create planner-ical-export-buffer))
  (erase-buffer)
        (planner-ical-export (if (listp page) page (list page))))

(defun planner-ical-export (pages)
        "Export the given plan page to iCalendar format. The result
        added to the current buffer"
        (let ((tasks (planner-extract-tasks pages))
                                result)
                (while tasks
                        (when (not (string= (planner-task-status (car tasks)) 
"X"))
                                (let* ((task (car tasks))
                                                         (header (format 
"\nBEGIN:VTODO\nUID:emacs-planner-%x"
                                                                                
                                         (sxhash (planner-task-description 
task))))
                                                         (my-task-date 
(planner-task-date task))
                                                         (task-date 
                                                                (if 
my-task-date 
                                                                                
(planner-filename-to-calendar-date my-task-date)
                                                                        nil))
                                                         (task-categories
                                                                (if (featurep 
'planner-multi)
                                                                                
(progn (setq cat-list (planner-multi-task-link-as-list task))
                                                                                
                         (setq cat-list-no-dates nil)
                                                                                
                         (while cat-list
                                                                                
                                 (let ((cat (car cat-list)))
                                                                                
                                         (when (not (string-match 
planner-date-regexp cat)) 
                                                                                
                                                 (setq cat-list-no-dates (cons 
cat cat-list-no-dates)))
                                                                                
                                         (setq cat-list (cdr cat-list))))
                                                                                
                         (mapconcat 
                                                                                
                                (function (lambda (x) 
                                                                                
                                                                                
(when x (replace-regexp-in-string "\\(\\[\\[\\|\\]\\]\\)" "" x)))) 
                                                                                
                                cat-list-no-dates ", "))
                                                                        
(planner-task-plan task)))
                                                         (task-due 
                                                                (when task-date 
(concat "\nDUE:" (icalendar--date-to-isodate task-date))))
                                                         (contents
                                                                (concat task-due
                                                                                
                "\nSUMMARY:" (planner-task-description task)
                                                                                
                "\nCATEGORIES:" task-categories)))
                                                                                
                 
                                        (setq result (concat result header 
contents "\nEND:VTODO"))))
                        (setq tasks (cdr tasks)))
                
                (let ((coding-system-for-write 'utf-8))
                        (insert "BEGIN:VCALENDAR")
                        (insert "\nPRODID:-//Emacs//NONSGML 
planner-ical.el//EN")
                        (insert "\nVERSION:2.0")
                        (when result (insert result))
                        (insert "\nEND:VCALENDAR\n"))))


(provide 'planner-ical)

;;; planner-ical.el ends here

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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