Added layer for synchronizing google-calendars to emacs#8372
Conversation
nixmaniack
left a comment
There was a problem hiding this comment.
This is great. I have been using org-gcal and calfw and it's nice to see it coming in spacemacs.
Can you add screenshot of how it looks? It'll give this PR more visibility.
I will try it later and provide more feedback.
|
|
||
| (defun google-calendar/init-f () | ||
| "Initialize f" | ||
| (use-package f)) |
There was a problem hiding this comment.
Spacemacs already has dependency on f. This shouldn't be needed.
There was a problem hiding this comment.
I was not sure whenever f came with emacs or was provided in some package or layer. I am removing it.
| "Initialize alert" | ||
| (use-package alert | ||
| :init | ||
| (setq alert-default-style 'notifications))) |
There was a problem hiding this comment.
Is it required to set it? Since this is platform dependant it'd be better to let user select notification style(or we detect and set up a sane one).
Also there are other packages/layers(slace layer, mu4e-alert) which are setting alert-default-style and I think it's time to consolidate effort to setup alert properly.
There was a problem hiding this comment.
You are correct, I just tested it and you are not required to set alert-default-style. I am removing it.
aaronjensen
left a comment
There was a problem hiding this comment.
This is looking great, nice work. It'll be nice to be able to remove my custom code for this.
| "ags" 'org-gcal-sync | ||
| "agf" 'org-gcal-fetch)) | ||
| :config | ||
| (setq org-gcal-down-days 365) ;; Set org-gcal to download events a year in advance |
There was a problem hiding this comment.
I probably wouldn't want this as the default. Maybe this can just be documented as something that can change.
There was a problem hiding this comment.
What is the default without that ?
There was a problem hiding this comment.
Yes, it should be kept default - 365 is too big!
There was a problem hiding this comment.
I agree. Ill restore the default value and add it to the documentation
| :config | ||
| (setq org-gcal-down-days 365) ;; Set org-gcal to download events a year in advance | ||
| (add-hook 'after-init-hook 'org-gcal-fetch) | ||
| (add-hook 'kill-emacs-hook 'org-gcal-sync) |
There was a problem hiding this comment.
I believe this is an asynchronous operation. Does this actually do anything if emacs is being killed immediately? I know it's a last ditch attempt to get calendar entries up, but it'd be surprising if it worked.
| (add-hook 'after-init-hook 'org-gcal-fetch) | ||
| (add-hook 'kill-emacs-hook 'org-gcal-sync) | ||
| (add-hook 'org-capture-after-finalize-hook 'google-calendar/sync-cal-after-capture) | ||
| (run-with-idle-timer 600 t 'google-calendar/org-gcal-update))) |
There was a problem hiding this comment.
With this, there's no way for the calendar to update while emacs is in use throughout the day. org-gcal-fetch is not super disruptive, so I configured my emacs to create a a much shorter idle timer every 10 minutes or so. That way it tries to sync every 10 minutes if emacs is idle for, say, 30 seconds. That way you probably won't have your typing interrupted, but it'd still update while you're using emacs normally. The code to do that is here: https://github.com/aaronjensen/spacemacs.d/blob/fc69c4a1e643ad276268a2409fc736b28ee2ae14/lisp/init-org.el#L71-L106 (probably can be cleaned up a bit, but you get the idea)
| "* %^{Description}\n%^{LOCATION}p\n%(cfw:org-capture-day)\n%?")) | ||
| #+END_SRC | ||
|
|
||
| ** Configure alert |
There was a problem hiding this comment.
It was unclear to me what these alerts were for. It seems that they're status messages from the org-gcal sync/fetch, which is not what I would have expected (I would have expected that they were calendar remindrs). AFAICT the only way to get those is with org-agenda-to-appt. Maybe it'd be worth integrating that as well? See here
There was a problem hiding this comment.
I previously removed the alert dependency since I came to the same discovery as you. This reference in the README is just remnants from that.
Good point with org-agenda-to-appt. I don't have time to work on integrate it at the moment so I dont think it should be part of this PR.
| @@ -0,0 +1,166 @@ | |||
| #+TITLE: Google calendar layer | |||
There was a problem hiding this comment.
Would it make sense to have this be the general calendar layer and have org-gcal support just be optional (if a var is set, for example)
There was a problem hiding this comment.
Depends if there are reliable packages that provides synchronization with other popular calendar services. Non Google calendar users could just exclude org-gcal in their dotfile and only use calfw.
| "Initializes org-gcal and adds keybindings for it's exposed functions" | ||
| (use-package org-gcal | ||
| :init | ||
| (progn |
There was a problem hiding this comment.
There's a bug in org-gcal that can cause it to choke on events that are private (Say you share your work calendar with your personal account and your work calendar has something marked private).
This will work around it until it is fixed in org-gcal and may be worth including in this layer:
(push (lambda (event) (plist-get event :summary)) org-gcal-fetch-event-filters)
| "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))))) |
There was a problem hiding this comment.
This creates an error if the file in the org-capture-template is a variable (for example, (file org-default-notes-file))
robbyoconnor
left a comment
There was a problem hiding this comment.
Fix the CI failure: https://travis-ci.org/syl20bnr/spacemacs/jobs/234724860
|
@mkhc do you think you'd be able to complete this soon? id love to use it! |
|
@Voleking -- step 1) use a topic branch; step 2) fix the issues that travis is reporting. With regard to the other issues....don't know |
|
@Voleking - Reporting at upstream might be a better idea. |
|
Just poking my head in here. Does anyone know what the status of this layer is? |
|
@mhkc, do you have this hosted somewhere that I can clone and use it as a private layer? Edit: Nevermind, I found it. |
The layer handles synchronization through org-gcal. It also adds an additional calendar view through calfw. It can be run stand alone but integrates nicely with org-mode.
|
It would be awesome if this is pushed to the develop branch. |
|
This looks cool, however I have noticed that some of the packages are pretty old, can someone have a short test and confirm that the current google apis are still working with this layer? If it does I would volunteer to see what needs to be done to get this integrated into develop somewhere. |
|
I have tested this layer on Ubuntu 20.04 Everything works as expected so far. I had previously setup org-gcal Only minor change needed is inclusion of the calfw-org package as discussed here mhkc/google-calendar-layer#8 Original PR has archived his repo. I have a forked version here, ready to test: https://github.com/HanshenWang/google-calendar-layer Where I've gone through the issues and PRs of the original and added minor fixups As it currently stands, I do believe it needs more testing before it can be Specifically how To be clear, on the whole I am very grateful for the work done already. I Calfw is a nicety, but useful enough that I am sticking with it. I do wonder how @maikol-solis Are you still using this layer? How does it work for you? |
|
@HanshenWang |
|
@lebensterben It would be better for someone else to carry this PR across the Cheers, |
|
Lets close this, we can have a new PR which is using a more up-to-date code base if this feature is still wished by enough people. |
|
I could take this on at some point and bring it up to date |
The layer handles synchronization through org-gcal. It also adds an additional
calendar view through calfw.
It can be run stand alone but integrates nicely with org-mode.
Solves feature request #7741
Screenshots
Monthly overview of calendar events and scheduled TODOs

Agenda view of what is scheduled for the day
