From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Eglen Subject: Re: icalendar: exporting times of day specified in heading? Date: Tue, 02 Feb 2010 13:16:54 +0000 Message-ID: <11681.1265116614@maps> References: <15490.1263652716@cpc1-cmbg14-2-0-cust6.5-4.cable.virginmedia.com> Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcIcr-0006X2-5H for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 08:17:05 -0500 Received: from [199.232.76.173] (port=54656 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcIcq-0006WZ-IB for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 08:17:04 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcIcm-0008Dn-3D for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 08:17:04 -0500 Received: from ppsw-7.csi.cam.ac.uk ([131.111.8.137]:51873) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcIcl-0008C5-6c for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 08:16:59 -0500 In-reply-to: <15490.1263652716@cpc1-cmbg14-2-0-cust6.5-4.cable.virginmedia.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Stephen Eglen Cc: emacs-orgmode@gnu.org > > I often use org-agenda-diary-entry to make simple entries into > an agenda.org file. I see that the agenda is clever enough to recognise > if a time range has been typed into the heading. However, this time > range is not exported by the icalendar code. Attached is a patch to the code underlying 'i d' entries in the *Org Agenda* buffer. If a time of day is specified in the entry, it is extracted from the entry and put into the timestamp of the diary entry. (The .ics exporting code recognises these timestamps and therefore the ics export code does not need altering.) For example, given the following three entries added using 'i d' from *Org Agenda*: i d RET test 1 12:00-14:00 classes RET i d RET test 2 did you get 7am wake up call? RET i d RET test 3 find 3--5 volunteers RET then the following entries are added to agenda.org: *** 2010-02-03 Wednesday **** test 3 find 3--5 volunteers <2010-02-03 Wed> **** test 2 did you get wake up call? <2010-02-03 Wed 07:00> **** test 1 classes <2010-02-03 Wed 12:00-14:00> As this behvaiour may not be desired by all, I've currently put the code conditional on org-agenda-search-headline-for-time being non-nil (the default is t). If that variable is nil, then the above three test entries generates the regular tree: *** 2010-02-03 Wednesday **** test 3 find 3--5 volunteers <2010-02-03 Wed> **** test 2 did you get 7am wake up call? <2010-02-03 Wed> **** test 1 12:00-14:00 classes <2010-02-03 Wed> Perhaps org-agenda-search-headline-for-time is not the right variable though (happy to had another) given that it defaults to t? Stephen 2010-02-02 Stephen Eglen * org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file): Optionally extract time specification from text and add to the timestamp. *** /tmp/ediff11782joC 2010-02-02 13:07:49.000000000 +0000 --- /home/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el 2010-02-02 09:48:10.000000000 +0000 *************** *** 6891,6903 **** (insert (format "%%%%(diary-anniversary %s) %s" (calendar-date-string d1 nil t) text)))) ((eq type 'day) ! (if (eq org-agenda-insert-diary-strategy 'top-level) ! (org-agenda-insert-diary-as-top-level text) ! (require 'org-datetree) ! (org-datetree-find-date-create d1) ! (org-agenda-insert-diary-make-new-entry text)) ! (org-insert-time-stamp (org-time-from-absolute ! (calendar-absolute-from-gregorian d1))) (end-of-line 0)) ((eq type 'block) (if (> (calendar-absolute-from-gregorian d1) --- 6891,6919 ---- (insert (format "%%%%(diary-anniversary %s) %s" (calendar-date-string d1 nil t) text)))) ((eq type 'day) ! (let* ! (fmt time time2 ! (org-agenda-time-leading-zero t)) ! (if org-agenda-search-headline-for-time ! ;; Use org-format-agenda-item to parse text for a time-range and ! ;; remove it. ! (setq fmt (org-format-agenda-item nil text nil nil t) ! time (get-text-property 0 'time fmt) ! time2 (if (> (length time) 0) ! ;; split-string removes trailing ...... if ! ;; no end time given. First space ! ;; separates time from date. ! (concat " " (car (split-string time "\\."))) ! nil) ! text (get-text-property 0 'txt fmt))) ! (if (eq org-agenda-insert-diary-strategy 'top-level) ! (org-agenda-insert-diary-as-top-level text) ! (require 'org-datetree) ! (org-datetree-find-date-create d1) ! (org-agenda-insert-diary-make-new-entry text)) ! (org-insert-time-stamp (org-time-from-absolute ! (calendar-absolute-from-gregorian d1)) ! nil nil nil nil time2)) (end-of-line 0)) ((eq type 'block) (if (> (calendar-absolute-from-gregorian d1)