emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Don Roberts <roberts@refactory.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-mac-ical: Include repeating events in diary file
Date: Sat, 30 Jul 2011 11:36:19 -0500	[thread overview]
Message-ID: <85D38C62-CE6A-497C-861A-06050EFD0609@refactory.com> (raw)

[-- 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


             reply	other threads:[~2011-07-30 16:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-30 16:36 Don Roberts [this message]
2011-08-14 16:35 ` [PATCH] org-mac-ical: Include repeating events in diary file Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85D38C62-CE6A-497C-861A-06050EFD0609@refactory.com \
    --to=roberts@refactory.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).