[PATCH] Emacs calendar CVS sync and bug fixes

Jeff Miller jmiller at cablespeed.com
Tue Jan 23 22:22:15 EST 2007


I intend to commit this weekend.

Jeff 


ChangeLog addition:

2007-01-23  Jeff Miller  <jeff.miller at xemacs.org>

	* icalendar.el (icalendar--rris): Fixed improper argument usage for replace-string. 
	* ChangeLog: restores Adrian Aichner original ChangeLog dates.

2007-01-08  Juanma Barranquero  <lekktu at gmail.com>

        * calendar/icalendar.el (icalendar-import-buffer):Fix typo in docstring.
	
2006-12-24  Kevin Ryde  <user42 at zip.com.au>

        * calendar/cal-dst.el (calendar-dst-starts): Default to second Sunday
        in March.
        (calendar-dst-ends): Default to first Sunday in November.

2006-12-23  Chong Yidong  <cyd at stupidchicken.com>

        * calendar/calendar.el (calendar-mode-map): Switch < and >.
        (calendar-mode-line-format): Use mouse-1 bindings, and tweak
        formatting.

2006-12-17  Ulf Jasper  <ulf.jasper at web.de>

        * calendar/icalendar.el (icalendar-version): Increase to "0.14".
        (icalendar--rris): First try Emacs, then XEmacs.
        (icalendar--convert-ical-to-diary): Doc fix.  Insert
        newline at end of target file.


calendar source patch:
Diff command:   cvs -q diff -uN
Files affected: icalendar.el calendar.el cal-dst.el

Index: cal-dst.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/cal-dst.el,v
retrieving revision 1.7
diff -u -u -r1.7 cal-dst.el
--- cal-dst.el	2006/11/13 04:22:11	1.7
+++ cal-dst.el	2007/01/24 03:20:29
@@ -50,12 +50,13 @@
 current date apply to all years.  This is faster, but not always
 correct, since the dates of Daylight Saving transitions sometimes
 change."
-:type 'boolean
-:version "22.1"
-:group 'calendar)
+:type 'boolean
+:version "22.1"
+:group 'calendar)
 
 (defvar calendar-current-time-zone-cache nil
-  "Cache for result of calendar-current-time-zone.")
+  "Cache for result of `calendar-current-time-zone'.")
+(put 'calendar-current-time-zone-cache 'risky-local-variable t)
 
 (defvar calendar-system-time-basis
   (calendar-absolute-from-gregorian '(1 1 1970))
@@ -347,8 +348,9 @@
                       (cadr (calendar-dst-find-startend year))
                     (nth 4 calendar-current-time-zone-cache))))
         (if expr (eval expr)))
+      ;; New US rules commencing 2007.	ftp://elsie.nci.nih.gov/pub/.
       (and (not (zerop calendar-daylight-time-offset))
-           (calendar-nth-named-day 1 0 4 year))))
+           (calendar-nth-named-day 2 0 3 year))))
 
 (defun calendar-dst-ends (year)
   "Return the date of YEAR on which Daylight Saving Time ends.
@@ -357,8 +359,9 @@
                       (nth 2 (calendar-dst-find-startend year))
                     (nth 5 calendar-current-time-zone-cache))))
         (if expr (eval expr)))
+      ;; New US rules commencing 2007.	ftp://elsie.nci.nih.gov/pub/.
       (and (not (zerop calendar-daylight-time-offset))
-           (calendar-nth-named-day -1 0 10 year))))
+           (calendar-nth-named-day 1 0 11 year))))
 
 
 ;;;###autoload
Index: calendar.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/calendar.el,v
retrieving revision 1.13
diff -u -u -r1.13 calendar.el
--- calendar.el	2006/11/19 00:31:23	1.13
+++ calendar.el	2007/01/24 03:20:29
@@ -580,8 +580,8 @@
   :type 'boolean
   ;; Without :initialize (require 'calendar) throws an error because
   ;; american-calendar is undefined at this point.
-:initialize 'custom-initialize-default
-:set (lambda (symbol value)
+:initialize 'custom-initialize-default
+:set (lambda (symbol value)
          (if value
              (european-calendar)
            (american-calendar)))
@@ -2213,12 +2213,12 @@
                  downcase-region upcase-region kill-region
                  copy-region-as-kill capitalize-region write-region))
       (define-key map (vector 'remap c) 'calendar-not-implemented))
