2018-02-18 03:10:09 -05:00
|
|
|
;;; app/calendar/autoload.el -*- lexical-binding: t; -*-
|
2018-01-13 17:26:40 +08:00
|
|
|
|
2018-04-02 05:49:55 -04:00
|
|
|
(defvar +calendar--wconf nil)
|
|
|
|
|
|
|
|
(defun +calendar--init ()
|
|
|
|
(if-let* ((win (cl-loop for win in (doom-visible-windows)
|
2018-04-04 01:05:20 -04:00
|
|
|
if (string-match-p "^\\*cfw:" (buffer-name (window-buffer win)))
|
2018-04-02 05:49:55 -04:00
|
|
|
return win)))
|
|
|
|
(select-window win)
|
|
|
|
(call-interactively +calendar-open-function)))
|
|
|
|
|
2018-01-13 17:26:40 +08:00
|
|
|
;;;###autoload
|
|
|
|
(defun =calendar ()
|
|
|
|
"Activate (or switch to) `calendar' in its workspace."
|
|
|
|
(interactive)
|
2018-04-02 05:49:55 -04:00
|
|
|
(if (featurep! :feature workspaces)
|
|
|
|
(progn
|
|
|
|
(+workspace-switch "Calendar" t)
|
2019-03-30 11:19:40 +01:00
|
|
|
(doom/switch-to-scratch-buffer)
|
2018-04-02 05:49:55 -04:00
|
|
|
(+calendar--init)
|
|
|
|
(+workspace/display))
|
|
|
|
(setq +calendar--wconf (current-window-configuration))
|
|
|
|
(delete-other-windows)
|
2019-04-19 19:54:14 -04:00
|
|
|
(switch-to-buffer (doom-fallback-buffer))
|
2018-04-02 05:49:55 -04:00
|
|
|
(+calendar--init)))
|
2018-01-13 17:26:40 +08:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +calendar/quit ()
|
2018-02-19 15:18:36 -05:00
|
|
|
"TODO"
|
2018-01-13 17:26:40 +08:00
|
|
|
(interactive)
|
2018-04-02 05:49:55 -04:00
|
|
|
(if (featurep! :feature workspaces)
|
|
|
|
(+workspace/delete "Calendar")
|
|
|
|
(doom-kill-matching-buffers "^\\*cfw:")
|
|
|
|
(set-window-configuration +calendar--wconf)
|
|
|
|
(setq +calendar--wconf nil)))
|
2018-01-13 17:26:40 +08:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +calendar/open-calendar ()
|
2018-02-19 15:18:36 -05:00
|
|
|
"TODO"
|
2018-01-13 17:26:40 +08:00
|
|
|
(interactive)
|
|
|
|
(cfw:open-calendar-buffer
|
|
|
|
;; :custom-map cfw:my-cal-map
|
|
|
|
:contents-sources
|
|
|
|
(list
|
|
|
|
(cfw:org-create-source (doom-color 'fg)) ; orgmode source
|
|
|
|
)))
|
|
|
|
|
2018-02-19 15:18:36 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun +calendar*cfw:render-button (title command &optional state)
|
2018-04-02 05:50:07 -04:00
|
|
|
"render-button
|
2018-02-19 15:18:36 -05:00
|
|
|
TITLE
|
|
|
|
COMMAND
|
|
|
|
STATE"
|
2018-04-02 05:50:07 -04:00
|
|
|
(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))
|