Mercurial > emacs
annotate lisp/calendar/icalendar.el @ 66151:934d10a9685c
(jit-lock-fontify-now): Move jit-lock-context-unfontify-pos.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 17 Oct 2005 15:15:31 +0000 |
parents | a65f8ec418fc |
children | 88fc54347c68 |
rev | line source |
---|---|
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1 ;;; icalendar.el --- iCalendar implementation -*-coding: utf-8 -*- |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
3 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
4 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
5 ;; Author: Ulf Jasper <ulf.jasper@web.de> |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
6 ;; Created: August 2002 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
7 ;; Keywords: calendar |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
8 ;; Human-Keywords: calendar, diary, iCalendar, vCalendar |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
9 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
11 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
15 ;; any later version. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
16 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
21 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
26 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
27 ;;; Commentary: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
28 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
29 ;; This package is documented in the Emacs Manual. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
30 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
31 ;; Please note: |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
32 ;; - Diary entries which have a start time but no end time are assumed to |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
33 ;; last for one hour when they are exported. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
34 ;; - Weekly diary entries are assumed to occur the first time in the first |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
35 ;; week of the year 2000 when they are exported. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
36 ;; - Yearly diary entries are assumed to occur the first time in the year |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
37 ;; 1900 when they are exported. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
38 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
39 ;;; History: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
40 |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
41 ;; 0.07 onwards: see lisp/ChangeLog |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
42 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
43 ;; 0.06: Bugfixes regarding icalendar-import-format-*. |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
44 ;; Fix in icalendar-convert-diary-to-ical -- thanks to Philipp |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
45 ;; Grau. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
46 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
47 ;; 0.05: New import format scheme: Replaced icalendar-import-prefix-*, |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
48 ;; icalendar-import-ignored-properties, and |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
49 ;; icalendar-import-separator with icalendar-import-format(-*). |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
50 ;; icalendar-import-file and icalendar-convert-diary-to-ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
51 ;; have an extra parameter which should prevent them from |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
52 ;; erasing their target files (untested!). |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
53 ;; Tested with Emacs 21.3.2 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
54 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
55 ;; 0.04: Bugfix: import: double quoted param values did not work |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
56 ;; Read DURATION property when importing. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
57 ;; Added parameter icalendar-duration-correction. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
58 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
59 ;; 0.03: Export takes care of european-calendar-style. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
60 ;; Tested with Emacs 21.3.2 and XEmacs 21.4.12 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
61 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
62 ;; 0.02: Should work in XEmacs now. Thanks to Len Trigg for the |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
63 ;; XEmacs patches! |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
64 ;; Added exporting from Emacs diary to ical. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
65 ;; Some bugfixes, after testing with calendars from |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
66 ;; http://icalshare.com. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
67 ;; Tested with Emacs 21.3.2 and XEmacs 21.4.12 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
68 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
69 ;; 0.01: First published version. Trial version. Alpha version. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
70 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
71 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
72 ;; To Do: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
73 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
74 ;; * Import from ical to diary: |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
75 ;; + Need more properties for icalendar-import-format |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
76 ;; + check vcalendar version |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
77 ;; + check (unknown) elements |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
78 ;; + recurring events! |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
79 ;; + works for european style calendars only! Does it? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
80 ;; + alarm |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
81 ;; + exceptions in recurring events |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
82 ;; + the parser is too soft |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
83 ;; + error log is incomplete |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
84 ;; + nice to have: #include "webcal://foo.com/some-calendar.ics" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
85 ;; + timezones, currently all times are local! |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
86 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
87 ;; * Export from diary to ical |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
88 ;; + diary-date, diary-float, and self-made sexp entries are not |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
89 ;; understood |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
90 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
91 ;; * Other things |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
92 ;; + clean up all those date/time parsing functions |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
93 ;; + Handle todo items? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
94 ;; + Check iso 8601 for datetime and period |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
95 ;; + Which chars to (un)escape? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
96 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
97 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
98 ;;; Code: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
99 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
100 (defconst icalendar-version 0.12 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
101 "Version number of icalendar.el.") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
102 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
103 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
104 ;; Customizables |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
105 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
106 (defgroup icalendar nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
107 "Icalendar support." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
108 :prefix "icalendar-" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
109 :group 'calendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
110 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
111 (defcustom icalendar-import-format |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
112 "%s%d%l%o" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
113 "Format string for importing events from iCalendar into Emacs diary. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
114 This string defines how iCalendar events are inserted into diary |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
115 file. Meaning of the specifiers: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
116 %d Description, see `icalendar-import-format-description' |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
117 %l Location, see `icalendar-import-format-location' |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
118 %o Organizer, see `icalendar-import-format-organizer' |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
119 %s Subject, see `icalendar-import-format-subject'" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
120 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
121 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
122 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
123 (defcustom icalendar-import-format-subject |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
124 "%s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
125 "Format string defining how the subject element is formatted. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
126 This applies only if the subject is not empty! `%s' is replaced |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
127 by the subject." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
128 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
129 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
130 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
131 (defcustom icalendar-import-format-description |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
132 "\n Desc: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
133 "Format string defining how the description element is formatted. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
134 This applies only if the description is not empty! `%s' is |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
135 replaced by the description." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
136 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
137 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
138 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
139 (defcustom icalendar-import-format-location |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
140 "\n Location: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
141 "Format string defining how the location element is formatted. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
142 This applies only if the location is not empty! `%s' is replaced |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
143 by the location." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
144 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
145 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
146 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
147 (defcustom icalendar-import-format-organizer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
148 "\n Organizer: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
149 "Format string defining how the organizer element is formatted. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
150 This applies only if the organizer is not empty! `%s' is |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
151 replaced by the organizer." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
152 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
153 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
154 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
155 (defvar icalendar-debug nil |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
156 "Enable icalendar debug messages.") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
157 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
158 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
159 ;; NO USER SERVICABLE PARTS BELOW THIS LINE |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
160 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
161 |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
162 (defconst icalendar--weekday-array ["SU" "MO" "TU" "WE" "TH" "FR" "SA"]) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
163 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
164 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
165 ;; all the other libs we need |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
166 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
167 (require 'calendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
168 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
169 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
170 ;; misc |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
171 ;; ====================================================================== |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
172 (defun icalendar--dmsg (&rest args) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
173 "Print message ARGS if `icalendar-debug' is non-nil." |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
174 (if icalendar-debug |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
175 (apply 'message args))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
176 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
177 ;; ====================================================================== |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
178 ;; Core functionality |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
179 ;; Functions for parsing icalendars, importing and so on |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
180 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
181 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
182 (defun icalendar--get-unfolded-buffer (folded-ical-buffer) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
183 "Return a new buffer containing the unfolded contents of a buffer. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
184 Folding is the iCalendar way of wrapping long lines. In the |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
185 created buffer all occurrences of CR LF BLANK are replaced by the |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
186 empty string. Argument FOLDED-ICAL-BUFFER is the unfolded input |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
187 buffer." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
188 (let ((unfolded-buffer (get-buffer-create " *icalendar-work*"))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
189 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
190 (set-buffer unfolded-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
191 (erase-buffer) |
64432
cd3c7f95237e
(icalendar--get-unfolded-buffer): Use `insert-buffer-substring' and `goto-char',
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
192 (insert-buffer-substring folded-ical-buffer) |
cd3c7f95237e
(icalendar--get-unfolded-buffer): Use `insert-buffer-substring' and `goto-char',
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
193 (goto-char (point-min)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
194 (while (re-search-forward "\r?\n[ \t]" nil t) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
195 (replace-match "" nil nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
196 unfolded-buffer)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
197 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
198 (defsubst icalendar--rris (re rp st) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
199 "Replace regexp RE with RP in string ST and return the new string. |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
200 This is here for compatibility with XEmacs." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
201 ;; XEmacs: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
202 (if (fboundp 'replace-in-string) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
203 (save-match-data ;; apparently XEmacs needs save-match-data |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
204 (replace-in-string st re rp)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
205 ;; Emacs: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
206 (replace-regexp-in-string re rp st))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
207 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
208 (defun icalendar--read-element (invalue inparams) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
209 "Recursively read the next iCalendar element in the current buffer. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
210 INVALUE gives the current iCalendar element we are reading. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
211 INPARAMS gives the current parameters..... |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
212 This function calls itself recursively for each nested calendar element |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
213 it finds" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
214 (let (element children line name params param param-name param-value |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
215 value |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
216 (continue t)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
217 (setq children '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
218 (while (and continue |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
219 (re-search-forward "^\\([A-Za-z0-9-]+\\)[;:]" nil t)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
220 (setq name (intern (match-string 1))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
221 (backward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
222 (setq params '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
223 (setq line '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
224 (while (looking-at ";") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
225 (re-search-forward ";\\([A-Za-z0-9-]+\\)=" nil nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
226 (setq param-name (intern (match-string 1))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
227 (re-search-forward "\\(\\([^;,:\"]+\\)\\|\"\\([^\"]+\\)\"\\)[;:]" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
228 nil t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
229 (backward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
230 (setq param-value (or (match-string 2) (match-string 3))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
231 (setq param (list param-name param-value)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
232 (while (looking-at ",") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
233 (re-search-forward "\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\)" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
234 nil t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
235 (if (match-string 2) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
236 (setq param-value (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
237 (setq param-value (match-string 3))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
238 (setq param (append param param-value))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
239 (setq params (append params param))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
240 (unless (looking-at ":") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
241 (error "Oops")) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
242 (forward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
243 (re-search-forward "\\(.*\\)\\(\r?\n[ \t].*\\)*" nil t) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
244 (setq value (icalendar--rris "\r?\n[ \t]" "" (match-string 0))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
245 (setq line (list name params value)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
246 (cond ((eq name 'BEGIN) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
247 (setq children |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
248 (append children |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
249 (list (icalendar--read-element (intern value) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
250 params))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
251 ((eq name 'END) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
252 (setq continue nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
253 (t |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
254 (setq element (append element (list line)))))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
255 (if invalue |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
256 (list invalue inparams element children) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
257 children))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
258 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
259 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
260 ;; helper functions for examining events |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
261 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
262 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
263 ;;(defsubst icalendar--get-all-event-properties (event) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
264 ;; "Return the list of properties in this EVENT." |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
265 ;; (car (cddr event))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
266 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
267 (defun icalendar--get-event-property (event prop) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
268 "For the given EVENT return the value of the first occurence of PROP." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
269 (catch 'found |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
270 (let ((props (car (cddr event))) pp) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
271 (while props |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
272 (setq pp (car props)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
273 (if (eq (car pp) prop) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
274 (throw 'found (car (cddr pp)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
275 (setq props (cdr props)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
276 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
277 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
278 (defun icalendar--get-event-property-attributes (event prop) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
279 "For the given EVENT return attributes of the first occurence of PROP." |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
280 (catch 'found |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
281 (let ((props (car (cddr event))) pp) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
282 (while props |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
283 (setq pp (car props)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
284 (if (eq (car pp) prop) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
285 (throw 'found (cadr pp))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
286 (setq props (cdr props)))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
287 nil)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
288 |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
289 (defun icalendar--get-event-properties (event prop) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
290 "For the given EVENT return a list of all values of the property PROP." |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
291 (let ((props (car (cddr event))) pp result) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
292 (while props |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
293 (setq pp (car props)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
294 (if (eq (car pp) prop) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
295 (setq result (append (split-string (car (cddr pp)) ",") result))) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
296 (setq props (cdr props))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
297 result)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
298 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
299 ;; (defun icalendar--set-event-property (event prop new-value) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
300 ;; "For the given EVENT set the property PROP to the value NEW-VALUE." |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
301 ;; (catch 'found |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
302 ;; (let ((props (car (cddr event))) pp) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
303 ;; (while props |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
304 ;; (setq pp (car props)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
305 ;; (when (eq (car pp) prop) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
306 ;; (setcdr (cdr pp) new-value) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
307 ;; (throw 'found (car (cddr pp)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
308 ;; (setq props (cdr props))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
309 ;; (setq props (car (cddr event))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
310 ;; (setcar (cddr event) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
311 ;; (append props (list (list prop nil new-value))))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
312 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
313 (defun icalendar--get-children (node name) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
314 "Return all children of the given NODE which have a name NAME. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
315 For instance the VCALENDAR node can have VEVENT children as well as VTODO |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
316 children." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
317 (let ((result nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
318 (children (cadr (cddr node)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
319 (when (eq (car node) name) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
320 (setq result node)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
321 ;;(message "%s" node) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
322 (when children |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
323 (let ((subresult |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
324 (delq nil |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
325 (mapcar (lambda (n) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
326 (icalendar--get-children n name)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
327 children)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
328 (if subresult |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
329 (if result |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
330 (setq result (append result subresult)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
331 (setq result subresult))))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
332 result)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
333 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
334 ; private |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
335 (defun icalendar--all-events (icalendar) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
336 "Return the list of all existing events in the given ICALENDAR." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
337 (icalendar--get-children (car icalendar) 'VEVENT)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
338 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
339 (defun icalendar--split-value (value-string) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
340 "Split VALUE-STRING at ';='." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
341 (let ((result '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
342 param-name param-value) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
343 (when value-string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
344 (save-current-buffer |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
345 (set-buffer (get-buffer-create " *icalendar-work*")) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
346 (set-buffer-modified-p nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
347 (erase-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
348 (insert value-string) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
349 (goto-char (point-min)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
350 (while |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
351 (re-search-forward |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
352 "\\([A-Za-z0-9-]+\\)=\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\);?" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
353 nil t) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
354 (setq param-name (intern (match-string 1))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
355 (setq param-value (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
356 (setq result |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
357 (append result (list (list param-name param-value))))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
358 result)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
359 |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
360 (defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
361 "Return ISODATETIMESTRING in format like `decode-time'. |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
362 Converts from ISO-8601 to Emacs representation. If |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
363 ISODATETIMESTRING specifies UTC time (trailing letter Z) the |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
364 decoded time is given in the local time zone! If optional |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
365 parameter DAY-SHIFT is non-nil the result is shifted by DAY-SHIFT |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
366 days. |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
367 |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
368 FIXME: TZID-attributes are ignored....! |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
369 FIXME: multiple comma-separated values should be allowed!" |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
370 (icalendar--dmsg isodatetimestring) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
371 (if isodatetimestring |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
372 ;; day/month/year must be present |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
373 (let ((year (read (substring isodatetimestring 0 4))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
374 (month (read (substring isodatetimestring 4 6))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
375 (day (read (substring isodatetimestring 6 8))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
376 (hour 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
377 (minute 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
378 (second 0)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
379 (when (> (length isodatetimestring) 12) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
380 ;; hour/minute present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
381 (setq hour (read (substring isodatetimestring 9 11))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
382 (setq minute (read (substring isodatetimestring 11 13)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
383 (when (> (length isodatetimestring) 14) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
384 ;; seconds present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
385 (setq second (read (substring isodatetimestring 13 15)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
386 (when (and (> (length isodatetimestring) 15) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
387 ;; UTC specifier present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
388 (char-equal ?Z (aref isodatetimestring 15))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
389 ;; if not UTC add current-time-zone offset |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
390 (setq second (+ (car (current-time-zone)) second))) |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
391 ;; shift if necessary |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
392 (if day-shift |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
393 (let ((mdy (calendar-gregorian-from-absolute |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
394 (+ (calendar-absolute-from-gregorian |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
395 (list month day year)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
396 day-shift)))) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
397 (setq month (nth 0 mdy)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
398 (setq day (nth 1 mdy)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
399 (setq year (nth 2 mdy)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
400 ;; create the decoded date-time |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
401 ;; FIXME!?! |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
402 (condition-case nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
403 (decode-time (encode-time second minute hour day month year)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
404 (error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
405 (message "Cannot decode \"%s\"" isodatetimestring) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
406 ;; hope for the best... |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
407 (list second minute hour day month year 0 nil 0)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
408 ;; isodatetimestring == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
409 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
410 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
411 (defun icalendar--decode-isoduration (isodurationstring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
412 &optional duration-correction) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
413 "Convert ISODURATIONSTRING into format provided by `decode-time'. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
414 Converts from ISO-8601 to Emacs representation. If ISODURATIONSTRING |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
415 specifies UTC time (trailing letter Z) the decoded time is given in |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
416 the local time zone! |
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
417 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
418 Optional argument DURATION-CORRECTION shortens result by one day. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
419 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
420 FIXME: TZID-attributes are ignored....! |
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
421 FIXME: multiple comma-separated values should be allowed!" |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
422 (if isodurationstring |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
423 (save-match-data |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
424 (string-match |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
425 (concat |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
426 "^P[+-]?\\(" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
427 "\\(\\([0-9]+\\)D\\)" ; days only |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
428 "\\|" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
429 "\\(\\(\\([0-9]+\\)D\\)?T\\(\\([0-9]+\\)H\\)?" ; opt days |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
430 "\\(\\([0-9]+\\)M\\)?\\(\\([0-9]+\\)S\\)?\\)" ; mand. time |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
431 "\\|" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
432 "\\(\\([0-9]+\\)W\\)" ; weeks only |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
433 "\\)$") isodurationstring) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
434 (let ((seconds 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
435 (minutes 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
436 (hours 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
437 (days 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
438 (months 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
439 (years 0)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
440 (cond |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
441 ((match-beginning 2) ;days only |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
442 (setq days (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
443 (match-beginning 3) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
444 (match-end 3)))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
445 (when duration-correction |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
446 (setq days (1- days)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
447 ((match-beginning 4) ;days and time |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
448 (if (match-beginning 5) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
449 (setq days (* 7 (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
450 (match-beginning 6) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
451 (match-end 6)))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
452 (if (match-beginning 7) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
453 (setq hours (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
454 (match-beginning 8) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
455 (match-end 8))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
456 (if (match-beginning 9) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
457 (setq minutes (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
458 (match-beginning 10) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
459 (match-end 10))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
460 (if (match-beginning 11) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
461 (setq seconds (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
462 (match-beginning 12) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
463 (match-end 12)))))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
464 ((match-beginning 13) ;weeks only |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
465 (setq days (* 7 (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
466 (match-beginning 14) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
467 (match-end 14))))))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
468 (list seconds minutes hours days months years))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
469 ;; isodatetimestring == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
470 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
471 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
472 (defun icalendar--add-decoded-times (time1 time2) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
473 "Add TIME1 to TIME2. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
474 Both times must be given in decoded form. One of these times must be |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
475 valid (year > 1900 or something)." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
476 ;; FIXME: does this function exist already? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
477 (decode-time (encode-time |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
478 (+ (nth 0 time1) (nth 0 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
479 (+ (nth 1 time1) (nth 1 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
480 (+ (nth 2 time1) (nth 2 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
481 (+ (nth 3 time1) (nth 3 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
482 (+ (nth 4 time1) (nth 4 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
483 (+ (nth 5 time1) (nth 5 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
484 nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
485 nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
486 ;;(or (nth 6 time1) (nth 6 time2)) ;; FIXME? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
487 ))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
488 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
489 (defun icalendar--datetime-to-noneuropean-date (datetime &optional separator) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
490 "Convert the decoded DATETIME to non-european-style format. |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
491 Optional argument SEPARATOR gives the separator between month, |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
492 day, and year. If nil a blank character is used as separator. |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
493 Non-European format: \"month day year\"." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
494 (if datetime |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
495 (format "%d%s%d%s%d" (nth 4 datetime) ;month |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
496 (or separator " ") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
497 (nth 3 datetime) ;day |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
498 (or separator " ") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
499 (nth 5 datetime)) ;year |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
500 ;; datetime == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
501 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
502 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
503 (defun icalendar--datetime-to-european-date (datetime &optional separator) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
504 "Convert the decoded DATETIME to European format. |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
505 Optional argument SEPARATOR gives the separator between month, |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
506 day, and year. If nil a blank character is used as separator. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
507 European format: (day month year). |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
508 FIXME" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
509 (if datetime |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
510 (format "%d%s%d%s%d" (nth 3 datetime) ;day |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
511 (or separator " ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
512 (nth 4 datetime) ;month |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
513 (or separator " ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
514 (nth 5 datetime)) ;year |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
515 ;; datetime == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
516 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
517 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
518 (defun icalendar--datetime-to-diary-date (datetime &optional separator) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
519 "Convert the decoded DATETIME to diary format. |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
520 Optional argument SEPARATOR gives the separator between month, |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
521 day, and year. If nil a blank character is used as separator. |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
522 Call icalendar--datetime-to-(non)-european-date according to |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
523 value of `european-calendar-style'." |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
524 (if european-calendar-style |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
525 (icalendar--datetime-to-european-date datetime separator) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
526 (icalendar--datetime-to-noneuropean-date datetime separator))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
527 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
528 (defun icalendar--datetime-to-colontime (datetime) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
529 "Extract the time part of a decoded DATETIME into 24-hour format. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
530 Note that this silently ignores seconds." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
531 (format "%02d:%02d" (nth 2 datetime) (nth 1 datetime))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
532 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
533 (defun icalendar--get-month-number (monthname) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
534 "Return the month number for the given MONTHNAME." |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
535 (catch 'found |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
536 (let ((num 1) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
537 (m (downcase monthname))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
538 (mapc (lambda (month) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
539 (let ((mm (downcase month))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
540 (if (or (string-equal mm m) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
541 (string-equal (substring mm 0 3) m)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
542 (throw 'found num)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
543 (setq num (1+ num)))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
544 calendar-month-name-array)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
545 ;; Error: |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
546 -1)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
547 |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
548 (defun icalendar--get-weekday-number (abbrevweekday) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
549 "Return the number for the ABBREVWEEKDAY." |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
550 (if abbrevweekday |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
551 (catch 'found |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
552 (let ((num 0) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
553 (aw (downcase abbrevweekday))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
554 (mapc (lambda (day) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
555 (let ((d (downcase day))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
556 (if (string-equal d aw) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
557 (throw 'found num)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
558 (setq num (1+ num)))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
559 icalendar--weekday-array))) |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
560 ;; Error: |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
561 -1)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
562 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
563 (defun icalendar--get-weekday-abbrev (weekday) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
564 "Return the abbreviated WEEKDAY." |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
565 (catch 'found |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
566 (let ((num 0) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
567 (w (downcase weekday))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
568 (mapc (lambda (day) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
569 (let ((d (downcase day))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
570 (if (or (string-equal d w) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
571 (string-equal (substring d 0 3) w)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
572 (throw 'found (aref icalendar--weekday-array num))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
573 (setq num (1+ num)))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
574 calendar-day-name-array)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
575 ;; Error: |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
576 nil)) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
577 |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
578 (defun icalendar--date-to-isodate (date &optional day-shift) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
579 "Convert DATE to iso-style date. |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
580 DATE must be a list of the form (month day year). |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
581 If DAY-SHIFT is non-nil, the result is shifted by DAY-SHIFT days." |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
582 (let ((mdy (calendar-gregorian-from-absolute |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
583 (+ (calendar-absolute-from-gregorian date) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
584 (or day-shift 0))))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
585 (format "%04d%02d%02d" (nth 2 mdy) (nth 0 mdy) (nth 1 mdy)))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
586 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
587 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
588 (defun icalendar--datestring-to-isodate (datestring &optional day-shift) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
589 "Convert diary-style DATESTRING to iso-style date. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
590 If DAY-SHIFT is non-nil, the result is shifted by DAY-SHIFT days |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
591 -- DAY-SHIFT must be either nil or an integer. This function |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
592 takes care of european-style." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
593 (let ((day -1) month year) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
594 (save-match-data |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
595 (cond ( ;; numeric date |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
596 (string-match (concat "\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
597 "0?\\([1-9][0-9]?\\)[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
598 "0?\\([1-9][0-9]?\\),?[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
599 "\\([0-9]\\{4\\}\\)") |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
600 datestring) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
601 (setq day (read (substring datestring (match-beginning 1) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
602 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
603 (setq month (read (substring datestring (match-beginning 2) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
604 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
605 (setq year (read (substring datestring (match-beginning 3) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
606 (match-end 3)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
607 (unless european-calendar-style |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
608 (let ((x month)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
609 (setq month day) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
610 (setq day x)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
611 ( ;; date contains month names -- european-style |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
612 (and european-calendar-style |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
613 (string-match (concat "\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
614 "0?\\([123]?[0-9]\\)[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
615 "\\([A-Za-z][^ ]+\\)[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
616 "\\([0-9]\\{4\\}\\)") |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
617 datestring)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
618 (setq day (read (substring datestring (match-beginning 1) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
619 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
620 (setq month (icalendar--get-month-number |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
621 (substring datestring (match-beginning 2) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
622 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
623 (setq year (read (substring datestring (match-beginning 3) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
624 (match-end 3))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
625 ( ;; date contains month names -- non-european-style |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
626 (and (not european-calendar-style) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
627 (string-match (concat "\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
628 "\\([A-Za-z][^ ]+\\)[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
629 "0?\\([123]?[0-9]\\),?[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
630 "\\([0-9]\\{4\\}\\)") |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
631 datestring)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
632 (setq day (read (substring datestring (match-beginning 2) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
633 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
634 (setq month (icalendar--get-month-number |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
635 (substring datestring (match-beginning 1) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
636 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
637 (setq year (read (substring datestring (match-beginning 3) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
638 (match-end 3))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
639 (t |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
640 nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
641 (if (> day 0) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
642 (let ((mdy (calendar-gregorian-from-absolute |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
643 (+ (calendar-absolute-from-gregorian (list month day |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
644 year)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
645 (or day-shift 0))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
646 (format "%04d%02d%02d" (nth 2 mdy) (nth 0 mdy) (nth 1 mdy))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
647 nil))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
648 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
649 (defun icalendar--diarytime-to-isotime (timestring ampmstring) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
650 "Convert a a time like 9:30pm to an iso-conform string like T213000. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
651 In this example the TIMESTRING would be \"9:30\" and the AMPMSTRING |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
652 would be \"pm\"." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
653 (if timestring |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
654 (let ((starttimenum (read (icalendar--rris ":" "" timestring)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
655 ;; take care of am/pm style |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
656 (if (and ampmstring (string= "pm" ampmstring)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
657 (setq starttimenum (+ starttimenum 1200))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
658 (format "T%04d00" starttimenum)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
659 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
660 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
661 (defun icalendar--convert-string-for-export (string) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
662 "Escape comma and other critical characters in STRING." |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
663 (icalendar--rris "," "\\\\," string)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
664 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
665 (defun icalendar--convert-string-for-import (string) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
666 "Remove escape chars for comma, semicolon etc. from STRING." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
667 (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
668 "\\\\n" "\n " (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
669 "\\\\\"" "\"" (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
670 "\\\\;" ";" (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
671 "\\\\," "," string))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
672 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
673 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
674 ;; Export -- convert emacs-diary to icalendar |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
675 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
676 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
677 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
678 (defun icalendar-export-file (diary-filename ical-filename) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
679 "Export diary file to iCalendar format. |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
680 All diary entries in the file DIARY-FILENAME are converted to iCalendar |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
681 format. The result is appended to the file ICAL-FILENAME." |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
682 (interactive "FExport diary data from file: |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
683 Finto iCalendar file: ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
684 (save-current-buffer |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
685 (set-buffer (find-file diary-filename)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
686 (icalendar-export-region (point-min) (point-max) ical-filename))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
687 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
688 (defalias 'icalendar-convert-diary-to-ical 'icalendar-export-file) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
689 (make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
690 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
691 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
692 (defun icalendar-export-region (min max ical-filename) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
693 "Export region in diary file to iCalendar format. |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
694 All diary entries in the region from MIN to MAX in the current buffer are |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
695 converted to iCalendar format. The result is appended to the file |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
696 ICAL-FILENAME. |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
697 This function attempts to return t if something goes wrong. In this |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
698 case an error string which describes all the errors and problems is |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
699 written into the buffer `*icalendar-errors*'." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
700 (interactive "r |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
701 FExport diary data into iCalendar file: ") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
702 (let ((result "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
703 (start 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
704 (entry-main "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
705 (entry-rest "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
706 (header "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
707 (contents) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
708 (found-error nil) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
709 (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
710 "?"))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
711 ;; prepare buffer with error messages |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
712 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
713 (set-buffer (get-buffer-create "*icalendar-errors*")) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
714 (erase-buffer)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
715 |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
716 ;; here we go |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
717 (save-excursion |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
718 (goto-char min) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
719 (while (re-search-forward |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
720 "^\\([^ \t\n].+\\)\\(\\(\n[ \t].*\\)*\\)" max t) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
721 (setq entry-main (match-string 1)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
722 (if (match-beginning 2) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
723 (setq entry-rest (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
724 (setq entry-rest "")) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
725 (setq header (format "\nBEGIN:VEVENT\nUID:emacs%d%d%d" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
726 (car (current-time)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
727 (cadr (current-time)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
728 (car (cddr (current-time))))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
729 (condition-case error-val |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
730 (progn |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
731 (setq contents |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
732 (or |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
733 ;; anniversaries -- %%(diary-anniversary ...) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
734 (icalendar--convert-anniversary-to-ical nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
735 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
736 ;; cyclic events -- %%(diary-cyclic ...) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
737 (icalendar--convert-cyclic-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
738 ;; diary-date -- %%(diary-date ...) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
739 (icalendar--convert-date-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
740 ;; float events -- %%(diary-float ...) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
741 (icalendar--convert-float-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
742 ;; block events -- %%(diary-block ...) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
743 (icalendar--convert-block-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
744 ;; other sexp diary entries |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
745 (icalendar--convert-sexp-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
746 ;; weekly by day -- Monday 8:30 Team meeting |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
747 (icalendar--convert-weekly-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
748 ;; yearly by day -- 1 May Tag der Arbeit |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
749 (icalendar--convert-yearly-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
750 ;; "ordinary" events, start and end time given |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
751 ;; 1 Feb 2003 blah |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
752 (icalendar--convert-ordinary-to-ical nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
753 ;; everything else |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
754 ;; Oops! what's that? |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
755 (error "Could not parse entry"))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
756 (unless (string= entry-rest "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
757 (setq contents |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
758 (concat contents "\nDESCRIPTION:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
759 (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
760 entry-rest)))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
761 (setq result (concat result header contents "\nEND:VEVENT"))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
762 ;; handle errors |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
763 (error |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
764 (setq found-error t) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
765 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
766 (set-buffer (get-buffer-create "*icalendar-errors*")) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
767 (insert (format "Error in line %d -- %s: `%s'\n" |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
768 (count-lines (point-min) (point)) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
769 (cadr error-val) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
770 entry-main)))))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
771 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
772 ;; we're done, insert everything into the file |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
773 (save-current-buffer |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
774 (let ((coding-system-for-write 'utf-8)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
775 (set-buffer (find-file ical-filename)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
776 (goto-char (point-max)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
777 (insert "BEGIN:VCALENDAR") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
778 (insert "\nPRODID:-//Emacs//NONSGML icalendar.el//EN") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
779 (insert "\nVERSION:2.0") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
780 (insert result) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
781 (insert "\nEND:VCALENDAR\n") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
782 ;; save the diary file |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
783 (save-buffer)))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
784 found-error)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
785 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
786 ;; subroutines |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
787 (defun icalendar--convert-ordinary-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
788 "Convert \"ordinary\" diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
789 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
790 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
791 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
792 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
793 "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
794 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
795 "\\(" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
796 "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
797 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
798 "\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
799 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
800 (let* ((datetime (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
801 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
802 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
803 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
804 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
805 datetime 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
806 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
807 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
808 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
809 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
810 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
811 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
812 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
813 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
814 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
815 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
816 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
817 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
818 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
819 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
820 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
821 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
822 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
823 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
824 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
825 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
826 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
827 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
828 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
829 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
830 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
831 (icalendar--dmsg "ordinary %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
832 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
833 (unless startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
834 (error "Could not parse date")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
835 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
836 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
837 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
838 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
839 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
840 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
841 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
842 (concat "\nDTSTART;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
843 (if starttimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
844 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
845 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
846 (or starttimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
847 "\nDTEND;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
848 (if endtimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
849 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
850 (if starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
851 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
852 endisostring) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
853 (or endtimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
854 "\nSUMMARY:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
855 summary)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
856 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
857 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
858 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
859 (defun icalendar--convert-weekly-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
860 "Convert weekly diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
861 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
862 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
863 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
864 (if (and (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
865 "\\([a-z]+\\)\\s-+" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
866 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
867 "\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
868 "\\(-0?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
869 "\\([1-9][0-9]?:[0-9][0-9]\\)" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
870 "\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
871 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
872 "\\s-*\\(.*\\)$") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
873 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
874 (icalendar--get-weekday-abbrev |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
875 (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
876 (match-end 1)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
877 (let* ((day (icalendar--get-weekday-abbrev |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
878 (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
879 (match-end 1)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
880 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
881 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
882 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
883 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
884 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
885 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
886 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
887 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
888 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
889 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
890 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
891 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
892 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
893 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
894 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
895 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
896 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
897 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
898 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
899 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
900 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
901 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
902 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
903 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
904 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
905 (icalendar--dmsg "weekly %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
906 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
907 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
908 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
909 (let ((time (read |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
910 (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
911 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
912 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
913 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
914 (concat "\nDTSTART;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
915 (if starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
916 "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
917 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
918 ;; find the correct week day, |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
919 ;; 1st january 2000 was a saturday |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
920 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
921 "200001%02d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
922 (+ (icalendar--get-weekday-number day) 2)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
923 (or starttimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
924 "\nDTEND;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
925 (if endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
926 "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
927 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
928 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
929 "200001%02d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
930 ;; end is non-inclusive! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
931 (+ (icalendar--get-weekday-number day) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
932 (if endtimestring 2 3))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
933 (or endtimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
934 "\nSUMMARY:" summary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
935 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
936 day)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
937 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
938 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
939 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
940 (defun icalendar--convert-yearly-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
941 "Convert yearly diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
942 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
943 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
944 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
945 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
946 (if european-calendar-style |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
947 "0?\\([1-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
948 "\\([a-z]+\\)\\s-+0?\\([1-9]+[0-9]?\\)\\s-+") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
949 "\\*?\\s-*" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
950 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
951 "\\(" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
952 "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
953 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
954 "\\s-*\\([^0-9]+.*\\)$" ; must not match years |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
955 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
956 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
957 (let* ((daypos (if european-calendar-style 1 2)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
958 (monpos (if european-calendar-style 2 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
959 (day (read (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
960 (match-beginning daypos) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
961 (match-end daypos)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
962 (month (icalendar--get-month-number |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
963 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
964 (match-beginning monpos) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
965 (match-end monpos)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
966 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
967 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
968 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
969 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
970 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
971 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
972 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
973 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
974 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
975 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
976 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
977 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
978 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
979 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
980 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
981 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
982 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
983 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
984 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
985 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
986 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
987 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
988 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
989 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
990 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
991 (icalendar--dmsg "yearly %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
992 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
993 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
994 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
995 (let ((time (read |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
996 (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
997 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
998 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
999 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1000 (concat "\nDTSTART;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1001 (if starttimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1002 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1003 (format "1900%02d%02d" month day) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1004 (or starttimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1005 "\nDTEND;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1006 (if endtimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1007 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1008 ;; end is not included! shift by one day |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1009 (icalendar--date-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1010 (list month day 1900) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1011 (if endtimestring 0 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1012 (or endtimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1013 "\nSUMMARY:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1014 summary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1015 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1016 (format "%2d" month) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1017 ";BYMONTHDAY=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1018 (format "%2d" day))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1019 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1020 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1021 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1022 (defun icalendar--convert-sexp-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1023 "Convert complex sexp diary entry to icalendar format -- unsupported! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1024 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1025 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1026 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1027 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1028 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1029 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1030 "%%(\\([^)]+\\))\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1031 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1032 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1033 (icalendar--dmsg "diary-sexp %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1034 (error "Sexp-entries are not supported yet")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1035 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1036 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1037 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1038 (defun icalendar--convert-block-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1039 "Convert block diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1040 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1041 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1042 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1043 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1044 "%%(diary-block \\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1045 " +\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1046 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1047 "\\(" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1048 "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1049 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1050 "\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1051 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1052 (let* ((startstring (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1053 (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1054 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1055 (endstring (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1056 (match-beginning 2) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1057 (match-end 2))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1058 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1059 startstring)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1060 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1061 endstring)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1062 (endisostring+1 (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1063 endstring 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1064 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1065 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1066 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1067 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1068 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1069 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1070 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1071 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1072 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1073 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1074 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1075 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1076 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1077 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1078 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1079 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1080 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1081 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1082 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1083 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1084 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1085 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1086 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1087 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1088 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1089 (icalendar--dmsg "diary-block %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1090 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1091 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1092 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1093 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1094 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1095 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1096 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1097 (if starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1098 ;; with time -> write rrule |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1099 (concat "\nDTSTART;VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1100 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1101 starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1102 "\nDTEND;VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1103 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1104 endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1105 "\nSUMMARY:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1106 summary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1107 "\nRRULE:FREQ=DAILY;INTERVAL=1;UNTIL=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1108 endisostring) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1109 ;; no time -> write long event |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1110 (concat "\nDTSTART;VALUE=DATE:" startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1111 "\nDTEND;VALUE=DATE:" endisostring+1 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1112 "\nSUMMARY:" summary))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1113 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1114 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1115 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1116 (defun icalendar--convert-float-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1117 "Convert float diary entry to icalendar format -- unsupported! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1118 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1119 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1120 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1121 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1122 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1123 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1124 "%%(diary-float \\([^)]+\\))\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1125 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1126 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1127 (icalendar--dmsg "diary-float %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1128 (error "`diary-float' is not supported yet")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1129 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1130 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1131 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1132 (defun icalendar--convert-date-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1133 "Convert `diary-date' diary entry to icalendar format -- unsupported! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1134 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1135 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1136 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1137 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1138 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1139 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1140 "%%(diary-date \\([^)]+\\))\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1141 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1142 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1143 (icalendar--dmsg "diary-date %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1144 (error "`diary-date' is not supported yet")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1145 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1146 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1147 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1148 (defun icalendar--convert-cyclic-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1149 "Convert `diary-cyclic' diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1150 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1151 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1152 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1153 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1154 "%%(diary-cyclic \\([^ ]+\\) +" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1155 "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1156 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1157 "\\(" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1158 "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1159 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1160 "\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1161 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1162 (let* ((frequency (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1163 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1164 (datetime (substring entry-main (match-beginning 2) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1165 (match-end 2))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1166 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1167 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1168 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1169 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1170 (endisostring+1 (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1171 datetime 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1172 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1173 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1174 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1175 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1176 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1177 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1178 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1179 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1180 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1181 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1182 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1183 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1184 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1185 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1186 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1187 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1188 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1189 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1190 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1191 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1192 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1193 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1194 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1195 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1196 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1197 (icalendar--dmsg "diary-cyclic %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1198 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1199 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1200 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1201 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1202 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1203 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1204 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1205 (concat "\nDTSTART;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1206 (if starttimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1207 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1208 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1209 (or starttimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1210 "\nDTEND;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1211 (if endtimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1212 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1213 (if endtimestring endisostring endisostring+1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1214 (or endtimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1215 "\nSUMMARY:" summary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1216 "\nRRULE:FREQ=DAILY;INTERVAL=" frequency |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1217 ;; strange: korganizer does not expect |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1218 ;; BYSOMETHING here... |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1219 )) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1220 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1221 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1222 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1223 (defun icalendar--convert-anniversary-to-ical (nonmarker entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1224 "Convert `diary-anniversary' diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1225 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1226 NONMARKER is a regular expression matching the start of non-marking |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1227 entries. ENTRY-MAIN is the first line of the diary entry." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1228 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1229 "%%(diary-anniversary \\([^)]+\\))\\s-*" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1230 "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1231 "\\(" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1232 "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1233 "\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1234 "\\s-*\\(.*\\)") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1235 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1236 (let* ((datetime (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1237 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1238 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1239 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1240 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1241 datetime 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1242 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1243 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1244 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1245 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1246 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1247 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1248 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1249 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1250 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1251 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1252 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1253 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1254 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1255 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1256 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1257 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1258 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1259 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1260 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1261 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1262 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1263 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1264 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1265 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1266 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1267 (icalendar--dmsg "diary-anniversary %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1268 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1269 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1270 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1271 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1272 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1273 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1274 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1275 (concat "\nDTSTART;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1276 (if starttimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1277 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1278 startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1279 (or starttimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1280 "\nDTEND;" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1281 (if endtimestring "VALUE=DATE-TIME:" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1282 "VALUE=DATE:") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1283 endisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1284 (or endtimestring "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1285 "\nSUMMARY:" summary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1286 "\nRRULE:FREQ=YEARLY;INTERVAL=1" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1287 ;; the following is redundant, |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1288 ;; but korganizer seems to expect this... ;( |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1289 ;; and evolution doesn't understand it... :( |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1290 ;; so... who is wrong?! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1291 ";BYMONTH=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1292 (substring startisostring 4 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1293 ";BYMONTHDAY=" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1294 (substring startisostring 6 8))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1295 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1296 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1297 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1298 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1299 ;; Import -- convert icalendar to emacs-diary |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1300 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1301 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
1302 ;;;###autoload |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1303 (defun icalendar-import-file (ical-filename diary-filename |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1304 &optional non-marking) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1305 "Import a iCalendar file and append to a diary file. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1306 Argument ICAL-FILENAME output iCalendar file. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1307 Argument DIARY-FILENAME input `diary-file'. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1308 Optional argument NON-MARKING determines whether events are created as |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1309 non-marking or not." |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1310 (interactive "fImport iCalendar data from file: |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1311 Finto diary file: |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1312 p") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1313 ;; clean up the diary file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1314 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1315 ;; now load and convert from the ical file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1316 (set-buffer (find-file ical-filename)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1317 (icalendar-import-buffer diary-filename t non-marking))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1318 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
1319 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1320 (defun icalendar-import-buffer (&optional diary-file do-not-ask |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1321 non-marking) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1322 "Extract iCalendar events from current buffer. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1323 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1324 This function searches the current buffer for the first iCalendar |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1325 object, reads it and adds all VEVENT elements to the diary |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1326 DIARY-FILE. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1327 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1328 It will ask for each appointment whether to add it to the diary |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1329 when DO-NOT-ASK is non-nil. When called interactively, |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1330 DO-NOT-ASK is set to t, so that you are asked fore each event. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1331 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1332 NON-MARKING determines whether diary events are created as |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1333 non-marking. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1334 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1335 Return code t means that importing worked well, return code nil |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1336 means that an error has occured. Error messages will be in the |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1337 buffer `*icalendar-errors*'." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1338 (interactive) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1339 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1340 ;; prepare ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1341 (message "Preparing icalendar...") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1342 (set-buffer (icalendar--get-unfolded-buffer (current-buffer))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1343 (goto-char (point-min)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1344 (message "Preparing icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1345 (if (re-search-forward "^BEGIN:VCALENDAR\\s-*$" nil t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1346 (let (ical-contents ical-errors) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1347 ;; read ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1348 (message "Reading icalendar...") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1349 (beginning-of-line) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1350 (setq ical-contents (icalendar--read-element nil nil)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1351 (message "Reading icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1352 ;; convert ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1353 (message "Converting icalendar...") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1354 (setq ical-errors (icalendar--convert-ical-to-diary |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1355 ical-contents |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1356 diary-file do-not-ask non-marking)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1357 (when diary-file |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1358 ;; save the diary file if it is visited already |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1359 (let ((b (find-buffer-visiting diary-file))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1360 (when b |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1361 (save-current-buffer |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1362 (set-buffer b) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1363 (save-buffer))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1364 (message "Converting icalendar...done") |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1365 ;; return t if no error occured |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1366 (not ical-errors)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1367 (message |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1368 "Current buffer does not contain icalendar contents!") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1369 ;; return nil, i.e. import did not work |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1370 nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1371 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1372 (defalias 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1373 (make-obsolete 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1374 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1375 (defun icalendar--format-ical-event (event) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1376 "Create a string representation of an iCalendar EVENT." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1377 (let ((string icalendar-import-format) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1378 (conversion-list |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1379 '(("%d" DESCRIPTION icalendar-import-format-description) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1380 ("%s" SUMMARY icalendar-import-format-subject) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1381 ("%l" LOCATION icalendar-import-format-location) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1382 ("%o" ORGANIZER icalendar-import-format-organizer)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1383 ;; convert the specifiers in the format string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1384 (mapcar (lambda (i) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1385 (let* ((spec (car i)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1386 (prop (cadr i)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1387 (format (car (cddr i))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1388 (contents (icalendar--get-event-property event prop)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1389 (formatted-contents "")) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1390 (when (and contents (> (length contents) 0)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1391 (setq formatted-contents |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1392 (icalendar--rris "%s" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1393 (icalendar--convert-string-for-import |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1394 contents) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1395 (symbol-value format)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1396 (setq string (icalendar--rris spec |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1397 formatted-contents |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1398 string)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1399 conversion-list) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1400 string)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1401 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1402 (defun icalendar--convert-ical-to-diary (ical-list diary-file |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1403 &optional do-not-ask |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1404 non-marking) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1405 "Convert an iCalendar file to an Emacs diary file. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1406 Import VEVENTS from the iCalendar object ICAL-LIST and saves them to a |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1407 DIARY-FILE. If DO-NOT-ASK is nil the user is asked for each event |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1408 whether to actually import it. NON-MARKING determines whether diary |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1409 events are created as non-marking. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1410 This function attempts to return t if something goes wrong. In this |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1411 case an error string which describes all the errors and problems is |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1412 written into the buffer `*icalendar-errors*'." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1413 (let* ((ev (icalendar--all-events ical-list)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1414 (error-string "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1415 (event-ok t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1416 (found-error nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1417 e diary-string) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1418 ;; step through all events/appointments |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1419 (while ev |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1420 (setq e (car ev)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1421 (setq ev (cdr ev)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1422 (setq event-ok nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1423 (condition-case error-val |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1424 (let* ((dtstart (icalendar--get-event-property e 'DTSTART)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1425 (dtstart-dec (icalendar--decode-isodatetime dtstart)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1426 (start-d (icalendar--datetime-to-diary-date |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1427 dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1428 (start-t (icalendar--datetime-to-colontime dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1429 (dtend (icalendar--get-event-property e 'DTEND)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1430 (dtend-dec (icalendar--decode-isodatetime dtend)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1431 (dtend-1-dec (icalendar--decode-isodatetime dtend -1)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1432 end-d |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1433 end-1-d |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1434 end-t |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1435 (subject (icalendar--convert-string-for-import |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1436 (or (icalendar--get-event-property e 'SUMMARY) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1437 "No Subject"))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1438 (rrule (icalendar--get-event-property e 'RRULE)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1439 (rdate (icalendar--get-event-property e 'RDATE)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1440 (duration (icalendar--get-event-property e 'DURATION))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1441 (icalendar--dmsg "%s: `%s'" start-d subject) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1442 ;; check whether start-time is missing |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1443 (if (and dtstart |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1444 (string= |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1445 (cadr (icalendar--get-event-property-attributes |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1446 e 'DTSTART)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1447 "DATE")) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1448 (setq start-t nil)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1449 (when duration |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1450 (let ((dtend-dec-d (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1451 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1452 (icalendar--decode-isoduration duration))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1453 (dtend-1-dec-d (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1454 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1455 (icalendar--decode-isoduration duration |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1456 t)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1457 (if (and dtend-dec (not (eq dtend-dec dtend-dec-d))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1458 (message "Inconsistent endtime and duration for %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1459 subject)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1460 (setq dtend-dec dtend-dec-d) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1461 (setq dtend-1-dec dtend-1-dec-d))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1462 (setq end-d (if dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1463 (icalendar--datetime-to-diary-date dtend-dec) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1464 start-d)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1465 (setq end-1-d (if dtend-1-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1466 (icalendar--datetime-to-diary-date dtend-1-dec) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1467 start-d)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1468 (setq end-t (if (and |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1469 dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1470 (not (string= |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1471 (cadr |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1472 (icalendar--get-event-property-attributes |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1473 e 'DTEND)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1474 "DATE"))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1475 (icalendar--datetime-to-colontime dtend-dec) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1476 start-t)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1477 (icalendar--dmsg "start-d: %s, end-d: %s" start-d end-d) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1478 (cond |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1479 ;; recurring event |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1480 (rrule |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1481 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1482 (icalendar--convert-recurring-to-diary e dtstart-dec start-t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1483 end-t)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1484 (setq event-ok t)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1485 (rdate |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1486 (icalendar--dmsg "rdate event") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1487 (setq diary-string "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1488 (mapcar (lambda (datestring) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1489 (setq diary-string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1490 (concat diary-string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1491 (format "......")))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1492 (icalendar--split-value rdate))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1493 ;; non-recurring event |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
1494 ;; all-day event |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1495 ((not (string= start-d end-d)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1496 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1497 (icalendar--convert-non-recurring-all-day-to-diary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1498 e start-d end-1-d)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1499 (setq event-ok t)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1500 ;; not all-day |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1501 ((and start-t (or (not end-t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1502 (not (string= start-t end-t)))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1503 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1504 (icalendar--convert-non-recurring-not-all-day-to-diary |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1505 e dtstart-dec dtend-dec start-t end-t)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1506 (setq event-ok t)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1507 ;; all-day event |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1508 (t |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1509 (icalendar--dmsg "all day event") |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1510 (setq diary-string (icalendar--datetime-to-diary-date |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1511 dtstart-dec "/")) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1512 (setq event-ok t))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1513 ;; add all other elements unless the user doesn't want to have |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1514 ;; them |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1515 (if event-ok |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1516 (progn |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1517 (setq diary-string |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1518 (concat diary-string " " |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1519 (icalendar--format-ical-event e))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1520 (if do-not-ask (setq subject nil)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1521 (icalendar--add-diary-entry diary-string diary-file |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1522 non-marking subject)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1523 ;; event was not ok |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1524 (setq found-error t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1525 (setq error-string |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1526 (format "%s\nCannot handle this event:%s" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1527 error-string e)))) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1528 ;; FIXME: inform user about ignored event properties |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1529 ;; handle errors |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1530 (error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1531 (message "Ignoring event \"%s\"" e) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1532 (setq found-error t) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1533 (setq error-string (format "%s\n%s\nCannot handle this event: %s" |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1534 error-val error-string e)) |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64432
diff
changeset
|
1535 (message "%s" error-string)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1536 (if found-error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1537 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1538 (set-buffer (get-buffer-create "*icalendar-errors*")) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1539 (erase-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1540 (insert error-string))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1541 (message "Converting icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1542 found-error)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1543 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1544 ;; subroutines for importing |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1545 (defun icalendar--convert-recurring-to-diary (e dtstart-dec start-t end-t) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1546 "Convert recurring icalendar event E to diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1547 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1548 DTSTART-DEC is the DTSTART property of E. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1549 START-T is the event's start time in diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1550 END-T is the event's end time in diary format." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1551 (icalendar--dmsg "recurring event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1552 (let* ((rrule (icalendar--get-event-property e 'RRULE)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1553 (rrule-props (icalendar--split-value rrule)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1554 (frequency (cadr (assoc 'FREQ rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1555 (until (cadr (assoc 'UNTIL rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1556 (count (cadr (assoc 'COUNT rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1557 (interval (read (or (cadr (assoc 'INTERVAL rrule-props)) "1"))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1558 (dtstart-conv (icalendar--datetime-to-diary-date dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1559 (until-conv (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1560 (icalendar--decode-isodatetime until))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1561 (until-1-conv (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1562 (icalendar--decode-isodatetime until -1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1563 (result "")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1564 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1565 ;; FIXME FIXME interval!!!!!!!!!!!!! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1566 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1567 (when count |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1568 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1569 (message "Must not have UNTIL and COUNT -- ignoring COUNT element!") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1570 (let ((until-1 0)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1571 (cond ((string-equal frequency "DAILY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1572 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1573 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1574 (list 0 0 0 (* (read count) interval) 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1575 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1576 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1577 (list 0 0 0 (* (- (read count) 1) interval) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1578 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1579 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1580 ((string-equal frequency "WEEKLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1581 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1582 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1583 (list 0 0 0 (* (read count) 7 interval) 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1584 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1585 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1586 (list 0 0 0 (* (- (read count) 1) 7 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1587 interval) 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1588 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1589 ((string-equal frequency "MONTHLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1590 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1591 dtstart-dec (list 0 0 0 0 (* (- (read count) 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1592 interval) 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1593 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1594 dtstart-dec (list 0 0 0 0 (* (- (read count) 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1595 interval) 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1596 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1597 ((string-equal frequency "YEARLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1598 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1599 dtstart-dec (list 0 0 0 0 0 (* (- (read count) 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1600 interval)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1601 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1602 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1603 (list 0 0 0 0 0 (* (- (read count) 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1604 interval)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1605 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1606 (t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1607 (message "Cannot handle COUNT attribute for `%s' events." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1608 frequency))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1609 (setq until-conv (icalendar--datetime-to-diary-date until)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1610 (setq until-1-conv (icalendar--datetime-to-diary-date until-1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1611 )) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1612 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1613 (cond ((string-equal frequency "WEEKLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1614 (if (not start-t) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1615 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1616 ;; weekly and all-day |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1617 (icalendar--dmsg "weekly all-day") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1618 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1619 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1620 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1621 (concat "%%%%(and " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1622 "(diary-cyclic %d %s) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1623 "(diary-block %s %s))") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1624 (* interval 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1625 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1626 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1627 (if count until-1-conv until-conv) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1628 )) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1629 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1630 (format "%%%%(and (diary-cyclic %d %s))" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1631 (* interval 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1632 dtstart-conv)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1633 ;; weekly and not all-day |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1634 (let* ((byday (cadr (assoc 'BYDAY rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1635 (weekday |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1636 (icalendar--get-weekday-number byday))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1637 (icalendar--dmsg "weekly not-all-day") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1638 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1639 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1640 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1641 (concat "%%%%(and " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1642 "(diary-cyclic %d %s) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1643 "(diary-block %s %s)) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1644 "%s%s%s") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1645 (* interval 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1646 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1647 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1648 until-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1649 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1650 (if end-t "-" "") (or end-t ""))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1651 ;; no limit |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1652 ;; FIXME!!!! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1653 ;; DTSTART;VALUE=DATE-TIME:20030919T090000 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1654 ;; DTEND;VALUE=DATE-TIME:20030919T113000 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1655 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1656 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1657 "%%%%(and (diary-cyclic %s %s)) %s%s%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1658 (* interval 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1659 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1660 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1661 (if end-t "-" "") (or end-t ""))))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1662 ;; yearly |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1663 ((string-equal frequency "YEARLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1664 (icalendar--dmsg "yearly") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1665 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1666 (setq result (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1667 (concat "%%%%(and (diary-date %s %s t) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1668 "(diary-block %s %s)) %s%s%s") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1669 (if european-calendar-style (nth 3 dtstart-dec) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1670 (nth 4 dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1671 (if european-calendar-style (nth 4 dtstart-dec) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1672 (nth 3 dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1673 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1674 until-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1675 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1676 (if end-t "-" "") (or end-t ""))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1677 (setq result (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1678 "%%%%(and (diary-anniversary %s)) %s%s%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1679 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1680 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1681 (if end-t "-" "") (or end-t ""))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1682 ;; monthly |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1683 ((string-equal frequency "MONTHLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1684 (icalendar--dmsg "monthly") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1685 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1686 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1687 "%%%%(and (diary-date %s %s %s) (diary-block %s %s)) %s%s%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1688 (if european-calendar-style (nth 3 dtstart-dec) "t") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1689 (if european-calendar-style "t" (nth 3 dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1690 "t" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1691 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1692 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1693 until-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1694 "1 1 9999") ;; FIXME: should be unlimited |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1695 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1696 (if end-t "-" "") (or end-t "")))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1697 ;; daily |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1698 ((and (string-equal frequency "DAILY")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1699 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1700 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1701 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1702 (concat "%%%%(and (diary-cyclic %s %s) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1703 "(diary-block %s %s)) %s%s%s") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1704 interval dtstart-conv dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1705 (if count until-1-conv until-conv) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1706 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1707 (if end-t "-" "") (or end-t ""))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1708 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1709 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1710 "%%%%(and (diary-cyclic %s %s)) %s%s%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1711 interval |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1712 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1713 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1714 (if end-t "-" "") (or end-t "")))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1715 ;; Handle exceptions from recurrence rules |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1716 (let ((ex-dates (icalendar--get-event-properties e 'EXDATE))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1717 (while ex-dates |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1718 (let* ((ex-start (icalendar--decode-isodatetime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1719 (car ex-dates))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1720 (ex-d (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1721 ex-start))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1722 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1723 (icalendar--rris "^%%(\\(and \\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1724 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1725 "%%%%(and (not (diary-date %s)) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1726 ex-d) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1727 result))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1728 (setq ex-dates (cdr ex-dates)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1729 ;; FIXME: exception rules are not recognized |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1730 (if (icalendar--get-event-property e 'EXRULE) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1731 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1732 (concat result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1733 "\n Exception rules: " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1734 (icalendar--get-event-properties |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1735 e 'EXRULE)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1736 result)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1737 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1738 (defun icalendar--convert-non-recurring-all-day-to-diary (event start-d end-d) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1739 "Convert non-recurring icalendar EVENT to diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1740 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1741 DTSTART is the decoded DTSTART property of E. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1742 Argument START-D gives the first day. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1743 Argument END-D gives the last day." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1744 (icalendar--dmsg "non-recurring all-day event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1745 (format "%%%%(and (diary-block %s %s))" start-d end-d)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1746 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1747 (defun icalendar--convert-non-recurring-not-all-day-to-diary (event dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1748 dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1749 start-t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1750 end-t) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1751 "Convert recurring icalendar EVENT to diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1752 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1753 DTSTART-DEC is the decoded DTSTART property of E. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1754 DTEND-DEC is the decoded DTEND property of E. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1755 START-T is the event's start time in diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1756 END-T is the event's end time in diary format." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1757 (icalendar--dmsg "not all day event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1758 (cond (end-t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1759 (format "%s %s-%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1760 (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1761 dtstart-dec "/") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1762 start-t end-t)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1763 (t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1764 (format "%s %s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1765 (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1766 dtstart-dec "/") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1767 start-t)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1768 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1769 (defun icalendar--add-diary-entry (string diary-file non-marking |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1770 &optional subject) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1771 "Add STRING to the diary file DIARY-FILE. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1772 STRING must be a properly formatted valid diary entry. NON-MARKING |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1773 determines whether diary events are created as non-marking. If |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1774 SUBJECT is not nil it must be a string that gives the subject of the |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1775 entry. In this case the user will be asked whether he wants to insert |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1776 the entry." |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1777 (when (or (not subject) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1778 (y-or-n-p (format "Add appointment for `%s' to diary? " |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1779 subject))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1780 (when subject |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1781 (setq non-marking |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1782 (y-or-n-p (format "Make appointment non-marking? ")))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1783 (save-window-excursion |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1784 (unless diary-file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1785 (setq diary-file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1786 (read-file-name "Add appointment to this diary file: "))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1787 (make-diary-entry string non-marking diary-file)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1788 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1789 (provide 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1790 |
57345
f024640dc5e4
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
57337
diff
changeset
|
1791 ;; arch-tag: 74fdbe8e-0451-4e38-bb61-4416e822f4fc |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1792 ;;; icalendar.el ends here |