Mercurial > emacs
annotate lisp/calendar/icalendar.el @ 111541:ca0d9a916432
Repeat 2010-11-14 change to xfns.c for w32 and ns.
* w32fns.c (Fx_create_frame):
* nsfns.m (Fx_create_frame): Don't check for the cursorColor
resource here; it's now done at startup.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 14 Nov 2010 14:58:24 -0500 |
parents | a3e1f7134e6e |
children | 417b1e4d63cd |
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 |
106815 | 3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
5 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
6 ;; Author: Ulf Jasper <ulf.jasper@web.de> |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
7 ;; Created: August 2002 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
8 ;; Keywords: calendar |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
9 ;; Human-Keywords: calendar, diary, iCalendar, vCalendar |
110016
a3e1f7134e6e
Add "Version:" and "Package:" Lisp file headers.
Chong Yidong <cyd@stupidchicken.com>
parents:
109808
diff
changeset
|
10 ;; Version: 0.19 |
57337
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 ;; 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
|
13 |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93790
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93790
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93790
diff
changeset
|
17 ;; (at your option) any later version. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
18 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93790
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
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 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
43 ;; 0.06: (2004-10-06) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
44 ;; - Bugfixes regarding icalendar-import-format-*. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
45 ;; - Fix in icalendar-convert-diary-to-ical -- thanks to Philipp Grau. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
46 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
47 ;; 0.05: (2003-06-19) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
48 ;; - New import format scheme: Replaced icalendar-import-prefix-*, |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
49 ;; icalendar-import-ignored-properties, and |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
50 ;; icalendar-import-separator with icalendar-import-format(-*). |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
51 ;; - icalendar-import-file and icalendar-convert-diary-to-ical |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
52 ;; have an extra parameter which should prevent them from |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
53 ;; erasing their target files (untested!). |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
54 ;; - Tested with Emacs 21.3.2 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
55 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
56 ;; 0.04: |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
57 ;; - Bugfix: import: double quoted param values did not work |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
58 ;; - Read DURATION property when importing. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
59 ;; - Added parameter icalendar-duration-correction. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
60 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
61 ;; 0.03: (2003-05-07) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
62 ;; - Export takes care of european-calendar-style. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
63 ;; - Tested with Emacs 21.3.2 and XEmacs 21.4.12 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
64 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
65 ;; 0.02: |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
66 ;; - Should work in XEmacs now. Thanks to Len Trigg for the XEmacs patches! |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
67 ;; - Added exporting from Emacs diary to ical. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
68 ;; - Some bugfixes, after testing with calendars from http://icalshare.com. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
69 ;; - Tested with Emacs 21.3.2 and XEmacs 21.4.12 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
70 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
71 ;; 0.01: (2003-03-21) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
72 ;; - First published version. Trial version. Alpha version. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
73 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
74 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
75 ;; To Do: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
76 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
77 ;; * Import from ical to diary: |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
78 ;; + Need more properties for icalendar-import-format |
74673
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
79 ;; (added all that Mozilla Calendar uses) |
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
80 ;; From iCal specifications (RFC2445: 4.8.1), icalendar.el lacks |
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
81 ;; ATTACH, CATEGORIES, COMMENT, GEO, PERCENT-COMPLETE (VTODO), |
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
82 ;; PRIORITY, RESOURCES) not considering date/time and time-zone |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
83 ;; + check vcalendar version |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
84 ;; + check (unknown) elements |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
85 ;; + recurring events! |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
86 ;; + 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
|
87 ;; + alarm |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
88 ;; + exceptions in recurring events |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
89 ;; + the parser is too soft |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
90 ;; + error log is incomplete |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
91 ;; + nice to have: #include "webcal://foo.com/some-calendar.ics" |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
92 ;; + timezones probably still need some improvements. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
93 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
94 ;; * Export from diary to ical |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
95 ;; + 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
|
96 ;; understood |
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 ;; * Other things |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
99 ;; + 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
|
100 ;; + Handle todo items? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
101 ;; + 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
|
102 ;; + Which chars to (un)escape? |
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 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
105 ;;; Code: |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
106 |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
107 (defconst icalendar-version "0.19" |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
108 "Version number of icalendar.el.") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
109 |
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 ;; Customizables |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
112 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
113 (defgroup icalendar nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
114 "Icalendar support." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
115 :prefix "icalendar-" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
116 :group 'calendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
117 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
118 (defcustom icalendar-import-format |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
119 "%s%d%l%o" |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
120 "Format for importing events from iCalendar into Emacs diary. |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
121 It defines how iCalendar events are inserted into diary file. |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
122 This may either be a string or a function. |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
123 |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
124 In case of a formatting STRING the following specifiers can be used: |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
125 %c Class, see `icalendar-import-format-class' |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
126 %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
|
127 %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
|
128 %o Organizer, see `icalendar-import-format-organizer' |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
129 %s Summary, see `icalendar-import-format-summary' |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
130 %t Status, see `icalendar-import-format-status' |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
131 %u URL, see `icalendar-import-format-url' |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
132 |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
133 A formatting FUNCTION will be called with a VEVENT as its only |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
134 argument. It must return a string. See |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
135 `icalendar-import-format-sample' for an example." |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
136 :type '(choice |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
137 (string :tag "String") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
138 (function :tag "Function")) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
139 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
140 |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
141 (defcustom icalendar-import-format-summary |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
142 "%s" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
143 "Format string defining how the summary element is formatted. |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
144 This applies only if the summary is not empty! `%s' is replaced |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
145 by the summary." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
146 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
147 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
148 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
149 (defcustom icalendar-import-format-description |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
150 "\n Desc: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
151 "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
|
152 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
|
153 replaced by the description." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
154 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
155 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
156 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
157 (defcustom icalendar-import-format-location |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
158 "\n Location: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
159 "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
|
160 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
|
161 by the location." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
162 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
163 :group 'icalendar) |
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 (defcustom icalendar-import-format-organizer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
166 "\n Organizer: %s" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
167 "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
|
168 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
|
169 replaced by the organizer." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
170 :type 'string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
171 :group 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
172 |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
173 (defcustom icalendar-import-format-url |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
174 "\n URL: %s" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
175 "Format string defining how the URL element is formatted. |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
176 This applies only if the URL is not empty! `%s' is replaced by |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
177 the URL." |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
178 :type 'string |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
179 :group 'icalendar) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
180 |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
181 (defcustom icalendar-import-format-status |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
182 "\n Status: %s" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
183 "Format string defining how the status element is formatted. |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
184 This applies only if the status is not empty! `%s' is replaced by |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
185 the status." |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
186 :type 'string |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
187 :group 'icalendar) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
188 |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
189 (defcustom icalendar-import-format-class |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
190 "\n Class: %s" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
191 "Format string defining how the class element is formatted. |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
192 This applies only if the class is not empty! `%s' is replaced by |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
193 the class." |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
194 :type 'string |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
195 :group 'icalendar) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
196 |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
197 (defcustom icalendar-recurring-start-year |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
198 2005 |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
199 "Start year for recurring events. |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
200 Some calendar browsers only propagate recurring events for |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
201 several years beyond the start time. Set this string to a year |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
202 just before the start of your personal calendar." |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
203 :type 'integer |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
204 :group 'icalendar) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
205 |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
206 (defcustom icalendar-export-hidden-diary-entries |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
207 t |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
208 "Determines whether hidden diary entries are exported. |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
209 If non-nil hidden diary entries (starting with `&') get exported, |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
210 if nil they are ignored." |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
211 :type 'boolean |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
212 :group 'icalendar) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
213 |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
214 (defcustom icalendar-uid-format |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
215 "emacs%t%c" |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
216 "Format of unique ID code (UID) for each iCalendar object. |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
217 The following specifiers are available: |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
218 %c COUNTER, an integer value that is increased each time a uid is |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
219 generated. This may be necessary for systems which do not |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
220 provide time-resolution finer than a second. |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
221 %h HASH, a hash value of the diary entry, |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
222 %s DTSTART, the start date (excluding time) of the diary entry, |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
223 %t TIMESTAMP, a unique creation timestamp, |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
224 %u USERNAME, the variable `user-login-name'. |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
225 |
101497
dd2ac0d143cb
icalendar: fixed doc string.
Ulf Jasper <ulf.jasper@web.de>
parents:
101457
diff
changeset
|
226 For example, a value of \"%s_%h@mydomain.com\" will generate a |
dd2ac0d143cb
icalendar: fixed doc string.
Ulf Jasper <ulf.jasper@web.de>
parents:
101457
diff
changeset
|
227 UID code for each entry composed of the time of the event, a hash |
dd2ac0d143cb
icalendar: fixed doc string.
Ulf Jasper <ulf.jasper@web.de>
parents:
101457
diff
changeset
|
228 code for the event, and your personal domain name." |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
229 :type 'string |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
230 :group 'icalendar) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
231 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
232 (defvar icalendar-debug nil |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
233 "Enable icalendar debug messages.") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
234 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
235 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
236 ;; 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
|
237 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
238 |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
239 (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
|
240 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
241 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
242 ;; all the other libs we need |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
243 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
244 (require 'calendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
245 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
246 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
247 ;; misc |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
248 ;; ====================================================================== |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
249 (defun icalendar--dmsg (&rest args) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
250 "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
|
251 (if icalendar-debug |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
252 (apply 'message args))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
253 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
254 ;; ====================================================================== |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
255 ;; Core functionality |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
256 ;; 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
|
257 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
258 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
259 (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
|
260 "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
|
261 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
|
262 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
|
263 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
|
264 buffer." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
265 (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
|
266 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
267 (set-buffer unfolded-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
268 (erase-buffer) |
64432
cd3c7f95237e
(icalendar--get-unfolded-buffer): Use `insert-buffer-substring' and `goto-char',
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
269 (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
|
270 (goto-char (point-min)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
271 (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
|
272 (replace-match "" nil nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
273 unfolded-buffer)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
274 |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
275 (defsubst icalendar--rris (regexp rep string &optional fixedcase literal) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
276 "Replace regular expression in string. |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
277 Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
278 `replace-regexp-in-string' (Emacs) or to `replace-in-string' (XEmacs)." |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
279 (cond ((fboundp 'replace-regexp-in-string) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
280 ;; Emacs: |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
281 (replace-regexp-in-string regexp rep string fixedcase literal)) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
282 ((fboundp 'replace-in-string) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
283 ;; XEmacs: |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
284 (save-match-data ;; apparently XEmacs needs save-match-data |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
285 (replace-in-string string regexp rep literal))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
286 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
287 (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
|
288 "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
|
289 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
|
290 INPARAMS gives the current parameters..... |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
291 This function calls itself recursively for each nested calendar element |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
292 it finds." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
293 (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
|
294 value |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
295 (continue t)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
296 (setq children '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
297 (while (and continue |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
298 (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
|
299 (setq name (intern (match-string 1))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
300 (backward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
301 (setq params '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
302 (setq line '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
303 (while (looking-at ";") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
304 (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
|
305 (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
|
306 (re-search-forward "\\(\\([^;,:\"]+\\)\\|\"\\([^\"]+\\)\"\\)[;:]" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
307 nil t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
308 (backward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
309 (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
|
310 (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
|
311 (while (looking-at ",") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
312 (re-search-forward "\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\)" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
313 nil t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
314 (if (match-string 2) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
315 (setq param-value (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
316 (setq param-value (match-string 3))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
317 (setq param (append param param-value))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
318 (setq params (append params param))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
319 (unless (looking-at ":") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
320 (error "Oops")) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
321 (forward-char 1) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
322 (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
|
323 (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
|
324 (setq line (list name params value)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
325 (cond ((eq name 'BEGIN) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
326 (setq children |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
327 (append children |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
328 (list (icalendar--read-element (intern value) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
329 params))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
330 ((eq name 'END) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
331 (setq continue nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
332 (t |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
333 (setq element (append element (list line)))))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
334 (if invalue |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
335 (list invalue inparams element children) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
336 children))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
337 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
338 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
339 ;; helper functions for examining events |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
340 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
341 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
342 ;;(defsubst icalendar--get-all-event-properties (event) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
343 ;; "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
|
344 ;; (car (cddr event))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
345 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
346 (defun icalendar--get-event-property (event prop) |
68930
16194e6e2a7b
(icalendar--get-event-property, icalendar--get-event-property-attributes):
Juanma Barranquero <lekktu@gmail.com>
parents:
68721
diff
changeset
|
347 "For the given EVENT return the value of the first occurrence of PROP." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
348 (catch 'found |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
349 (let ((props (car (cddr event))) pp) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
350 (while props |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
351 (setq pp (car props)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
352 (if (eq (car pp) prop) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
353 (throw 'found (car (cddr pp)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
354 (setq props (cdr props)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
355 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
356 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
357 (defun icalendar--get-event-property-attributes (event prop) |
68930
16194e6e2a7b
(icalendar--get-event-property, icalendar--get-event-property-attributes):
Juanma Barranquero <lekktu@gmail.com>
parents:
68721
diff
changeset
|
358 "For the given EVENT return attributes of the first occurrence of PROP." |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
359 (catch 'found |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
360 (let ((props (car (cddr event))) pp) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
361 (while props |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
362 (setq pp (car props)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
363 (if (eq (car pp) prop) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
364 (throw 'found (cadr pp))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
365 (setq props (cdr props)))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
366 nil)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
367 |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
368 (defun icalendar--get-event-properties (event prop) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
369 "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
|
370 (let ((props (car (cddr event))) pp result) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
371 (while props |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
372 (setq pp (car props)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
373 (if (eq (car pp) prop) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
374 (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
|
375 (setq props (cdr props))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
376 result)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
377 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
378 ;; (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
|
379 ;; "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
|
380 ;; (catch 'found |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
381 ;; (let ((props (car (cddr event))) pp) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
382 ;; (while props |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
383 ;; (setq pp (car props)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
384 ;; (when (eq (car pp) prop) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
385 ;; (setcdr (cdr pp) new-value) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
386 ;; (throw 'found (car (cddr pp)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
387 ;; (setq props (cdr props))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
388 ;; (setq props (car (cddr event))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
389 ;; (setcar (cddr event) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
390 ;; (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
|
391 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
392 (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
|
393 "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
|
394 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
|
395 children." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
396 (let ((result nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
397 (children (cadr (cddr node)))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
398 (when (eq (car node) name) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
399 (setq result node)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
400 ;;(message "%s" node) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
401 (when children |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
402 (let ((subresult |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
403 (delq nil |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
404 (mapcar (lambda (n) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
405 (icalendar--get-children n name)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
406 children)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
407 (if subresult |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
408 (if result |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
409 (setq result (append result subresult)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
410 (setq result subresult))))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
411 result)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
412 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
413 ; private |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
414 (defun icalendar--all-events (icalendar) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
415 "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
|
416 (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
|
417 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
418 (defun icalendar--split-value (value-string) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
419 "Split VALUE-STRING at ';='." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
420 (let ((result '()) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
421 param-name param-value) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
422 (when value-string |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
423 (save-current-buffer |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
424 (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
|
425 (set-buffer-modified-p nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
426 (erase-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
427 (insert value-string) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
428 (goto-char (point-min)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
429 (while |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
430 (re-search-forward |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
431 "\\([A-Za-z0-9-]+\\)=\\(\\([^;:]+\\)\\|\"\\([^\"]+\\)\"\\);?" |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
432 nil t) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
433 (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
|
434 (setq param-value (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
435 (setq result |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
436 (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
|
437 result)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
438 |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
439 (defun icalendar--convert-tz-offset (alist dst-p) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
440 "Return a cons of two strings representing a timezone start. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
441 ALIST is an alist entry from a VTIMEZONE, like STANDARD. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
442 DST-P is non-nil if this is for daylight savings time. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
443 The strings are suitable for assembling into a TZ variable." |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
444 (let ((offset (car (cddr (assq 'TZOFFSETTO alist)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
445 (rrule-value (car (cddr (assq 'RRULE alist)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
446 (dtstart (car (cddr (assq 'DTSTART alist))))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
447 ;; FIXME: for now we only handle RRULE and not RDATE here. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
448 (when (and offset rrule-value dtstart) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
449 (let* ((rrule (icalendar--split-value rrule-value)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
450 (freq (cadr (assq 'FREQ rrule))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
451 (bymonth (cadr (assq 'BYMONTH rrule))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
452 (byday (cadr (assq 'BYDAY rrule)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
453 ;; FIXME: we don't correctly handle WKST here. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
454 (if (and (string= freq "YEARLY") bymonth) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
455 (cons |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
456 (concat |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
457 ;; Fake a name. |
106617
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
458 (if dst-p "DST" "STD") |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
459 ;; For TZ, OFFSET is added to the local time. So, |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
460 ;; invert the values. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
461 (if (eq (aref offset 0) ?-) "+" "-") |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
462 (substring offset 1 3) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
463 ":" |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
464 (substring offset 3 5)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
465 ;; The start time. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
466 (let* ((day (icalendar--get-weekday-number (substring byday -2))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
467 (week (if (eq day -1) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
468 byday |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
469 (substring byday 0 -2)))) |
106617
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
470 ;; "Translate" the icalendar way to specify the last |
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
471 ;; (sun|mon|...)day in month to the tzset way. |
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
472 (if (string= week "-1") ; last day as icalendar calls it |
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
473 (setq week "5")) ; last day as tzset calls it |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
474 (concat "M" bymonth "." week "." (if (eq day -1) "0" |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
475 (int-to-string day)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
476 ;; Start time. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
477 "/" |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
478 (substring dtstart -6 -4) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
479 ":" |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
480 (substring dtstart -4 -2) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
481 ":" |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
482 (substring dtstart -2))))))))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
483 |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
484 (defun icalendar--parse-vtimezone (alist) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
485 "Turn a VTIMEZONE ALIST into a cons (ID . TZ-STRING). |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
486 Return nil if timezone cannot be parsed." |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
487 (let* ((tz-id (icalendar--get-event-property alist 'TZID)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
488 (daylight (cadr (cdar (icalendar--get-children alist 'DAYLIGHT)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
489 (day (and daylight (icalendar--convert-tz-offset daylight t))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
490 (standard (cadr (cdar (icalendar--get-children alist 'STANDARD)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
491 (std (and standard (icalendar--convert-tz-offset standard nil)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
492 (if (and tz-id std) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
493 (cons tz-id |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
494 (if day |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
495 (concat (car std) (car day) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
496 "," (cdr day) "," (cdr std)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
497 (car std)))))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
498 |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
499 (defun icalendar--convert-all-timezones (icalendar) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
500 "Convert all timezones in the ICALENDAR into an alist. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
501 Each element of the alist is a cons (ID . TZ-STRING), |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
502 like `icalendar--parse-vtimezone'." |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
503 (let (result) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
504 (dolist (zone (icalendar--get-children (car icalendar) 'VTIMEZONE)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
505 (setq zone (icalendar--parse-vtimezone zone)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
506 (if zone |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
507 (setq result (cons zone result)))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
508 result)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
509 |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
510 (defun icalendar--find-time-zone (prop-list zone-map) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
511 "Return a timezone string for the time zone in PROP-LIST, or nil if none. |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
512 ZONE-MAP is a timezone alist as returned by `icalendar--convert-all-timezones'." |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
513 (let ((id (plist-get prop-list 'TZID))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
514 (if id |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
515 (cdr (assoc id zone-map))))) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
516 |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
517 (defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
518 zone) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
519 "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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 days. |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
525 ZONE, if provided, is the timezone, in any format understood by `encode-time'. |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
526 |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
527 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
|
528 (icalendar--dmsg isodatetimestring) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
529 (if isodatetimestring |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
530 ;; day/month/year must be present |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
531 (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
|
532 (month (read (substring isodatetimestring 4 6))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
533 (day (read (substring isodatetimestring 6 8))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
534 (hour 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
535 (minute 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
536 (second 0)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
537 (when (> (length isodatetimestring) 12) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
538 ;; hour/minute present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
539 (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
|
540 (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
|
541 (when (> (length isodatetimestring) 14) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
542 ;; seconds present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
543 (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
|
544 (when (and (> (length isodatetimestring) 15) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
545 ;; UTC specifier present |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
546 (char-equal ?Z (aref isodatetimestring 15))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
547 ;; 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
|
548 (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
|
549 ;; shift if necessary |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
550 (if day-shift |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
551 (let ((mdy (calendar-gregorian-from-absolute |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
552 (+ (calendar-absolute-from-gregorian |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
553 (list month day year)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
554 day-shift)))) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
555 (setq month (nth 0 mdy)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
556 (setq day (nth 1 mdy)) |
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
557 (setq year (nth 2 mdy)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
558 ;; create the decoded date-time |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
559 ;; FIXME!?! |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
560 (condition-case nil |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
561 (decode-time (encode-time second minute hour day month year zone)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
562 (error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
563 (message "Cannot decode \"%s\"" isodatetimestring) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
564 ;; hope for the best... |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
565 (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
|
566 ;; isodatetimestring == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
567 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
568 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
569 (defun icalendar--decode-isoduration (isodurationstring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
570 &optional duration-correction) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
571 "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
|
572 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
|
573 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
|
574 the local time zone! |
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
575 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
576 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
|
577 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
578 FIXME: TZID-attributes are ignored....! |
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
579 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
|
580 (if isodurationstring |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
581 (save-match-data |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
582 (string-match |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
583 (concat |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
584 "^P[+-]?\\(" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
585 "\\(\\([0-9]+\\)D\\)" ; days only |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
586 "\\|" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
587 "\\(\\(\\([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
|
588 "\\(\\([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
|
589 "\\|" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
590 "\\(\\([0-9]+\\)W\\)" ; weeks only |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
591 "\\)$") isodurationstring) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
592 (let ((seconds 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
593 (minutes 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
594 (hours 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
595 (days 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
596 (months 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
597 (years 0)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
598 (cond |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
599 ((match-beginning 2) ;days only |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
600 (setq days (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
601 (match-beginning 3) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
602 (match-end 3)))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
603 (when duration-correction |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
604 (setq days (1- days)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
605 ((match-beginning 4) ;days and time |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
606 (if (match-beginning 5) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
607 (setq days (* 7 (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
608 (match-beginning 6) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
609 (match-end 6)))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
610 (if (match-beginning 7) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
611 (setq hours (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
612 (match-beginning 8) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
613 (match-end 8))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
614 (if (match-beginning 9) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
615 (setq minutes (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
616 (match-beginning 10) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
617 (match-end 10))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
618 (if (match-beginning 11) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
619 (setq seconds (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
620 (match-beginning 12) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
621 (match-end 12)))))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
622 ((match-beginning 13) ;weeks only |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
623 (setq days (* 7 (read (substring isodurationstring |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
624 (match-beginning 14) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
625 (match-end 14))))))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
626 (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
|
627 ;; isodatetimestring == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
628 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
629 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
630 (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
|
631 "Add TIME1 to TIME2. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
632 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
|
633 valid (year > 1900 or something)." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
634 ;; FIXME: does this function exist already? |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
635 (decode-time (encode-time |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
636 (+ (nth 0 time1) (nth 0 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
637 (+ (nth 1 time1) (nth 1 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
638 (+ (nth 2 time1) (nth 2 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
639 (+ (nth 3 time1) (nth 3 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
640 (+ (nth 4 time1) (nth 4 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
641 (+ (nth 5 time1) (nth 5 time2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
642 nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
643 nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
644 ;;(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
|
645 ))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
646 |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
647 (defun icalendar--datetime-to-american-date (datetime &optional separator) |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
648 "Convert the decoded DATETIME to American-style format. |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
649 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
|
650 day, and year. If nil a blank character is used as separator. |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
651 American format: \"month day year\"." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
652 (if datetime |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
653 (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
|
654 (or separator " ") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
655 (nth 3 datetime) ;day |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
656 (or separator " ") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
657 (nth 5 datetime)) ;year |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
658 ;; datetime == nil |
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 |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
661 (define-obsolete-function-alias 'icalendar--datetime-to-noneuropean-date |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
662 'icalendar--datetime-to-american-date "icalendar 0.19") |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
663 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
664 (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
|
665 "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
|
666 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
|
667 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
|
668 European format: (day month year). |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
669 FIXME" |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
670 (if datetime |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
671 (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
|
672 (or separator " ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
673 (nth 4 datetime) ;month |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
674 (or separator " ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
675 (nth 5 datetime)) ;year |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
676 ;; datetime == nil |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
677 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
678 |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
679 (defun icalendar--datetime-to-iso-date (datetime &optional separator) |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
680 "Convert the decoded DATETIME to ISO format. |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
681 Optional argument SEPARATOR gives the separator between month, |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
682 day, and year. If nil a blank character is used as separator. |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
683 ISO format: (year month day)." |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
684 (if datetime |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
685 (format "%d%s%d%s%d" (nth 5 datetime) ;year |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
686 (or separator " ") |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
687 (nth 4 datetime) ;month |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
688 (or separator " ") |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
689 (nth 3 datetime)) ;day |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
690 ;; datetime == nil |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
691 nil)) |
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
692 |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
693 (defun icalendar--date-style () |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
694 "Return current calendar date style. |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
695 Convenience function to handle transition from old |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
696 `european-calendar-style' to new `calendar-date-style'." |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
697 (if (boundp 'calendar-date-style) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
698 calendar-date-style |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
699 (if (with-no-warnings european-calendar-style) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
700 'european |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
701 'american))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
702 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
703 (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
|
704 "Convert the decoded DATETIME to diary format. |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
705 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
|
706 day, and year. If nil a blank character is used as separator. |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
707 Call icalendar--datetime-to-*-date according to the current |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
708 calendar date style." |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
709 (funcall (intern-soft (format "icalendar--datetime-to-%s-date" |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
710 (icalendar--date-style))) |
93376
bc4871e6df44
(icalendar--datetime-to-american-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92987
diff
changeset
|
711 datetime separator)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
712 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
713 (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
|
714 "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
|
715 Note that this silently ignores seconds." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
716 (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
|
717 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
718 (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
|
719 "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
|
720 (catch 'found |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
721 (let ((num 1) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
722 (m (downcase monthname))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
723 (mapc (lambda (month) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
724 (let ((mm (downcase month))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
725 (if (or (string-equal mm m) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
726 (string-equal (substring mm 0 3) m)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
727 (throw 'found num)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
728 (setq num (1+ num)))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
729 calendar-month-name-array)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
730 ;; Error: |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
731 -1)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
732 |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
733 (defun icalendar--get-weekday-number (abbrevweekday) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
734 "Return the number for the ABBREVWEEKDAY." |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
735 (if abbrevweekday |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
736 (catch 'found |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
737 (let ((num 0) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
738 (aw (downcase abbrevweekday))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
739 (mapc (lambda (day) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
740 (let ((d (downcase day))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
741 (if (string-equal d aw) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
742 (throw 'found num)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
743 (setq num (1+ num)))) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
744 icalendar--weekday-array))) |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
745 ;; Error: |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
746 -1)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
747 |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
748 (defun icalendar--get-weekday-numbers (abbrevweekdays) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
749 "Return the list of numbers for the comma-separated ABBREVWEEKDAYS." |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
750 (when abbrevweekdays |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
751 (let* ((num -1) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
752 (weekday-alist (mapcar (lambda (day) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
753 (progn |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
754 (setq num (1+ num)) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
755 (cons (downcase day) num))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
756 icalendar--weekday-array))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
757 (delq nil |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
758 (mapcar (lambda (abbrevday) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
759 (cdr (assoc abbrevday weekday-alist))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
760 (split-string (downcase abbrevweekdays) ",")))))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
761 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
762 (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
|
763 "Return the abbreviated WEEKDAY." |
57652
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
764 (catch 'found |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
765 (let ((num 0) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
766 (w (downcase weekday))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
767 (mapc (lambda (day) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
768 (let ((d (downcase day))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
769 (if (or (string-equal d w) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
770 (string-equal (substring d 0 3) w)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
771 (throw 'found (aref icalendar--weekday-array num))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
772 (setq num (1+ num)))) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
773 calendar-day-name-array)) |
1d0ad14ff912
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57586
diff
changeset
|
774 ;; Error: |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
775 nil)) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
776 |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
777 (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
|
778 "Convert DATE to iso-style date. |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
779 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
|
780 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
|
781 (let ((mdy (calendar-gregorian-from-absolute |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
782 (+ (calendar-absolute-from-gregorian date) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
783 (or day-shift 0))))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
784 (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
|
785 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
786 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
787 (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
|
788 "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
|
789 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
|
790 -- DAY-SHIFT must be either nil or an integer. This function |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
791 tries to figure the date style from DATESTRING itself. If that |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
792 is not possible it uses the current calendar date style." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
793 (let ((day -1) month year) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
794 (save-match-data |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
795 (cond ( ;; iso-style numeric date |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
796 (string-match (concat "\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
797 "\\([0-9]\\{4\\}\\)[ \t/]\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
798 "0?\\([1-9][0-9]?\\)[ \t/]\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
799 "0?\\([1-9][0-9]?\\)") |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
800 datestring) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
801 (setq year (read (substring datestring (match-beginning 1) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
802 (match-end 1)))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
803 (setq month (read (substring datestring (match-beginning 2) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
804 (match-end 2)))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
805 (setq day (read (substring datestring (match-beginning 3) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
806 (match-end 3))))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
807 ( ;; non-iso numeric date -- must rely on configured |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
808 ;; calendar style |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
809 (string-match (concat "\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
810 "0?\\([1-9][0-9]?\\)[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
811 "0?\\([1-9][0-9]?\\),?[ \t/]\\s-*" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
812 "\\([0-9]\\{4\\}\\)") |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
813 datestring) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
814 (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
|
815 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
816 (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
|
817 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
818 (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
|
819 (match-end 3)))) |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
820 (if (eq (icalendar--date-style) 'american) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
821 (let ((x month)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
822 (setq month day) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
823 (setq day x)))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
824 ( ;; date contains month names -- iso style |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
825 (string-match (concat "\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
826 "\\([0-9]\\{4\\}\\)[ \t/]\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
827 "\\([A-Za-z][^ ]+\\)[ \t/]\\s-*" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
828 "0?\\([123]?[0-9]\\)") |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
829 datestring) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
830 (setq year (read (substring datestring (match-beginning 1) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
831 (match-end 1)))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
832 (setq month (icalendar--get-month-number |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
833 (substring datestring (match-beginning 2) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
834 (match-end 2)))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
835 (setq day (read (substring datestring (match-beginning 3) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
836 (match-end 3))))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
837 ( ;; date contains month names -- european style |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
838 (string-match (concat "\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
839 "0?\\([123]?[0-9]\\)[ \t/]\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
840 "\\([A-Za-z][^ ]+\\)[ \t/]\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
841 "\\([0-9]\\{4\\}\\)") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
842 datestring) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
843 (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
|
844 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
845 (setq month (icalendar--get-month-number |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
846 (substring datestring (match-beginning 2) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
847 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
848 (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
|
849 (match-end 3))))) |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
850 ( ;; date contains month names -- american style |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
851 (string-match (concat "\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
852 "\\([A-Za-z][^ ]+\\)[ \t/]\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
853 "0?\\([123]?[0-9]\\),?[ \t/]\\s-*" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
854 "\\([0-9]\\{4\\}\\)") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
855 datestring) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
856 (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
|
857 (match-end 2)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
858 (setq month (icalendar--get-month-number |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
859 (substring datestring (match-beginning 1) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
860 (match-end 1)))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
861 (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
|
862 (match-end 3))))) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
863 (t |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
864 nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
865 (if (> day 0) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
866 (let ((mdy (calendar-gregorian-from-absolute |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
867 (+ (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
|
868 year)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
869 (or day-shift 0))))) |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
870 (icalendar--dmsg (format "%04d%02d%02d" (nth 2 mdy) (nth 0 mdy) (nth 1 mdy))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
871 (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
|
872 nil))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
873 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
874 (defun icalendar--diarytime-to-isotime (timestring ampmstring) |
77934
fc20957a3166
(icalendar--diarytime-to-isotime): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
76645
diff
changeset
|
875 "Convert a time like 9:30pm to an iso-conform string like T213000. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
876 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
|
877 would be \"pm\"." |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
878 (if timestring |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
879 (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
|
880 ;; take care of am/pm style |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
881 ;; Be sure *not* to convert 12:00pm - 12:59pm to 2400-2459 |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
882 (if (and ampmstring (string= "pm" ampmstring) (< starttimenum 1200)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
883 (setq starttimenum (+ starttimenum 1200))) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
884 ;; Similar effect with 12:00am - 12:59am (need to convert to 0000-0059) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
885 (if (and ampmstring (string= "am" ampmstring) (>= starttimenum 1200)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
886 (setq starttimenum (- starttimenum 1200))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
887 (format "T%04d00" starttimenum)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
888 nil)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
889 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
890 (defun icalendar--convert-string-for-export (string) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
891 "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
|
892 (icalendar--rris "," "\\\\," string)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
893 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
894 (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
|
895 "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
|
896 (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
897 "\\\\n" "\n " (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
898 "\\\\\"" "\"" (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
899 "\\\\;" ";" (icalendar--rris |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
900 "\\\\," "," string))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
901 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
902 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
903 ;; 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
|
904 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
905 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
906 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
907 (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
|
908 "Export diary file to iCalendar format. |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
909 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
|
910 format. The result is appended to the file ICAL-FILENAME." |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
911 (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
|
912 Finto iCalendar file: ") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
913 (save-current-buffer |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
914 (set-buffer (find-file diary-filename)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
915 (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
|
916 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
917 (defalias 'icalendar-convert-diary-to-ical 'icalendar-export-file) |
104396
e667f4aad5f2
* textmodes/remember.el (remember-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101497
diff
changeset
|
918 (make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file "22.1") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
919 |
99284
b39c4aef1848
icalendar: uid-creation improved
Ulf Jasper <ulf.jasper@web.de>
parents:
95273
diff
changeset
|
920 (defvar icalendar--uid-count 0 |
b39c4aef1848
icalendar: uid-creation improved
Ulf Jasper <ulf.jasper@web.de>
parents:
95273
diff
changeset
|
921 "Auxiliary counter for creating unique ids.") |
b39c4aef1848
icalendar: uid-creation improved
Ulf Jasper <ulf.jasper@web.de>
parents:
95273
diff
changeset
|
922 |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
923 (defun icalendar--create-uid (entry-full contents) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
924 "Construct a unique iCalendar UID for a diary entry. |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
925 ENTRY-FULL is the full diary entry string. CONTENTS is the |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
926 current iCalendar object, as a string. Increase |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
927 `icalendar--uid-count'. Returns the UID string." |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
928 (let ((uid icalendar-uid-format)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
929 |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
930 (setq uid (replace-regexp-in-string |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
931 "%c" |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
932 (format "%d" icalendar--uid-count) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
933 uid t t)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
934 (setq icalendar--uid-count (1+ icalendar--uid-count)) |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
935 (setq uid (replace-regexp-in-string |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
936 "%t" |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
937 (format "%d%d%d" (car (current-time)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
938 (cadr (current-time)) |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
939 (car (cddr (current-time)))) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
940 uid t t)) |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
941 (setq uid (replace-regexp-in-string |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
942 "%h" |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
943 (format "%d" (abs (sxhash entry-full))) uid t t)) |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
944 (setq uid (replace-regexp-in-string |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
945 "%u" (or user-login-name "UNKNOWN_USER") uid t t)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
946 (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
947 (substring contents (match-beginning 1) (match-end 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
948 "DTSTART"))) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
949 (setq uid (replace-regexp-in-string "%s" dtstart uid t t))) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
950 |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
951 ;; Return the UID string |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
952 uid)) |
99284
b39c4aef1848
icalendar: uid-creation improved
Ulf Jasper <ulf.jasper@web.de>
parents:
95273
diff
changeset
|
953 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
954 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
955 (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
|
956 "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
|
957 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
|
958 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
|
959 ICAL-FILENAME. |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
960 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
|
961 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
|
962 written into the buffer `*icalendar-errors*'." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
963 (interactive "r |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
964 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
|
965 (let ((result "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
966 (start 0) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
967 (entry-main "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
968 (entry-rest "") |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
969 (entry-full "") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
970 (header "") |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
971 (contents-n-summary) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
972 (contents) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
973 (found-error nil) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
974 (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
975 "?")) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
976 (other-elements nil)) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
977 ;; prepare buffer with error messages |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
978 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
979 (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
|
980 (erase-buffer)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
981 |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
982 ;; here we go |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
983 (save-excursion |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
984 (goto-char min) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
985 (while (re-search-forward |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
986 ;; possibly ignore hidden entries beginning with "&" |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
987 (if icalendar-export-hidden-diary-entries |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
988 "^\\([^ \t\n#].+\\)\\(\\(\n[ \t].*\\)*\\)" |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
989 "^\\([^ \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
|
990 (setq entry-main (match-string 1)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
991 (if (match-beginning 2) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
992 (setq entry-rest (match-string 2)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
993 (setq entry-rest "")) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
994 (setq entry-full (concat entry-main entry-rest)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
995 |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
996 (condition-case error-val |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
997 (progn |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
998 (setq contents-n-summary |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
999 (icalendar--convert-to-ical nonmarker entry-main)) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1000 (setq other-elements (icalendar--parse-summary-and-rest |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1001 entry-full)) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1002 (setq contents (concat (car contents-n-summary) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1003 "\nSUMMARY:" (cadr contents-n-summary))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1004 (let ((cla (cdr (assoc 'cla other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1005 (des (cdr (assoc 'des other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1006 (loc (cdr (assoc 'loc other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1007 (org (cdr (assoc 'org other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1008 (sta (cdr (assoc 'sta other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1009 (sum (cdr (assoc 'sum other-elements))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1010 (url (cdr (assoc 'url other-elements)))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1011 (if cla |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1012 (setq contents (concat contents "\nCLASS:" cla))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1013 (if des |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1014 (setq contents (concat contents "\nDESCRIPTION:" des))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1015 (if loc |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1016 (setq contents (concat contents "\nLOCATION:" loc))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1017 (if org |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1018 (setq contents (concat contents "\nORGANIZER:" org))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1019 (if sta |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1020 (setq contents (concat contents "\nSTATUS:" sta))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1021 ;;(if sum |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1022 ;; (setq contents (concat contents "\nSUMMARY:" sum))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1023 (if url |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1024 (setq contents (concat contents "\nURL:" url)))) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1025 |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
1026 (setq header (concat "\nBEGIN:VEVENT\nUID:" |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1027 (icalendar--create-uid entry-full contents))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1028 (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
|
1029 ;; handle errors |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1030 (error |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1031 (setq found-error t) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1032 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1033 (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
|
1034 (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
|
1035 (count-lines (point-min) (point)) |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1036 error-val |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1037 entry-main)))))) |
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1038 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1039 ;; 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
|
1040 (save-current-buffer |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
1041 (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
|
1042 (set-buffer (find-file ical-filename)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1043 (goto-char (point-max)) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1044 (insert "BEGIN:VCALENDAR") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1045 (insert "\nPRODID:-//Emacs//NONSGML icalendar.el//EN") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1046 (insert "\nVERSION:2.0") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1047 (insert result) |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1048 (insert "\nEND:VCALENDAR\n") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1049 ;; save the diary file |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1050 (save-buffer) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1051 (unless found-error |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1052 (bury-buffer))))) |
57862
60f1782b5d8d
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57652
diff
changeset
|
1053 found-error)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1054 |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1055 (defun icalendar--convert-to-ical (nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1056 "Convert a diary entry to icalendar format. |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1057 NONMARKER is a regular expression matching the start of non-marking |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1058 entries. ENTRY-MAIN is the first line of the diary entry." |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1059 (or |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1060 ;; anniversaries -- %%(diary-anniversary ...) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1061 (icalendar--convert-anniversary-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1062 ;; cyclic events -- %%(diary-cyclic ...) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1063 (icalendar--convert-cyclic-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1064 ;; diary-date -- %%(diary-date ...) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1065 (icalendar--convert-date-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1066 ;; float events -- %%(diary-float ...) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1067 (icalendar--convert-float-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1068 ;; block events -- %%(diary-block ...) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1069 (icalendar--convert-block-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1070 ;; other sexp diary entries |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1071 (icalendar--convert-sexp-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1072 ;; weekly by day -- Monday 8:30 Team meeting |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1073 (icalendar--convert-weekly-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1074 ;; yearly by day -- 1 May Tag der Arbeit |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1075 (icalendar--convert-yearly-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1076 ;; "ordinary" events, start and end time given |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1077 ;; 1 Feb 2003 blah |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1078 (icalendar--convert-ordinary-to-ical nonmarker entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1079 ;; everything else |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1080 ;; Oops! what's that? |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1081 (error "Could not parse entry"))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1082 |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1083 (defun icalendar--parse-summary-and-rest (summary-and-rest) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1084 "Parse SUMMARY-AND-REST from a diary to fill iCalendar properties. |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1085 Returns an alist." |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1086 (save-match-data |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1087 (if (functionp icalendar-import-format) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1088 ;; can't do anything |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1089 nil |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1090 ;; split summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1091 (let* ((s icalendar-import-format) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1092 (p-cla (or (string-match "%c" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1093 (p-des (or (string-match "%d" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1094 (p-loc (or (string-match "%l" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1095 (p-org (or (string-match "%o" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1096 (p-sum (or (string-match "%s" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1097 (p-sta (or (string-match "%t" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1098 (p-url (or (string-match "%u" icalendar-import-format) -1)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1099 (p-list (sort (list p-cla p-des p-loc p-org p-sta p-sum p-url) '<)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1100 (ct 0) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1101 pos-cla pos-des pos-loc pos-org pos-sta pos-sum pos-url) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1102 (dotimes (i (length p-list)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1103 ;; Use 'ct' to keep track of current position in list |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1104 (cond ((and (>= p-cla 0) (= (nth i p-list) p-cla)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1105 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1106 (setq pos-cla (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1107 ((and (>= p-des 0) (= (nth i p-list) p-des)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1108 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1109 (setq pos-des (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1110 ((and (>= p-loc 0) (= (nth i p-list) p-loc)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1111 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1112 (setq pos-loc (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1113 ((and (>= p-org 0) (= (nth i p-list) p-org)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1114 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1115 (setq pos-org (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1116 ((and (>= p-sta 0) (= (nth i p-list) p-sta)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1117 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1118 (setq pos-sta (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1119 ((and (>= p-sum 0) (= (nth i p-list) p-sum)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1120 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1121 (setq pos-sum (* 2 ct))) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1122 ((and (>= p-url 0) (= (nth i p-list) p-url)) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1123 (setq ct (+ ct 1)) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1124 (setq pos-url (* 2 ct)))) ) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1125 (mapc (lambda (ij) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1126 (setq s (icalendar--rris (car ij) (cadr ij) s t t))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1127 (list |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1128 ;; summary must be first! because of %s |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1129 (list "%s" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1130 (concat "\\(" icalendar-import-format-summary "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1131 (list "%c" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1132 (concat "\\(" icalendar-import-format-class "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1133 (list "%d" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1134 (concat "\\(" icalendar-import-format-description "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1135 (list "%l" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1136 (concat "\\(" icalendar-import-format-location "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1137 (list "%o" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1138 (concat "\\(" icalendar-import-format-organizer "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1139 (list "%t" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1140 (concat "\\(" icalendar-import-format-status "\\)??")) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1141 (list "%u" |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1142 (concat "\\(" icalendar-import-format-url "\\)??")))) |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1143 ;; Need the \' regexp in order to detect multi-line items |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
1144 (setq s (concat "\\`" |
101457
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1145 (icalendar--rris "%s" "\\(.*?\\)" s nil t) |
feab64c71ad0
icalendar: uid-format, bug fixes.
Ulf Jasper <ulf.jasper@web.de>
parents:
100908
diff
changeset
|
1146 "\\'")) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1147 (if (string-match s summary-and-rest) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1148 (let (cla des loc org sta sum url) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1149 (if (and pos-sum (match-beginning pos-sum)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1150 (setq sum (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1151 (match-beginning pos-sum) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1152 (match-end pos-sum)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1153 (if (and pos-cla (match-beginning pos-cla)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1154 (setq cla (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1155 (match-beginning pos-cla) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1156 (match-end pos-cla)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1157 (if (and pos-des (match-beginning pos-des)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1158 (setq des (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1159 (match-beginning pos-des) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1160 (match-end pos-des)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1161 (if (and pos-loc (match-beginning pos-loc)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1162 (setq loc (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1163 (match-beginning pos-loc) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1164 (match-end pos-loc)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1165 (if (and pos-org (match-beginning pos-org)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1166 (setq org (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1167 (match-beginning pos-org) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1168 (match-end pos-org)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1169 (if (and pos-sta (match-beginning pos-sta)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1170 (setq sta (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1171 (match-beginning pos-sta) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1172 (match-end pos-sta)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1173 (if (and pos-url (match-beginning pos-url)) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1174 (setq url (substring summary-and-rest |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1175 (match-beginning pos-url) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1176 (match-end pos-url)))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1177 (list (if cla (cons 'cla cla) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1178 (if des (cons 'des des) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1179 (if loc (cons 'loc loc) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1180 (if org (cons 'org org) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1181 (if sta (cons 'sta sta) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1182 ;;(if sum (cons 'sum sum) nil) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1183 (if url (cons 'url url) nil)))))))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1184 |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1185 ;; subroutines for icalendar-export-region |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1186 (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
|
1187 "Convert \"ordinary\" diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1188 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
|
1189 entries. ENTRY-MAIN is the first line of the diary entry." |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1190 (if (string-match |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1191 (concat nonmarker |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1192 "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1193 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" ; start time |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1194 "\\(" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1195 "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" ; end time |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1196 "\\)?" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1197 "\\s-*\\(.*?\\) ?$") |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1198 entry-main) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1199 (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
|
1200 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1201 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1202 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1203 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1204 datetime 1)) |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1205 (endisostring1) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1206 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1207 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1208 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1209 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1210 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1211 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1212 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1213 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1214 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1215 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1216 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1217 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1218 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1219 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1220 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1221 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1222 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1223 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1224 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1225 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1226 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1227 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1228 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1229 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1230 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1231 (icalendar--dmsg "ordinary %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1232 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1233 (unless startisostring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1234 (error "Could not parse date")) |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1235 |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1236 ;; If only start-date is specified, then end-date is next day, |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1237 ;; otherwise it is same day. |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1238 (setq endisostring1 (if starttimestring |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1239 startisostring |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1240 endisostring)) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1241 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1242 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1243 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1244 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1245 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1246 starttimestring)))) |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1247 (if (< time 230000) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1248 ;; Case: ends on same day |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1249 (setq endtimestring (format "T%06d" |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1250 (+ 10000 time))) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1251 ;; Case: ends on next day |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1252 (setq endtimestring (format "T%06d" |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1253 (- time 230000))) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1254 (setq endisostring1 endisostring)) ))) |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1255 |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1256 (list (concat "\nDTSTART;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1257 (if starttimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1258 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1259 startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1260 (or starttimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1261 "\nDTEND;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1262 (if endtimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1263 "VALUE=DATE:") |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1264 endisostring1 |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1265 (or endtimestring "")) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1266 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1267 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1268 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1269 |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1270 (defun icalendar-first-weekday-of-year (abbrevweekday year) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1271 "Find the first ABBREVWEEKDAY in a given YEAR. |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1272 Returns day number." |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1273 (let* ((day-of-week-jan01 (calendar-day-of-week (list 1 1 year))) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1274 (result (+ 1 |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1275 (- (icalendar--get-weekday-number abbrevweekday) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1276 day-of-week-jan01)))) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1277 (cond ((<= result 0) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1278 (setq result (+ result 7))) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1279 ((> result 7) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1280 (setq result (- result 7)))) |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1281 result)) |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1282 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1283 (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
|
1284 "Convert weekly diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1285 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
|
1286 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
|
1287 (if (and (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1288 "\\([a-z]+\\)\\s-+" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1289 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1290 "\\([ap]m\\)?" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1291 "\\(-" |
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1292 "\\([0-9][0-9]?:[0-9][0-9]\\)" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1293 "\\([ap]m\\)?\\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1294 "\\)?" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1295 "\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1296 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1297 (icalendar--get-weekday-abbrev |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1298 (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1299 (match-end 1)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1300 (let* ((day (icalendar--get-weekday-abbrev |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1301 (substring entry-main (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1302 (match-end 1)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1303 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1304 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1305 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1306 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1307 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1308 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1309 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1310 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1311 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1312 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1313 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1314 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1315 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1316 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1317 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1318 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1319 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1320 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1321 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1322 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1323 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1324 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1325 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1326 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1327 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1328 (icalendar--dmsg "weekly %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1329 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1330 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1331 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1332 (let ((time (read |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1333 (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1334 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1335 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1336 (+ 10000 time)))))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1337 (list (concat "\nDTSTART;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1338 (if starttimestring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1339 "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1340 "VALUE=DATE:") |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1341 ;; Find the first requested weekday of the |
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1342 ;; start year |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1343 (funcall 'format "%04d%02d%02d" |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1344 icalendar-recurring-start-year 1 |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1345 (icalendar-first-weekday-of-year |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1346 day icalendar-recurring-start-year)) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1347 (or starttimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1348 "\nDTEND;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1349 (if endtimestring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1350 "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1351 "VALUE=DATE:") |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1352 (funcall 'format "%04d%02d%02d" |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1353 ;; end is non-inclusive! |
92987
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1354 icalendar-recurring-start-year 1 |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1355 (+ (icalendar-first-weekday-of-year |
fe7a1170342d
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
92986
diff
changeset
|
1356 day icalendar-recurring-start-year) |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1357 (if endtimestring 0 1))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1358 (or endtimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1359 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1360 day) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1361 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1362 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1363 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1364 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1365 (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
|
1366 "Convert yearly diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1367 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
|
1368 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
|
1369 (if (string-match (concat nonmarker |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1370 (if (eq (icalendar--date-style) 'european) |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1371 "\\([0-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+" |
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1372 "\\([a-z]+\\)\\s-+\\([0-9]+[0-9]?\\)\\s-+") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1373 "\\*?\\s-*" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1374 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1375 "\\(" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1376 "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1377 "\\)?" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1378 "\\s-*\\([^0-9]+.*?\\) ?$" ; must not match years |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1379 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1380 entry-main) |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1381 (let* ((daypos (if (eq (icalendar--date-style) 'european) 1 2)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
1382 (monpos (if (eq (icalendar--date-style) 'european) 2 1)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1383 (day (read (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1384 (match-beginning daypos) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1385 (match-end daypos)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1386 (month (icalendar--get-month-number |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1387 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1388 (match-beginning monpos) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1389 (match-end monpos)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1390 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1391 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1392 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1393 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1394 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1395 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1396 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1397 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1398 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1399 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1400 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1401 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1402 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1403 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1404 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1405 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1406 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1407 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1408 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1409 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1410 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1411 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1412 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1413 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1414 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1415 (icalendar--dmsg "yearly %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1416 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1417 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1418 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1419 (let ((time (read |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1420 (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1421 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1422 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1423 (+ 10000 time)))))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1424 (list (concat "\nDTSTART;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1425 (if starttimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1426 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1427 (format "1900%02d%02d" month day) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1428 (or starttimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1429 "\nDTEND;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1430 (if endtimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1431 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1432 ;; end is not included! shift by one day |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1433 (icalendar--date-to-isodate |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1434 (list month day 1900) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1435 (if endtimestring 0 1)) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1436 (or endtimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1437 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=" |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1438 (format "%d" month) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1439 ";BYMONTHDAY=" |
92986
589bafdc6c3e
Craig Markwardt <Craig.Markwardt at nasa.gov>
Glenn Morris <rgm@gnu.org>
parents:
88008
diff
changeset
|
1440 (format "%d" day)) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1441 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1442 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1443 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1444 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1445 (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
|
1446 "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
|
1447 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1448 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1449 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1450 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
|
1451 entries. ENTRY-MAIN is the first line of the diary entry." |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1452 (cond ((string-match (concat nonmarker |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1453 "%%(and \\(([^)]+)\\))\\(\\s-*.*?\\) ?$") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1454 entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1455 ;; simple sexp entry as generated by icalendar.el: strip off the |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1456 ;; unnecessary (and) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1457 (icalendar--dmsg "diary-sexp from icalendar.el %s" entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1458 (icalendar--convert-to-ical |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1459 nonmarker |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1460 (concat "%%" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1461 (substring entry-main (match-beginning 1) (match-end 1)) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1462 (substring entry-main (match-beginning 2) (match-end 2))))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1463 ((string-match (concat nonmarker |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1464 "%%([^)]+)\\s-*.*") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1465 entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1466 (icalendar--dmsg "diary-sexp %s" entry-main) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1467 (error "Sexp-entries are not supported yet")) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1468 (t |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1469 ;; no match |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1470 nil))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1471 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1472 (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
|
1473 "Convert block diary entry to icalendar format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1474 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
|
1475 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
|
1476 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1477 "%%(diary-block \\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1478 " +\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1479 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1480 "\\(" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1481 "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1482 "\\)?" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1483 "\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1484 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1485 (let* ((startstring (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1486 (match-beginning 1) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1487 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1488 (endstring (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1489 (match-beginning 2) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1490 (match-end 2))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1491 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1492 startstring)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1493 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1494 endstring)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1495 (endisostring+1 (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1496 endstring 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1497 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1498 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1499 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1500 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1501 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1502 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1503 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1504 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1505 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1506 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1507 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1508 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1509 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1510 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1511 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1512 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1513 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1514 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1515 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1516 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1517 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1518 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1519 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1520 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1521 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1522 (icalendar--dmsg "diary-block %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1523 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1524 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1525 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1526 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1527 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1528 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1529 (+ 10000 time)))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1530 (if starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1531 ;; with time -> write rrule |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1532 (list (concat "\nDTSTART;VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1533 startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1534 starttimestring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1535 "\nDTEND;VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1536 startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1537 endtimestring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1538 "\nRRULE:FREQ=DAILY;INTERVAL=1;UNTIL=" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1539 endisostring) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1540 summary) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1541 ;; no time -> write long event |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1542 (list (concat "\nDTSTART;VALUE=DATE:" startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1543 "\nDTEND;VALUE=DATE:" endisostring+1) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1544 summary))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1545 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1546 nil)) |
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 (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
|
1549 "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
|
1550 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1551 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1552 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1553 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
|
1554 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
|
1555 (if (string-match (concat nonmarker |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1556 "%%(diary-float \\([^)]+\\))\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1557 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1558 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1559 (icalendar--dmsg "diary-float %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1560 (error "`diary-float' is not supported yet")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1561 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1562 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1563 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1564 (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
|
1565 "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
|
1566 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1567 FIXME! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1568 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1569 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
|
1570 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
|
1571 (if (string-match (concat nonmarker |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1572 "%%(diary-date \\([^)]+\\))\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1573 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1574 (progn |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1575 (icalendar--dmsg "diary-date %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1576 (error "`diary-date' is not supported yet")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1577 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1578 nil)) |
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 (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
|
1581 "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
|
1582 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
|
1583 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
|
1584 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1585 "%%(diary-cyclic \\([^ ]+\\) +" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1586 "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1587 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1588 "\\(" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1589 "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1590 "\\)?" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1591 "\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1592 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1593 (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
|
1594 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1595 (datetime (substring entry-main (match-beginning 2) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1596 (match-end 2))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1597 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1598 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1599 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1600 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1601 (endisostring+1 (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1602 datetime 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1603 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1604 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1605 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1606 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1607 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1608 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1609 (if (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1610 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1611 (match-beginning 5) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1612 (match-end 5)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1613 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1614 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1615 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1616 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1617 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1618 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1619 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1620 (if (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1621 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1622 (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1623 (match-end 8)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1624 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1625 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1626 (substring entry-main (match-beginning 9) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1627 (match-end 9))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1628 (icalendar--dmsg "diary-cyclic %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1629 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1630 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1631 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1632 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1633 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1634 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1635 (+ 10000 time)))))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1636 (list (concat "\nDTSTART;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1637 (if starttimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1638 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1639 startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1640 (or starttimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1641 "\nDTEND;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1642 (if endtimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1643 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1644 (if endtimestring endisostring endisostring+1) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1645 (or endtimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1646 "\nRRULE:FREQ=DAILY;INTERVAL=" frequency |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1647 ;; strange: korganizer does not expect |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1648 ;; BYSOMETHING here... |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1649 ) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1650 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1651 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1652 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1653 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1654 (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
|
1655 "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
|
1656 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
|
1657 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
|
1658 (if (string-match (concat nonmarker |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1659 "%%(diary-anniversary \\([^)]+\\))\\s-*" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1660 "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1661 "\\(" |
107199
8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
106815
diff
changeset
|
1662 "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1663 "\\)?" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1664 "\\s-*\\(.*?\\) ?$") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1665 entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1666 (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
|
1667 (match-end 1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1668 (startisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1669 datetime)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1670 (endisostring (icalendar--datestring-to-isodate |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1671 datetime 1)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1672 (starttimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1673 (if (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1674 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1675 (match-beginning 3) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1676 (match-end 3)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1677 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1678 (if (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1679 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1680 (match-beginning 4) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1681 (match-end 4)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1682 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1683 (endtimestring (icalendar--diarytime-to-isotime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1684 (if (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1685 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1686 (match-beginning 6) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1687 (match-end 6)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1688 nil) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1689 (if (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1690 (substring entry-main |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1691 (match-beginning 7) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1692 (match-end 7)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1693 nil))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1694 (summary (icalendar--convert-string-for-export |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1695 (substring entry-main (match-beginning 8) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1696 (match-end 8))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1697 (icalendar--dmsg "diary-anniversary %s" entry-main) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1698 (when starttimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1699 (unless endtimestring |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1700 (let ((time |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1701 (read (icalendar--rris "^T0?" "" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1702 starttimestring)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1703 (setq endtimestring (format "T%06d" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1704 (+ 10000 time)))))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1705 (list (concat "\nDTSTART;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1706 (if starttimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1707 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1708 startisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1709 (or starttimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1710 "\nDTEND;" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1711 (if endtimestring "VALUE=DATE-TIME:" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1712 "VALUE=DATE:") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1713 endisostring |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1714 (or endtimestring "") |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1715 "\nRRULE:FREQ=YEARLY;INTERVAL=1" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1716 ;; the following is redundant, |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1717 ;; but korganizer seems to expect this... ;( |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1718 ;; and evolution doesn't understand it... :( |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1719 ;; so... who is wrong?! |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1720 ";BYMONTH=" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1721 (substring startisostring 4 6) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1722 ";BYMONTHDAY=" |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1723 (substring startisostring 6 8)) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1724 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1725 ;; no match |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1726 nil)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1727 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1728 ;; ====================================================================== |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1729 ;; 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
|
1730 ;; ====================================================================== |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1731 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
1732 ;;;###autoload |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1733 (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
|
1734 &optional non-marking) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1735 "Import an 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
|
1736 Argument ICAL-FILENAME output iCalendar file. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1737 Argument DIARY-FILENAME input `diary-file'. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1738 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
|
1739 non-marking or not." |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1740 (interactive "fImport iCalendar data from file: |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1741 Finto diary file: |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1742 p") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1743 ;; clean up the diary file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1744 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1745 ;; 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
|
1746 (set-buffer (find-file ical-filename)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1747 (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
|
1748 |
60382
87759c244379
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60235
diff
changeset
|
1749 ;;;###autoload |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1750 (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
|
1751 non-marking) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1752 "Extract iCalendar events from current buffer. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1753 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1754 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
|
1755 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
|
1756 DIARY-FILE. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1757 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1758 It will ask for each appointment whether to add it to the diary |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1759 unless DO-NOT-ASK is non-nil. When called interactively, |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1760 DO-NOT-ASK is nil, so that you are asked for each event. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1761 |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1762 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
|
1763 non-marking. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1764 |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1765 Return code t means that importing worked well, return code nil |
75141
e4abbe7f7417
(icalendar-import-buffer): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
74673
diff
changeset
|
1766 means that an error has occurred. Error messages will be in the |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1767 buffer `*icalendar-errors*'." |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1768 (interactive) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1769 (save-current-buffer |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1770 ;; prepare ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1771 (message "Preparing icalendar...") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1772 (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
|
1773 (goto-char (point-min)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1774 (message "Preparing icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1775 (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
|
1776 (let (ical-contents ical-errors) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1777 ;; read ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1778 (message "Reading icalendar...") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1779 (beginning-of-line) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1780 (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
|
1781 (message "Reading icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1782 ;; convert ical |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1783 (message "Converting icalendar...") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1784 (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
|
1785 ical-contents |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1786 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
|
1787 (when diary-file |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1788 ;; 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
|
1789 (let ((b (find-buffer-visiting diary-file))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1790 (when b |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1791 (save-current-buffer |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1792 (set-buffer b) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1793 (save-buffer))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1794 (message "Converting icalendar...done") |
75141
e4abbe7f7417
(icalendar-import-buffer): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
74673
diff
changeset
|
1795 ;; return t if no error occurred |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1796 (not ical-errors)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1797 (message |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1798 "Current buffer does not contain icalendar contents!") |
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1799 ;; 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
|
1800 nil))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1801 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1802 (defalias 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer) |
104396
e667f4aad5f2
* textmodes/remember.el (remember-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101497
diff
changeset
|
1803 (make-obsolete 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer "22.1") |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1804 |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1805 (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
|
1806 "Create a string representation of an iCalendar EVENT." |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1807 (if (functionp icalendar-import-format) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1808 (funcall icalendar-import-format event) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1809 (let ((string icalendar-import-format) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1810 (conversion-list |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1811 '(("%c" CLASS icalendar-import-format-class) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1812 ("%d" DESCRIPTION icalendar-import-format-description) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1813 ("%l" LOCATION icalendar-import-format-location) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1814 ("%o" ORGANIZER icalendar-import-format-organizer) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1815 ("%s" SUMMARY icalendar-import-format-summary) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1816 ("%t" STATUS icalendar-import-format-status) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1817 ("%u" URL icalendar-import-format-url)))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1818 ;; convert the specifiers in the format string |
84893
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1819 (mapc (lambda (i) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1820 (let* ((spec (car i)) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1821 (prop (cadr i)) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1822 (format (car (cddr i))) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1823 (contents (icalendar--get-event-property event prop)) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1824 (formatted-contents "")) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1825 (when (and contents (> (length contents) 0)) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1826 (setq formatted-contents |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1827 (icalendar--rris "%s" |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1828 (icalendar--convert-string-for-import |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1829 contents) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1830 (symbol-value format) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1831 t t))) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1832 (setq string (icalendar--rris spec |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1833 formatted-contents |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1834 string |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1835 t t)))) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1836 conversion-list) |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
1837 string))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1838 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1839 (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
|
1840 &optional do-not-ask |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1841 non-marking) |
74673
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
1842 "Convert iCalendar data to an Emacs diary file. |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1843 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
|
1844 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
|
1845 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
|
1846 events are created as non-marking. |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1847 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
|
1848 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
|
1849 written into the buffer `*icalendar-errors*'." |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1850 (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
|
1851 (error-string "") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1852 (event-ok t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1853 (found-error nil) |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1854 (zone-map (icalendar--convert-all-timezones ical-list)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1855 e diary-string) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1856 ;; step through all events/appointments |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1857 (while ev |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1858 (setq e (car ev)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1859 (setq ev (cdr ev)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1860 (setq event-ok nil) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1861 (condition-case error-val |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1862 (let* ((dtstart (icalendar--get-event-property e 'DTSTART)) |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1863 (dtstart-zone (icalendar--find-time-zone |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1864 (icalendar--get-event-property-attributes |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1865 e 'DTSTART) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1866 zone-map)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1867 (dtstart-dec (icalendar--decode-isodatetime dtstart nil |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1868 dtstart-zone)) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1869 (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
|
1870 dtstart-dec)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1871 (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
|
1872 (dtend (icalendar--get-event-property e 'DTEND)) |
87780
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1873 (dtend-zone (icalendar--find-time-zone |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1874 (icalendar--get-event-property-attributes |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1875 e 'DTEND) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1876 zone-map)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1877 (dtend-dec (icalendar--decode-isodatetime dtend |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1878 nil dtend-zone)) |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1879 (dtend-1-dec (icalendar--decode-isodatetime dtend -1 |
cdfa9a659163
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
1880 dtend-zone)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1881 end-d |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1882 end-1-d |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1883 end-t |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1884 (summary (icalendar--convert-string-for-import |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1885 (or (icalendar--get-event-property e 'SUMMARY) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1886 "No summary"))) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1887 (rrule (icalendar--get-event-property e 'RRULE)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1888 (rdate (icalendar--get-event-property e 'RDATE)) |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1889 (duration (icalendar--get-event-property e 'DURATION))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1890 (icalendar--dmsg "%s: `%s'" start-d summary) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1891 ;; check whether start-time is missing |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1892 (if (and dtstart |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1893 (string= |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1894 (cadr (icalendar--get-event-property-attributes |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1895 e 'DTSTART)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1896 "DATE")) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1897 (setq start-t nil)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1898 (when duration |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1899 (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
|
1900 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1901 (icalendar--decode-isoduration duration))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1902 (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
|
1903 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1904 (icalendar--decode-isoduration duration |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1905 t)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1906 (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
|
1907 (message "Inconsistent endtime and duration for %s" |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1908 summary)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1909 (setq dtend-dec dtend-dec-d) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1910 (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
|
1911 (setq end-d (if dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1912 (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
|
1913 start-d)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1914 (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
|
1915 (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
|
1916 start-d)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1917 (setq end-t (if (and |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1918 dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1919 (not (string= |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1920 (cadr |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1921 (icalendar--get-event-property-attributes |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1922 e 'DTEND)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1923 "DATE"))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1924 (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
|
1925 start-t)) |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1926 (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
|
1927 (cond |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1928 ;; recurring event |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1929 (rrule |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1930 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1931 (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
|
1932 end-t)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1933 (setq event-ok t)) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1934 (rdate |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1935 (icalendar--dmsg "rdate event") |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1936 (setq diary-string "") |
84893
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1937 (mapc (lambda (datestring) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1938 (setq diary-string |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1939 (concat diary-string |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1940 (format "......")))) |
527b0ddd39b9
(icalendar--format-ical-event, icalendar--convert-ical-to-diary):
Juanma Barranquero <lekktu@gmail.com>
parents:
78216
diff
changeset
|
1941 (icalendar--split-value rdate))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1942 ;; non-recurring event |
60235
025b4fbe4149
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60015
diff
changeset
|
1943 ;; all-day event |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1944 ((not (string= start-d end-d)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1945 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1946 (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
|
1947 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
|
1948 (setq event-ok t)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1949 ;; not all-day |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1950 ((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
|
1951 (not (string= start-t end-t)))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1952 (setq diary-string |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1953 (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
|
1954 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
|
1955 (setq event-ok t)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1956 ;; all-day event |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1957 (t |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1958 (icalendar--dmsg "all day event") |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1959 (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
|
1960 dtstart-dec "/")) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1961 (setq event-ok t))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1962 ;; 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
|
1963 ;; them |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1964 (if event-ok |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1965 (progn |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1966 (setq diary-string |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1967 (concat diary-string " " |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1968 (icalendar--format-ical-event e))) |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
1969 (if do-not-ask (setq summary nil)) |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1970 ;; add entry to diary and store actual name of diary |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1971 ;; file (in case it was nil) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1972 (setq diary-file |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1973 (icalendar--add-diary-entry diary-string diary-file |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1974 non-marking summary))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1975 ;; event was not ok |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1976 (setq found-error t) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1977 (setq error-string |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1978 (format "%s\nCannot handle this event:%s" |
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
1979 error-string e)))) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1980 ;; 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
|
1981 ;; handle errors |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1982 (error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1983 (message "Ignoring event \"%s\"" e) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1984 (setq found-error t) |
60015
7152e45c561a
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57862
diff
changeset
|
1985 (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
|
1986 error-val error-string e)) |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64432
diff
changeset
|
1987 (message "%s" error-string)))) |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1988 |
74673
9963f42a0a19
From Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
68943
diff
changeset
|
1989 ;; insert final newline |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1990 (if diary-file |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1991 (let ((b (find-buffer-visiting diary-file))) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1992 (when b |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1993 (save-current-buffer |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1994 (set-buffer b) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1995 (goto-char (point-max)) |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
1996 (insert "\n"))))) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1997 (if found-error |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
1998 (save-current-buffer |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
1999 (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
|
2000 (erase-buffer) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2001 (insert error-string))) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2002 (message "Converting icalendar...done") |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2003 found-error)) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2004 |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2005 ;; subroutines for importing |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2006 (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
|
2007 "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
|
2008 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2009 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
|
2010 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
|
2011 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
|
2012 (icalendar--dmsg "recurring event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2013 (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
|
2014 (rrule-props (icalendar--split-value rrule)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2015 (frequency (cadr (assoc 'FREQ rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2016 (until (cadr (assoc 'UNTIL rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2017 (count (cadr (assoc 'COUNT rrule-props))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2018 (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
|
2019 (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
|
2020 (until-conv (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2021 (icalendar--decode-isodatetime until))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2022 (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
|
2023 (icalendar--decode-isodatetime until -1))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2024 (result "")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2025 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2026 ;; FIXME FIXME interval!!!!!!!!!!!!! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2027 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2028 (when count |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2029 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2030 (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
|
2031 (let ((until-1 0)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2032 (cond ((string-equal frequency "DAILY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2033 (setq until (icalendar--add-decoded-times |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2034 dtstart-dec |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2035 (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
|
2036 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2037 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2038 (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
|
2039 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2040 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2041 ((string-equal frequency "WEEKLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2042 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2043 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2044 (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
|
2045 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2046 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2047 (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
|
2048 interval) 0 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2049 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2050 ((string-equal frequency "MONTHLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2051 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2052 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
|
2053 interval) 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2054 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2055 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
|
2056 interval) 0))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2057 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2058 ((string-equal frequency "YEARLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2059 (setq until (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2060 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
|
2061 interval)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2062 (setq until-1 (icalendar--add-decoded-times |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2063 dtstart-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2064 (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
|
2065 interval)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2066 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2067 (t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2068 (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
|
2069 frequency))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2070 (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
|
2071 (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
|
2072 )) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2073 ) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2074 (cond ((string-equal frequency "WEEKLY") |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2075 (let* ((byday (cadr (assoc 'BYDAY rrule-props))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2076 (weekdays |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2077 (icalendar--get-weekday-numbers byday)) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2078 (weekday-clause |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2079 (when (> (length weekdays) 1) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2080 (format "(memq (calendar-day-of-week date) '%s) " |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2081 weekdays)))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2082 (if (not start-t) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2083 (progn |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2084 ;; weekly and all-day |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2085 (icalendar--dmsg "weekly all-day") |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2086 (if until |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2087 (setq result |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2088 (format |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2089 (concat "%%%%(and " |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2090 "%s" |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2091 "(diary-block %s %s))") |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2092 (or weekday-clause |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2093 (format "(diary-cyclic %d %s) " |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2094 (* interval 7) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2095 dtstart-conv)) |
109808 | 2096 dtstart-conv |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2097 (if count until-1-conv until-conv) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2098 )) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2099 (setq result |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2100 (format "%%%%(and %s(diary-cyclic %d %s))" |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2101 (or weekday-clause "") |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2102 (if weekday-clause 1 (* interval 7)) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2103 dtstart-conv)))) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2104 ;; weekly and not all-day |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2105 (icalendar--dmsg "weekly not-all-day") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2106 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2107 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2108 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2109 (concat "%%%%(and " |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2110 "%s" |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2111 "(diary-block %s %s)) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2112 "%s%s%s") |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2113 (or weekday-clause |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2114 (format "(diary-cyclic %d %s) " |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2115 (* interval 7) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2116 dtstart-conv)) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2117 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2118 until-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2119 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2120 (if end-t "-" "") (or end-t ""))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2121 ;; no limit |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2122 ;; FIXME!!!! |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2123 ;; DTSTART;VALUE=DATE-TIME:20030919T090000 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2124 ;; DTEND;VALUE=DATE-TIME:20030919T113000 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2125 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2126 (format |
109686
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2127 "%%%%(and %s(diary-cyclic %d %s)) %s%s%s" |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2128 (or weekday-clause "") |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2129 (if weekday-clause 1 (* interval 7)) |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2130 dtstart-conv |
111f90199914
Fixed bug#6766 (icalendar.el)
Ulf Jasper <ulf.jasper@web.de>
parents:
107252
diff
changeset
|
2131 (or start-t "") |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2132 (if end-t "-" "") (or end-t ""))))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2133 ;; yearly |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2134 ((string-equal frequency "YEARLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2135 (icalendar--dmsg "yearly") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2136 (if until |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2137 (let ((day (nth 3 dtstart-dec)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2138 (month (nth 4 dtstart-dec))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2139 (setq result (concat "%%(and (diary-date " |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2140 (cond ((eq (icalendar--date-style) 'iso) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2141 (format "t %d %d" month day)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2142 ((eq (icalendar--date-style) 'european) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2143 (format "%d %d t" day month)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2144 ((eq (icalendar--date-style) 'american) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2145 (format "%d %d t" month day))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2146 ") (diary-block " |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2147 dtstart-conv |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2148 " " |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2149 until-conv |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2150 ")) " |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2151 (or start-t "") |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2152 (if end-t "-" "") |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2153 (or end-t "")))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2154 (setq result (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2155 "%%%%(and (diary-anniversary %s)) %s%s%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2156 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2157 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2158 (if end-t "-" "") (or end-t ""))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2159 ;; monthly |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2160 ((string-equal frequency "MONTHLY") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2161 (icalendar--dmsg "monthly") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2162 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2163 (format |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2164 "%%%%(and (diary-date %s) (diary-block %s %s)) %s%s%s" |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2165 (let ((day (nth 3 dtstart-dec))) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2166 (cond ((eq (icalendar--date-style) 'iso) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2167 (format "t t %d" day)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2168 ((eq (icalendar--date-style) 'european) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2169 (format "%d t t" day)) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2170 ((eq (icalendar--date-style) 'american) |
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2171 (format "t %d t" day)))) |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2172 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2173 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2174 until-conv |
95273
4d3975347028
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
2175 (if (eq (icalendar--date-style) 'iso) "9999 1 1" "1 1 9999")) ;; FIXME: should be unlimited |
62053
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2176 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2177 (if end-t "-" "") (or end-t "")))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2178 ;; daily |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2179 ((and (string-equal frequency "DAILY")) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2180 (if until |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2181 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2182 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2183 (concat "%%%%(and (diary-cyclic %s %s) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2184 "(diary-block %s %s)) %s%s%s") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2185 interval dtstart-conv dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2186 (if count until-1-conv until-conv) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2187 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2188 (if end-t "-" "") (or end-t ""))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2189 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2190 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2191 "%%%%(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
|
2192 interval |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2193 dtstart-conv |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2194 (or start-t "") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2195 (if end-t "-" "") (or end-t "")))))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2196 ;; Handle exceptions from recurrence rules |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2197 (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
|
2198 (while ex-dates |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2199 (let* ((ex-start (icalendar--decode-isodatetime |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2200 (car ex-dates))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2201 (ex-d (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2202 ex-start))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2203 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2204 (icalendar--rris "^%%(\\(and \\)?" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2205 (format |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2206 "%%%%(and (not (diary-date %s)) " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2207 ex-d) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2208 result))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2209 (setq ex-dates (cdr ex-dates)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2210 ;; FIXME: exception rules are not recognized |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2211 (if (icalendar--get-event-property e 'EXRULE) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2212 (setq result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2213 (concat result |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2214 "\n Exception rules: " |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2215 (icalendar--get-event-properties |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2216 e 'EXRULE)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2217 result)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2218 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2219 (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
|
2220 "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
|
2221 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2222 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
|
2223 Argument START-D gives the first day. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2224 Argument END-D gives the last day." |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2225 (icalendar--dmsg "non-recurring all-day event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2226 (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
|
2227 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2228 (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
|
2229 dtend-dec |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2230 start-t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2231 end-t) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2232 "Convert recurring icalendar EVENT to diary format. |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2233 |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2234 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
|
2235 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
|
2236 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
|
2237 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
|
2238 (icalendar--dmsg "not all day event") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2239 (cond (end-t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2240 (format "%s %s-%s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2241 (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2242 dtstart-dec "/") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2243 start-t end-t)) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2244 (t |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2245 (format "%s %s" |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2246 (icalendar--datetime-to-diary-date |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2247 dtstart-dec "/") |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2248 start-t)))) |
57aabea77432
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
60382
diff
changeset
|
2249 |
57586
376b47c63cfd
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
57345
diff
changeset
|
2250 (defun icalendar--add-diary-entry (string diary-file non-marking |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2251 &optional summary) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2252 "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
|
2253 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
|
2254 determines whether diary events are created as non-marking. If |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2255 SUMMARY is not nil it must be a string that gives the summary of the |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2256 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
|
2257 the entry." |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2258 (when (or (not summary) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2259 (y-or-n-p (format "Add appointment for `%s' to diary? " |
66374
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2260 summary))) |
88fc54347c68
From Ulf Jasper <ulf.jasper@web.de>:
Glenn Morris <rgm@gnu.org>
parents:
65591
diff
changeset
|
2261 (when summary |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2262 (setq non-marking |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2263 (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
|
2264 (save-window-excursion |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2265 (unless diary-file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2266 (setq diary-file |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2267 (read-file-name "Add appointment to this diary file: "))) |
93790
adddea858c0d
Update for diary-lib name changes.
Glenn Morris <rgm@gnu.org>
parents:
93376
diff
changeset
|
2268 ;; Note: diary-make-entry will add a trailing blank char.... :( |
adddea858c0d
Update for diary-lib name changes.
Glenn Morris <rgm@gnu.org>
parents:
93376
diff
changeset
|
2269 (funcall (if (fboundp 'diary-make-entry) |
adddea858c0d
Update for diary-lib name changes.
Glenn Morris <rgm@gnu.org>
parents:
93376
diff
changeset
|
2270 'diary-make-entry |
adddea858c0d
Update for diary-lib name changes.
Glenn Morris <rgm@gnu.org>
parents:
93376
diff
changeset
|
2271 'make-diary-entry) |
adddea858c0d
Update for diary-lib name changes.
Glenn Morris <rgm@gnu.org>
parents:
93376
diff
changeset
|
2272 string non-marking diary-file))) |
106617
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
2273 ;; Würgaround to remove the trailing blank char |
107252
2da9673fc448
Fix more save-excursion warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
107199
diff
changeset
|
2274 (with-current-buffer (find-file diary-file) |
106617
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
2275 (goto-char (point-max)) |
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
2276 (if (= (char-before) ? ) |
78f92ffeb7ab
Fixed timezone handling problem in icalendar.el.
Ulf Jasper <ulf.jasper@web.de>
parents:
104396
diff
changeset
|
2277 (delete-char -1))) |
76645
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
2278 ;; return diary-file in case it has been changed interactively |
fe0cd0081a51
Ulf Jasper <ulf.jasper at web.de>:
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
2279 diary-file) |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2280 |
88008
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2281 ;; ====================================================================== |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2282 ;; Examples |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2283 ;; ====================================================================== |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2284 (defun icalendar-import-format-sample (event) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2285 "Example function for formatting an icalendar EVENT." |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2286 (format (concat "SUMMARY=`%s' DESCRIPTION=`%s' LOCATION=`%s' ORGANIZER=`%s' " |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2287 "STATUS=`%s' URL=`%s' CLASS=`%s'") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2288 (or (icalendar--get-event-property event 'SUMMARY) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2289 (or (icalendar--get-event-property event 'DESCRIPTION) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2290 (or (icalendar--get-event-property event 'LOCATION) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2291 (or (icalendar--get-event-property event 'ORGANIZER) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2292 (or (icalendar--get-event-property event 'STATUS) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2293 (or (icalendar--get-event-property event 'URL) "") |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2294 (or (icalendar--get-event-property event 'CLASS) ""))) |
c8869a3e1938
Ulf Jasper <ulf.jasper at web.de>
Glenn Morris <rgm@gnu.org>
parents:
87780
diff
changeset
|
2295 |
57337
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2296 (provide 'icalendar) |
a1b1850b5a47
New file, from Ulf Jasper <ulf.jasper@web.de>.
Glenn Morris <rgm@gnu.org>
parents:
diff
changeset
|
2297 |
57345
f024640dc5e4
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
57337
diff
changeset
|
2298 ;; 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
|
2299 ;;; icalendar.el ends here |