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)
|
2022-08-31 14:33:08 -04:00
|
|
|
(defvar +calendar-workspace-name "*calendar*"
|
2022-08-31 15:16:20 -04:00
|
|
|
"Name of the workspace created by `=calendar', dedicated to calfw.")
|
2018-04-02 05:49:55 -04:00
|
|
|
|
|
|
|
(defun +calendar--init ()
|
2020-02-02 02:05:20 -05:00
|
|
|
(if-let (win (cl-find-if (lambda (b) (string-match-p "^\\*cfw:" (buffer-name b)))
|
|
|
|
(doom-visible-windows)
|
|
|
|
:key #'window-buffer))
|
2018-04-02 05:49:55 -04:00
|
|
|
(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)
|
2022-08-12 20:29:19 +02:00
|
|
|
(if (modulep! :ui workspaces)
|
2018-04-02 05:49:55 -04:00
|
|
|
(progn
|
2022-08-31 14:33:08 -04:00
|
|
|
(+workspace-switch +calendar-workspace-name t)
|
2022-08-31 14:35:59 -04:00
|
|
|
(unless (memq (buffer-local-value 'major-mode
|
|
|
|
(window-buffer (selected-window)))
|
|
|
|
'(cfw:details-mode
|
|
|
|
cfw:calendar-mode))
|
|
|
|
(doom/switch-to-scratch-buffer)
|
|
|
|
(+calendar--init))
|
2018-04-02 05:49:55 -04:00
|
|
|
(+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)
|
2022-08-12 20:29:19 +02:00
|
|
|
(if (modulep! :ui workspaces)
|
2022-08-31 14:33:08 -04:00
|
|
|
(when (+workspace-exists-p +calendar-workspace-name)
|
|
|
|
(+workspace/delete +calendar-workspace-name))
|
2020-10-12 03:37:08 -04:00
|
|
|
(when (window-configuration-p +calendar--wconf)
|
|
|
|
(set-window-configuration +calendar--wconf))
|
2021-03-06 00:07:12 -05:00
|
|
|
(setq +calendar--wconf nil))
|
|
|
|
(doom-kill-matching-buffers "^\\*cfw[:-]"))
|
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
|
2019-05-20 16:41:58 -04:00
|
|
|
(cfw:org-create-source (face-foreground 'default)) ; orgmode source
|
2018-01-13 17:26:40 +08:00
|
|
|
)))
|
|
|
|
|
2018-02-19 15:18:36 -05:00
|
|
|
;;;###autoload
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +calendar-cfw:render-button-a (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))
|