org-mac-ical: Clean up org-mac-iCal-range checking to eliminate end-of-year special cases and include repeating events in diary file

This commit is contained in:
Don Roberts 2011-07-30 09:20:09 -05:00 committed by Bastien Guerry
parent a8de7b7fc8
commit 662c7a047b
1 changed files with 15 additions and 13 deletions

View File

@ -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))