-;;; icalendar.el --- iCalendar implementation -*-coding: utf-8 -*-
+;;; icalendar.el --- iCalendar implementation
-;; Copyright (C) 2002-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2016 Free Software Foundation, Inc.
;; Author: Ulf Jasper <ulf.jasper@web.de>
;; Created: August 2002
;;; History:
-;; 0.07 onwards: see lisp/ChangeLog
+;; 0.07 onwards: see commit logs and ../ChangeLog*.
;; 0.06: (2004-10-06)
;; - Bugfixes regarding icalendar-import-format-*.
`icalendar-export-sexp-enumeration-days' days instead of
translating into an icalendar equivalent. This affects the
following sexp diary entries: `diary-anniversary',
-`diary-cyclic', `diary-date', `diary-float',`diary-block'. All
+`diary-cyclic', `diary-date', `diary-float', `diary-block'. All
other sexp entries are enumerated in any case."
:version "25.1"
:type 'boolean
"Return a new buffer containing the unfolded contents of a buffer.
Folding is the iCalendar way of wrapping long lines. In the
created buffer all occurrences of CR LF BLANK are replaced by the
-empty string. Argument FOLDED-ICAL-BUFFER is the unfolded input
+empty string. Argument FOLDED-ICAL-BUFFER is the folded input
buffer."
(let ((unfolded-buffer (get-buffer-create " *icalendar-work*")))
(save-current-buffer
(set-buffer unfolded-buffer)
(erase-buffer)
(insert-buffer-substring folded-ical-buffer)
+ (icalendar--clean-up-line-endings)
(goto-char (point-min))
(while (re-search-forward "\r?\n[ \t]" nil t)
(replace-match "" nil nil)))
unfolded-buffer))
+(defun icalendar--clean-up-line-endings ()
+ "Replace DOS- and MAC-like line endings with unix line endings.
+All occurrences of (CR LF) and (LF CF) are replaced with LF in
+the current buffer. This is necessary in buffers which contain a
+mix of different line endings."
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\r\n\\|\n\r" nil t)
+ (replace-match "\n" nil nil))))
+
(defsubst icalendar--rris (regexp rep string &optional fixedcase literal)
"Replace regular expression in string.
Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to
result))
(defun icalendar--split-value (value-string)
- "Split VALUE-STRING at ';='."
+ "Split VALUE-STRING at `;='."
(let ((result '())
param-name param-value)
(when value-string
(when (and (> (length isodatetimestring) 15)
;; UTC specifier present
(char-equal ?Z (aref isodatetimestring 15)))
- ;; if not UTC add current-time-zone offset
- ;; current-time-zone should be called with actual UTC time
- ;; (daylight saving at that time may differ to current one)
- (setq second (+ (car (current-time-zone
- (encode-time second minute hour day month year
- 0)))
- second)))
+ (setq zone t))
;; shift if necessary
(if day-shift
(let ((mdy (calendar-gregorian-from-absolute
(setq found-error t)
(save-current-buffer
(set-buffer (get-buffer-create "*icalendar-errors*"))
- (insert (format "Error in line %d -- %s: `%s'\n"
- (count-lines (point-min) (point))
- error-val
- entry-main))))))
+ (insert (format-message "Error in line %d -- %s: `%s'\n"
+ (count-lines (point-min) (point))
+ error-val
+ entry-main))))))
;; we're done, insert everything into the file
(save-current-buffer
"Return a VALARM block.
Argument ADVANCE-TIME is a number giving the time when the alarm
fires (minutes before the respective event). Argument ALARM-SPEC
-is a list which must be one of '(audio), '(display) or
-'(email (ADDRESS1 ...)), see `icalendar-export-alarms'. Argument
+is a list which must be one of (audio), (display) or
+(email (ADDRESS1 ...)), see `icalendar-export-alarms'. Argument
SUMMARY is a string which contains a short description for the
alarm."
(let* ((action (car alarm-spec))
(icalendar--convert-ordinary-to-ical
nonmarker (format "%4d/%02d/%02d %s" y m d see))))
(;TODO:
- (error (format "Unsupported Sexp-entry: %s"
- entry-main))))))
+ (error "Unsupported Sexp-entry: %s"
+ entry-main)))))
(number-sequence
0 (- icalendar-export-sexp-enumeration-days 1))))))
(t
entry. In this case the user will be asked whether he wants to insert
the entry."
(when (or (not summary)
- (y-or-n-p (format "Add appointment for `%s' to diary? "
- summary)))
+ (y-or-n-p (format-message "Add appointment for `%s' to diary? "
+ summary)))
(when summary
(setq non-marking
(y-or-n-p (format "Make appointment non-marking? "))))
;; ======================================================================
(defun icalendar-import-format-sample (event)
"Example function for formatting an iCalendar EVENT."
- (format (concat "SUMMARY=`%s' DESCRIPTION=`%s' LOCATION=`%s' ORGANIZER=`%s' "
- "STATUS=`%s' URL=`%s' CLASS=`%s'")
+ (format (concat "SUMMARY='%s' DESCRIPTION='%s' LOCATION='%s' ORGANIZER='%s' "
+ "STATUS='%s' URL='%s' CLASS='%s'")
(or (icalendar--get-event-property event 'SUMMARY) "")
(or (icalendar--get-event-property event 'DESCRIPTION) "")
(or (icalendar--get-event-property event 'LOCATION) "")