emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-mac-ical: Include repeating events in diary file
@ 2011-07-30 16:36 Don Roberts
  2011-08-14 16:35 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Don Roberts @ 2011-07-30 16:36 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]

This patch fixes two bugs. The original code always included events in December of the previous year and January of the next year regardless of the month range. This fixes that. Also, the original code didn't keep repeating events that started outside of the month range. The new code keeps all repeating events.

Don Roberts


[-- Attachment #2: 0001-org-mac-ical-Clean-up-org-mac-iCal-range-checking-to.patch --]
[-- Type: application/octet-stream, Size: 2364 bytes --]

From 5f1c8e1ab67c929eccdf9c3fb9e8b4d33900bdec Mon Sep 17 00:00:00 2001
From: Don Roberts <roberts@refactory.com>
Date: Sat, 30 Jul 2011 09:20:09 -0500
Subject: [PATCH] org-mac-ical: Clean up org-mac-iCal-range checking to
 eliminate end-of-year special cases and include repeating
 events in diary file

---
 contrib/lisp/org-mac-iCal.el |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/contrib/lisp/org-mac-iCal.el b/contrib/lisp/org-mac-iCal.el
index 83804c1..ee1c073 100644
--- a/contrib/lisp/org-mac-iCal.el
+++ b/contrib/lisp/org-mac-iCal.el
@@ -162,23 +162,25 @@ date range so that Emacs calendar view doesn't grind to a halt"
 	(re-search-forward "\\(^DTSTART;.*:\\)\\([0-9][0-9][0-9][0-9]\\)\\([0-9][0-9]\\)" nil t)
 	(if (or (eq (match-string 2) nil) (eq (match-string 3) nil))
 	    (progn
-	      (setq yearEntry 0)
-	      (setq monthEntry 0))
+	      (setq yearEntry 1)
+	      (setq monthEntry 1))
 	  (setq yearEntry (string-to-number (match-string 2)))
 	  (setq monthEntry (string-to-number (match-string 3))))
 	(setq year (string-to-number (format-time-string "%Y")))
 	(setq month (string-to-number (format-time-string "%m")))
-	(when (or
-	       (and
-		(= yearEntry year)
-		(or (< monthEntry (- month (/ org-mac-iCal-range 2))) (> monthEntry (+ month (/ org-mac-iCal-range 2)))))
-	       (< yearEntry (- year 1))
-	       (> yearEntry (+ year 1))
-	       (and
-		(= yearEntry (- year 1)) (/= monthEntry 12))
-	       (and
-		(= yearEntry (+ year 1)) (/= monthEntry 1)))
-	  (delete-region startEntry endEntry))))
+        (setq now (list month 1 year))
+        (setq entryDate (list monthEntry 1 yearEntry))
+        ;; Check to see if this is a repeating event
+        (goto-char (point-min))
+        (setq isRepeating (re-search-forward "^RRULE:" nil t))
+	;; Delete if outside range and not repeating
+        (when (and
+               (not isRepeating)
+               (> (abs (- (calendar-absolute-from-gregorian now)
+                          (calendar-absolute-from-gregorian entryDate)))
+                  (* (/ org-mac-iCal-range 2) 30))
+	  (delete-region startEntry endEntry)))
+          (goto-char (point-max))))
     (while 
 	(re-search-forward "^END:VEVENT$" nil t)
       (delete-blank-lines))
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] org-mac-ical: Include repeating events in diary file
  2011-07-30 16:36 [PATCH] org-mac-ical: Include repeating events in diary file Don Roberts
@ 2011-08-14 16:35 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-08-14 16:35 UTC (permalink / raw)
  To: Don Roberts; +Cc: emacs-orgmode

Hi Don,

Don Roberts <roberts@refactory.com> writes:

> This patch fixes two bugs. The original code always included events in
> December of the previous year and January of the next year regardless of
> the month range. This fixes that. Also, the original code didn't keep
> repeating events that started outside of the month range. The new code
> keeps all repeating events.

Applied, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-14 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-30 16:36 [PATCH] org-mac-ical: Include repeating events in diary file Don Roberts
2011-08-14 16:35 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).