Created
August 22, 2018 15:11
-
-
Save keegancsmith/27707e612580aae475bde0994d31e8d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package org-gcal | |
:config | |
(setq org-gcal-client-id "REDACTED" | |
org-gcal-client-secret "REDACTED" | |
org-gcal-file-alist '(("REDACTED" . "~/org-files/gcal.org") | |
("REDACTED" . "~/org-files/office.org") | |
("REDACTED" . "~/org-files/oncall.org"))) | |
;; org-gcal wrappers to only sync with a timeout | |
(defvar org-gcal-fetch-last-run (current-time) | |
"Timestamp of the last time org-gcal-fetch-store-time was run") | |
(defun org-gcal-fetch-with-timeout (timeout) | |
(interactive) | |
"Runs org-gcal-fetch only if the last time this function was called is > the timeout" | |
(let ((time-since-last-run | |
(float-time (time-subtract (current-time) org-gcal-fetch-last-run)))) | |
(when (> time-since-last-run timeout) ;; was the last run longer than our timeout | |
(org-gcal-fetch) | |
(set 'org-gcal-fetch-last-run (current-time))))) | |
(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-fetch-with-timeout 15.0)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment