|
;;; Taken pretty much verbatim from https://orgmode.org/worg/org-tutorials/org-google-sync.html |
|
;;; Thanks to those developers! |
|
|
|
;; https://stackoverflow.com/questions/23463962/emacs-export-calendar-bad-timezone-format-in-ics |
|
(setq org-icalendar-timezone "America/New_York") |
|
|
|
|
|
|
|
;;; define categories that should be excluded |
|
(setq org-export-exclude-category (list "google" "private")) |
|
|
|
;;; define filter. The filter is called on each entry in the agenda. |
|
;;; It defines a regexp to search for two timestamps, gets the start |
|
;;; and end point of the entry and does a regexp search. It also |
|
;;; checks if the category of the entry is in an exclude list and |
|
;;; returns either t or nil to skip or include the entry. |
|
|
|
(defun org-mycal-export-limit () |
|
"Limit the export to items that have a date, time and a range. Also exclude certain categories." |
|
(setq org-tst-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ... [0-9]\\{2\\}:[0-9]\\{2\\}[^\r\n>]*?\ |
|
\)>") |
|
(setq org-tstr-regexp (concat org-tst-regexp "--?-?" org-tst-regexp)) |
|
(save-excursion |
|
; get categories |
|
(setq mycategory (org-get-category)) |
|
; get start and end of tree |
|
(org-back-to-heading t) |
|
(setq mystart (point)) |
|
(org-end-of-subtree) |
|
(setq myend (point)) |
|
(goto-char mystart) |
|
; search for timerange |
|
(setq myresult (re-search-forward org-tstr-regexp myend t)) |
|
; search for categories to exclude |
|
(setq mycatp (member mycategory org-export-exclude-category)) |
|
; return t if ok, nil when not ok |
|
(if (and myresult (not mycatp)) t nil))) |
|
|
|
;;; activate filter and call export function |
|
;;(defun org-mycal-export () |
|
;; (let ((org-icalendar-verify-function 'org-mycal-export-limit)) |
|
;; (org-export-icalendar-combine-agenda-files))) |
|
;; FVV updated 2018-05-29: |
|
(defun org-mycal-export () |
|
(let ((org-icalendar-verify-function 'org-mycal-export-limit)) |
|
(org-icalendar-combine-agenda-files))) |
|
|