Save gcal org buffers after fetch

This commit is contained in:
Jeremy Dormitzer 2020-04-02 18:14:59 -04:00
parent 4e9ec5f5b6
commit 0c2b5aaffc

View File

@ -1859,12 +1859,22 @@ Integrate Google calendar with org-mode:
("lut2o2moohg6qkdsto1qfq7th4@group.calendar.google.com" . ,(get-calendar-file "j-n-gcal.org"))) ("lut2o2moohg6qkdsto1qfq7th4@group.calendar.google.com" . ,(get-calendar-file "j-n-gcal.org")))
org-gcal-notify-p nil)) org-gcal-notify-p nil))
(add-hook 'emacs-startup-hook #'org-gcal-fetch) (defun org-gcal-fetch-and-save ()
(interactive)
(deferred:$
(org-gcal-fetch)
(deferred:nextc it
(lambda ()
(dolist (entry org-gcal-file-alist)
(with-current-buffer (cdr entry)
(save-buffer)))))))
(add-hook 'emacs-startup-hook #'org-gcal-fetch-and-save)
(defun org-agenda-redo-and-fetch-gcal (&optional all) (defun org-agenda-redo-and-fetch-gcal (&optional all)
(interactive "P") (interactive "P")
(let ((cb (if all #'org-agenda-redo-all #'org-agenda-redo))) (let ((cb (if all #'org-agenda-redo-all #'org-agenda-redo)))
(deferred:nextc (org-gcal-fetch) cb))) (deferred:nextc (org-gcal-fetch-and-save) cb)))
(with-eval-after-load 'org-agenda (with-eval-after-load 'org-agenda
(general-def '(normal motion) org-agenda-mode-map "gR" #'org-agenda-redo-and-fetch-gcal)) (general-def '(normal motion) org-agenda-mode-map "gR" #'org-agenda-redo-and-fetch-gcal))