This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
funcs.el
53 lines (48 loc) · 2.23 KB
/
funcs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;;; funcs.el --- google-calendar Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Markus Johansson markus.johansson@me.com
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(when (configuration-layer/package-usedp 'org-gcal)
(defun google-calendar/org-gcal-update ()
"Refresh OAuth token, fetch and sync calendar"
(interactive)
(org-gcal-refresh-token)
(org-gcal-fetch))
(defun google-calendar/sync-cal-after-capture ()
"Sync calendar after a event was added with org-capture.
The function can be run automatically with the 'org-capture-after-finalize-hook'."
(when-let ((cal-files (mapcar 'f-expand (mapcar 'cdr org-gcal-file-alist)))
(capture-target (f-expand (car (cdr (org-capture-get :target)))))
(cal-file-exists (and (mapcar 'f-file? cal-files)))
(capture-target-isfile (eq (car (org-capture-get :target)) 'file))
(capture-target-is-cal-file (member capture-target cal-files)))
(org-gcal-refresh-token)
(org-gcal-post-at-point))))
(when (configuration-layer/package-usedp 'calfw)
(defun google-calendar/calfw-view ()
"Open calfw calendar view."
(interactive)
(let ((org-agenda-window-setup calfw-calendar-window-setup))
(google-calendar/calfw-prepare-window)
;;; If non nil, overload agenda window setup with the desired setup for calfw
(org-agenda nil calfw-org-agenda-view)
(cfw:open-org-calendar)))
(defun google-calendar/calfw-prepare-window ()
"Store current window layout in before opening calfw."
(when-let ((is-not-cal-buffer (not (member (buffer-name) '("*cfw-calendar*" "*Org Agenda*"))))
(is-not-conf (not (equal calfw-window-conf '(current-window-configuration)))))
(setq calfw-window-conf (current-window-configuration))))
(defun google-calendar/calfw-restore-windows ()
"Bury current buffer and restore window layout."
(interactive)
(bury-buffer)
(if (and (not (eq calfw-window-conf nil))
(eq calfw-restore-windows-after-quit 't))
(progn (set-window-configuration calfw-window-conf)
(setq calfw-window-conf nil)))))