doomemacs/modules/app/calendar/autoload.el
Henrik Lissner 4186b63b38
fix(calendar): adapt to upstream refactor
A large scale refactor upstream renamed the cfw: prefix with calfw-.

Amend: 5222baa373
Fix: #8598
Ref: kiwanami/emacs-calfw@b7c26ecbe9
2025-12-04 14:02:06 -05:00

67 lines
2.1 KiB
EmacsLisp

;;; app/calendar/autoload.el -*- lexical-binding: t; -*-
(defvar +calendar--wconf nil)
(defvar +calendar-workspace-name "*calendar*"
"Name of the workspace created by `=calendar', dedicated to calfw.")
(defun +calendar--init ()
(if-let* ((win (get-buffer-window calfw-calendar-buffer-name)))
(select-window win)
(call-interactively +calendar-open-function)))
;;;###autoload
(defun =calendar ()
"Activate (or switch to) `calendar' in its workspace."
(interactive)
(if (modulep! :ui workspaces)
(progn
(+workspace-switch +calendar-workspace-name t)
(unless (memq (buffer-local-value 'major-mode
(window-buffer (selected-window)))
'(calfw-details-mode
calfw-calendar-mode))
(doom/switch-to-scratch-buffer)
(+calendar--init))
(+workspace/display))
(setq +calendar--wconf (current-window-configuration))
(delete-other-windows)
(switch-to-buffer (doom-fallback-buffer))
(+calendar--init)))
;;;###autoload
(defun +calendar/quit ()
"TODO"
(interactive)
(if (modulep! :ui workspaces)
(when (+workspace-exists-p +calendar-workspace-name)
(+workspace/kill +calendar-workspace-name))
(when (window-configuration-p +calendar--wconf)
(set-window-configuration +calendar--wconf))
(setq +calendar--wconf nil))
(doom-kill-matching-buffers "^\\*cfw[:-]"))
;;;###autoload
(defun +calendar/open-calendar ()
"TODO"
(interactive)
(calfw-open-calendar-buffer
;; :custom-map calfw-my-cal-map
:contents-sources
(list
(calfw-org-create-source (face-foreground 'default)) ; orgmode source
)))
;;;###autoload
(defun +calendar-calfw-render-button-a (title command &optional state)
"render-button
TITLE
COMMAND
STATE"
(let ((text (concat " " title " "))
(keymap (make-sparse-keymap)))
(calfw-rt text (if state 'calfw-face-toolbar-button-on
'calfw-face-toolbar-button-off))
(define-key keymap [mouse-1] command)
(calfw-tp text 'keymap keymap)
(calfw-tp text 'mouse-face 'highlight)
text))