X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/eadf313c72edcc3a11b9d03032699416efebfe1a..08974112ae68aefba658a8516c8faa3374edc924:/lisp/calendar/icalendar.el diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 452a672ae3..386c554c06 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -1,6 +1,6 @@ -;;; icalendar.el --- iCalendar implementation -*-coding: utf-8 -*- +;;; icalendar.el --- iCalendar implementation -;; Copyright (C) 2002-2015 Free Software Foundation, Inc. +;; Copyright (C) 2002-2016 Free Software Foundation, Inc. ;; Author: Ulf Jasper ;; Created: August 2002 @@ -39,7 +39,7 @@ ;;; 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-*. @@ -261,7 +261,7 @@ If non-nil all sexp diary entries are enumerated for `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 @@ -321,18 +321,29 @@ other sexp entries are enumerated in any case." "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 @@ -482,7 +493,7 @@ children." result)) (defun icalendar--split-value (value-string) - "Split VALUE-STRING at ';='." + "Split VALUE-STRING at `;='." (let ((result '()) param-name param-value) (when value-string @@ -618,13 +629,7 @@ FIXME: multiple comma-separated values should be allowed!" (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 @@ -1124,10 +1129,10 @@ FExport diary data into iCalendar file: ") (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 @@ -1302,8 +1307,8 @@ Returns an alist." "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)) @@ -1635,8 +1640,8 @@ enumeration, given as a time value, in same format as returned by (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 @@ -2479,8 +2484,8 @@ SUMMARY is not nil it must be a string that gives the summary of the 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? ")))) @@ -2506,8 +2511,8 @@ the entry." ;; ====================================================================== (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) "")