Add: =calendar app

This commit is contained in:
fuxialexander 2018-01-13 17:26:40 +08:00
parent 8785664267
commit c63aba39ac
4 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,29 @@
;;; private/calendar/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun =calendar ()
"Activate (or switch to) `calendar' in its workspace."
(interactive)
(unless (featurep! :feature workspaces)
(user-error ":feature workspaces is required, but disabled"))
(+workspace-switch "Calendar" t)
(if-let* ((buf (cl-find-if (lambda (it) (string-match-p "^\\*cfw" (buffer-name (window-buffer it))))
(doom-visible-windows))))
(select-window (get-buffer-window buf)) (call-interactively '+calendar-open-calendar-function))
(+workspace/display))
;;;###autoload
(defun +calendar/quit ()
(interactive)
(+workspace/delete "Calendar"))
;;;###autoload
(defun +calendar/open-calendar ()
(interactive)
(cfw:open-calendar-buffer
;; :custom-map cfw:my-cal-map
:contents-sources
(list
(cfw:org-create-source (doom-color 'fg)) ; orgmode source
)))

View file

@ -0,0 +1,57 @@
;;; private/calendar/config.el -*- lexical-binding: t; -*-
(defvar +calendar-org-gcal-secret-file "~/.emacs.d/modules/private/org/secret.el")
(defvar +calendar-open-calendar-function '+calendar/open-calendar)
(def-package! calfw
:commands (cfw:open-calendar-buffer)
:config
;; better frame for calendar
(setq
cfw:face-item-separator-color nil
cfw:fchar-junction ?╋
cfw:fchar-vertical-line ?┃
cfw:fchar-horizontal-line ?━
cfw:fchar-left-junction ?┣
cfw:fchar-right-junction ?┫
cfw:fchar-top-junction ?┯
cfw:fchar-top-left-corner ?┏
cfw:fchar-top-right-corner ?┓)
(defun cfw:render-button (title command &optional state)
"render-button
TITLE
COMMAND
STATE"
(let ((text (concat " " title " "))
(keymap (make-sparse-keymap)))
(cfw:rt text (if state 'cfw:face-toolbar-button-on
'cfw:face-toolbar-button-off))
(define-key keymap [mouse-1] command)
(cfw:tp text 'keymap keymap)
(cfw:tp text 'mouse-face 'highlight)
text))
(add-hook! 'cfw:calendar-mode-hook (solaire-mode +1)
(doom-hide-modeline-mode)))
(def-package! calfw-org
:commands (cfw:open-org-calendar
cfw:org-create-source
cfw:open-org-calendar-withkevin
my-open-calendar))
(def-package! org-gcal
:commands (org-gcal-sync
org-gcal-fetch
org-gcal-post-at-point
org-gcal-delete-at-point)
:config
(load-file '+calendar-org-gcal-secret-file)
;; hack to avoid the deferred.el error
(defun org-gcal--notify (title mes)
(message "org-gcal::%s - %s" title mes)))
;; (def-package! alert)

View file

@ -0,0 +1,7 @@
;; -*- no-byte-compile: t; -*-
;;; private/calendar/packages.el
(package! calfw)
(package! calfw-org)
(package! org-gcal)

View file

@ -0,0 +1,71 @@
#+TITLE: `=Calendar App`
* Setup sync between google calendar and org file
:PROPERTIES:
:ID: 5E190E8A-CA26-4679-B5F8-BF9CFD289271
:END:
- Checkout https://github.com/myuhe/org-gcal.el, put the following content in a file ~secret.el~ and set the variable `+calendar-org-gcal-secret-file` to the path of that file.
#+BEGIN_SRC emacs-lisp
(setq org-gcal-client-id "your-id-foo.apps.googleusercontent.com"
org-gcal-client-secret "your-secret"
org-gcal-file-alist '(("your-mail@gmail.com" . "~/schedule.org")
("another-mail@gmail.com" . "~/task.org")))
#+END_SRC
* Doom faces
:PROPERTIES:
:ID: 8223894E-EA68-4259-A2EA-AF7E3653C610
:END:
I'm using the following setting:
#+BEGIN_SRC emacs-lisp
;; calfw
(cfw:face-title :foreground blue :bold bold :height 2.0 :inherit 'variable-pitch)
(cfw:face-header :foreground (doom-blend blue bg 0.8) :bold bold)
(cfw:face-sunday :foreground (doom-blend red bg 0.8) :bold bold)
(cfw:face-saturday :foreground (doom-blend red bg 0.8) :bold bold)
(cfw:face-holiday :foreground nil :background bg-alt :bold bold)
(cfw:face-grid :foreground vertical-bar)
(cfw:face-periods :foreground yellow)
(cfw:face-toolbar :foreground nil :background nil)
(cfw:face-toolbar-button-off :foreground base6 :bold bold :inherit 'variable-pitch)
(cfw:face-toolbar-button-on :foreground blue :bold bold :inherit 'variable-pitch)
(cfw:face-default-content :foreground fg)
(cfw:face-day-title :foreground fg :bold bold)
(cfw:face-today-title :foreground bg :background blue :bold bold)
(cfw:face-default-day :bold bold)
(cfw:face-today :foreground nil :background nil :bold bold)
(cfw:face-annotation :foreground violet)
(cfw:face-disable :foreground grey)
(cfw:face-select :background region)
#+END_SRC
* Adjust calendar to be included
:PROPERTIES:
:ID: D734975C-4B49-4F66-A088-AB2707A77537
:END:
Checkout example from https://github.com/kiwanami/emacs-calfw
#+BEGIN_SRC emacs-lisp
(defun my-open-calendar ()
(interactive)
(cfw:open-calendar-buffer
:contents-sources
(list
(cfw:org-create-source "Green") ; orgmode source
(cfw:howm-create-source "Blue") ; howm source
(cfw:cal-create-source "Orange") ; diary source
(cfw:ical-create-source "Moon" "~/moon.ics" "Gray") ; ICS source1
(cfw:ical-create-source "gcal" "https://..../basic.ics" "IndianRed") ; google calendar ICS
)))
#+END_SRC
Specifically, if you want to adjust the org files to be included, use a ~let~ binding to set the ~org-agenda-files~ like below:
#+BEGIN_SRC emacs-lisp
;;;###autoload
(defun cfw:open-org-calendar-with-cal1 ()
(interactive)
(let ((org-agenda-files '("/path/to/org/" "/path/to/cal1.org")))
(call-interactively '+calendar/open-calendar)))
;;;###autoload
(defun cfw:open-org-calendar-with-cal2 ()
(interactive)
(let ((org-agenda-files '("/path/to/org/" "/path/to/cal2.org")))
(call-interactively '+calendar/open-calendar)))
#+END_SRC