-    (define-key map ">"     'scroll-calendar-right)
-    (define-key map "\C-x>" 'scroll-calendar-right)
+    (define-key map "<"     'scroll-calendar-right)
+    (define-key map "\C-x<" 'scroll-calendar-right)
     (define-key map [prior] 'scroll-calendar-right-three-months)
     (define-key map "\ev"   'scroll-calendar-right-three-months)
-    (define-key map "<"     'scroll-calendar-left)
-    (define-key map "\C-x<" 'scroll-calendar-left)
+    (define-key map ">"     'scroll-calendar-left)
+    (define-key map "\C-x>" 'scroll-calendar-left)
     (define-key map [next]  'scroll-calendar-left-three-months)
     (define-key map "\C-v"  'scroll-calendar-left-three-months)
     (define-key map "\C-b"  'calendar-backward-day)
Index: icalendar.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/icalendar.el,v
retrieving revision 1.1
diff -u -u -r1.1 icalendar.el
--- icalendar.el	2006/10/23 01:25:29	1.1
+++ icalendar.el	2007/01/24 03:20:29
@@ -75,6 +75,10 @@
 
 ;;  * Import from ical to diary:
 ;;    + Need more properties for icalendar-import-format
+;;      (added all that Mozilla Calendar uses)
+;;      From iCal specifications (RFC2445: 4.8.1), icalendar.el lacks
+;;      ATTACH, CATEGORIES, COMMENT, GEO, PERCENT-COMPLETE (VTODO),
+;;      PRIORITY, RESOURCES) not considering date/time and time-zone
 ;;    + check vcalendar version
 ;;    + check (unknown) elements
 ;;    + recurring events!
@@ -99,7 +103,7 @@
 
 ;;; Code:
 
-(defconst icalendar-version "0.13"
+(defconst icalendar-version "0.14"
   "Version number of icalendar.el.")
 
 ;; ======================================================================
@@ -107,8 +111,8 @@
 ;; ======================================================================
 (defgroup icalendar nil
   "Icalendar support."
-:prefix "icalendar-"
-:group 'calendar)
+:prefix "icalendar-"
+:group 'calendar)
 
 (defcustom icalendar-import-format
   "%s%d%l%o"
@@ -122,64 +126,64 @@
 %s Summary, see `icalendar-import-format-summary'
 %t Status, see `icalendar-import-format-status'
 %u URL, see `icalendar-import-format-url'"
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-summary
   "%s"
   "Format string defining how the summary element is formatted.
 This applies only if the summary is not empty! `%s' is replaced
 by the summary."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-description
   "\n Desc: %s"
   "Format string defining how the description element is formatted.
 This applies only if the description is not empty! `%s' is
 replaced by the description."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-location
   "\n Location: %s"
   "Format string defining how the location element is formatted.
 This applies only if the location is not empty! `%s' is replaced
 by the location."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-organizer
   "\n Organizer: %s"
   "Format string defining how the organizer element is formatted.
 This applies only if the organizer is not empty! `%s' is
 replaced by the organizer."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-url
   "\n URL: %s"
   "Format string defining how the URL element is formatted.
 This applies only if the URL is not empty! `%s' is replaced by
 the URL."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-status
   "\n Status: %s"
   "Format string defining how the status element is formatted.
 This applies only if the status is not empty! `%s' is replaced by
 the status."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defcustom icalendar-import-format-class
   "\n Class: %s"
   "Format string defining how the class element is formatted.
 This applies only if the class is not empty! `%s' is replaced by
 the class."
-:type 'string
-:group 'icalendar)
+:type 'string
+:group 'icalendar)
 
 (defvar icalendar-debug nil
   "Enable icalendar debug messages.")
@@ -224,16 +228,24 @@
         (replace-match "" nil nil)))
     unfolded-buffer))
 
-(defsubst icalendar--rris (&rest args)
+;; XEmacs change.   
+;; As originally written, icalendar--rris assumed replace-regexp-in-string
+;; and replace-in-string used the same number of args and in the same order. 
+;; They don't, so expand the args and use the appropriate ones. 
+(defsubst icalendar--rris (regexp newtext str &optional fixed-case literal)
   "Replace regular expression in string.
 Pass ARGS to `replace-regexp-in-string' (Emacs) or to
 `replace-in-string' (XEmacs)."
-  ;; XEmacs:
-  (if (fboundp 'replace-in-string)
-      (save-match-data ;; apparently XEmacs needs save-match-data
-        (apply 'replace-in-string args))
-    ;; Emacs:
-    (apply 'replace-regexp-in-string args)))
+  (if (fboundp 'replace-regexp-in-string)
+      ;; Emacs:
+      ;;(apply 'replace-regexp-in-string args)
+      ;; XEmacs change, use the args
+      (replace-regexp-in-string regexp newtext str args fixed-case literal)
+    ;; XEmacs:
+    (save-match-data ;; apparently XEmacs needs save-match-data
+      ;;(apply 'replace-in-string args))))
+      ;; XEmacs change, use the args
+      (replace-in-string str regexp newtext literal ))))
 
 (defun icalendar--read-element (invalue inparams)
   "Recursively read the next iCalendar element in the current buffer.
@@ -707,7 +719,7 @@
   "Export diary file to iCalendar format.
 All diary entries in the file DIARY-FILENAME are converted to iCalendar
 format.  The result is appended to the file ICAL-FILENAME."
-  (interactive "FExport diary data from file: 
+  (interactive "FExport diary data from file:
 Finto iCalendar file: ")
   (save-current-buffer
     (set-buffer (find-file diary-filename))
@@ -1451,8 +1463,8 @@
 Argument DIARY-FILENAME input `diary-file'.
 Optional argument NON-MARKING determines whether events are created as
 non-marking or not."
-  (interactive "fImport iCalendar data from file: 
-Finto diary file: 
+  (interactive "fImport iCalendar data from file:
+Finto diary file:
 p")
   ;; clean up the diary file
   (save-current-buffer
@@ -1477,7 +1489,7 @@
 non-marking.
 
 Return code t means that importing worked well, return code nil
-means that an error has occured.  Error messages will be in the
+means that an error has occurred.  Error messages will be in the
 buffer `*icalendar-errors*'."
   (interactive)
   (save-current-buffer
@@ -1506,7 +1518,7 @@
                   (set-buffer b)
                   (save-buffer)))))
           (message "Converting icalendar...done")
-          ;; return t if no error occured
+          ;; return t if no error occurred
           (not ical-errors))
       (message
        "Current buffer does not contain icalendar contents!")
@@ -1551,7 +1563,7 @@
 (defun icalendar--convert-ical-to-diary (ical-list diary-file
                                                    &optional do-not-ask
                                                    non-marking)
-  "Convert Calendar data to an Emacs diary file.
+  "Convert iCalendar data to an Emacs diary file.
 Import VEVENTS from the iCalendar object ICAL-LIST and saves them to a
 DIARY-FILE.  If DO-NOT-ASK is nil the user is asked for each event
 whether to actually import it.  NON-MARKING determines whether diary
@@ -1682,6 +1694,13 @@
          (setq error-string (format "%s\n%s\nCannot handle this event: %s"
                                     error-val error-string e))
          (message "%s" error-string))))
+    ;; insert final newline
+    (let ((b (find-buffer-visiting diary-file)))
+      (when b
+        (save-current-buffer
+          (set-buffer b)
+          (goto-char (point-max))
+          (insert "\n"))))
     (if found-error
         (save-current-buffer
           (set-buffer (get-buffer-create "*icalendar-errors*"))



More information about the XEmacs-Patches mailing list