Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/misohena/gcal
Google Calendar Utilities for Emacs
https://github.com/misohena/gcal
emacs emacs-lisp org-mode
Last synced: 2 months ago
JSON representation
Google Calendar Utilities for Emacs
- Host: GitHub
- URL: https://github.com/misohena/gcal
- Owner: misohena
- Created: 2016-05-27T11:17:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-19T01:41:54.000Z (8 months ago)
- Last Synced: 2024-06-19T08:40:28.522Z (8 months ago)
- Topics: emacs, emacs-lisp, org-mode
- Language: Emacs Lisp
- Homepage: https://misohena.jp/blog/2016-05-26-access-google-calendar-api-from-emacs.html
- Size: 221 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
# -*- lexical-binding: t; -*-
* Google Calendar Utilities for Emacs
** Settings on Google server1. Access Google Cloud Console ( https://console.cloud.google.com/cloud-resource-manager ).
2. Create a Project.
3. Enable Google Calendar API.
4. Create a OAuth Client ID (Choose *"Desktop"* type and Download client ID and client secret).
5. Change publishing status to *"In production"* in OAuth Consent Screen.** gcal.el
Settings:
#+BEGIN_SRC elisp
;; Get from Google Developer Console
(setq gcal-client-id "xxxxxxxxx.apps.googleusercontent.com")
(setq gcal-client-secret "xxxx-XxxxXxxXXXxx") ;;API-KEY
#+END_SRCUsege:
#+BEGIN_SRC elisp
(require 'gcal);; list my calendars
(gcal-calendar-list-list) ;; Calendar List;; list events
(gcal-events-list
"[email protected]" ;; Calendar ID
`((timeMin . ,(gcal-datetime 2016 5 1))
(timeMax . ,(gcal-datetime 2016 6 1))));; insert event
(gcal-events-insert
"[email protected]"
`((start . ,(gcal-gtime 2016 5 27))
(end . ,(gcal-gtime 2016 5 28))
(summary . "My Special Holiday")));; delete event
(gcal-events-delete "[email protected]" "{event id}")
#+END_SRC** gcal-org.el
Usage:
#+BEGIN_SRC elisp
(require 'gcal-org);; Org to Google Calendar
(gcal-org-push-file
"[email protected]" ;; Calendar ID
"~/my-schedule.org" ;; Org file
"~/my-schedule.gcal-cache") ;; Cache file (If omitted, use the global cache file ~/.emacs.d/.gcal-org-pushed-events);; Google Calendar to Org
(gcal-org-pull-to-file
"[email protected]"
"~/my-schedule.org"
"Inbox"
"~/my-schedule.gcal-cache")
#+END_SRCParse org & Upload
#+BEGIN_SRC elisp
;; Org to oevent(org-mode event)
(gcal-org-parse-buffer) ;; Parse current buffer. Return a list of gcal-org-event object(including properties :id, :ord, :summary, :location, :ts-start, :ts-end, :ts-prefx, ...).(gcal-org-parse-file "~/my-schedule.org") ;; Parse specified org file.
;; Upload oevents to Google Calendar
(gcal-org-push-oevents
"[email protected]"
(gcal-org-parse-file "~/my-schedule.org")
nil);; Upload oevents to Google Calendar (delta)
(gcal-org-push-oevents
"[email protected]"
(gcal-org-parse-file "~/my-schedule.org")
(gcal-org-parse-file "~/my-schedule.org.old"));; Delete events from Google Calendar
(gcal-org-push-oevents
"[email protected]"
nil
(gcal-org-parse-file "~/my-schedule.org"))#+END_SRC
Download
#+BEGIN_SRC elisp
;; Download oevents from Goole Calendar
(gcal-org-pull-oevents
"[email protected]"
`((timeMin . ,(gcal-time-format (current-time) nil)))) ;;after current time
#+END_SRC** Asynchronous execution
#+begin_src elisp
(gcal-http-async ;; or -sync
(gcal-async-let ((calendars (gcal-calendar-list-list)))
(message "number of items: %s" (length (alist-get 'items calendars)))))
#+end_src#+begin_src elisp
(gcal-http-async
(gcal-async-let* ((calendars (gcal-calendar-list-list)) ;; If you call an async function, it must be the last in the expression.
(calendar-id (alist-get 'id (elt (alist-get 'items calendars)
5))) ;; It is also possible to not include async functions.
(events (gcal-events-list calendar-id
`((timeMin . ,(gcal-datetime 2024 2 1))
(timeMax . ,(gcal-datetime 2024 3 1))))))
(message "events=%s" events)))
#+end_src#+begin_src elisp
(gcal-http-async
(let ((event-list .....)
(calendar-id ".......")
response-list)
(gcal-async-wait-all
;; Inside this, multiple asynchronous functions are executed.
(dolist (event-data event-list)
(gcal-async-let ((response (gcal-events-insert calendar-id event-data)))
(push response response-list)))
;; Called when everything is complete.
(if (seq-some #'gcal-failed-p response-list)
(message "Looks like something went wrong.")
(message "It seems to have finished without any problems.")))))
#+end_src** Documents
- [[http://misohena.jp/blog/2016-05-26-access-google-calendar-api-from-emacs.html][About gcal.el]]
- [[http://misohena.jp/blog/2016-05-29-sync-events-between-google-calendar-and-org-mode.html][About gcal-org.el]]