From f6f2c9237320a4f1e8e9966bd1ccc4119fd3dd0f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 2 Apr 2018 05:49:55 -0400 Subject: [PATCH] app/calendar: don't require :feature workspaces --- modules/app/calendar/autoload.el | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/modules/app/calendar/autoload.el b/modules/app/calendar/autoload.el index 7d906c4cb..1f0348809 100644 --- a/modules/app/calendar/autoload.el +++ b/modules/app/calendar/autoload.el @@ -1,24 +1,36 @@ ;;; app/calendar/autoload.el -*- lexical-binding: t; -*- +(defvar +calendar--wconf nil) + +(defun +calendar--init () + (if-let* ((win (cl-loop for win in (doom-visible-windows) + if (string-match-p "^\\*cfw:" (buffer-name (window-buffer it))) + return win))) + (select-window win) + (call-interactively +calendar-open-function))) + ;;;###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* ((win (cl-loop for win in (doom-visible-windows) - if (string-match-p "^\\*cfw" (buffer-name (window-buffer it))) - return win))) - (select-window win) - (call-interactively +calendar-open-function)) - (+workspace/display)) + (if (featurep! :feature workspaces) + (progn + (+workspace-switch "Calendar" t) + (+calendar--init) + (+workspace/display)) + (setq +calendar--wconf (current-window-configuration)) + (delete-other-windows) + (+calendar--init))) ;;;###autoload (defun +calendar/quit () "TODO" (interactive) - (+workspace/delete "Calendar")) + (if (featurep! :feature workspaces) + (+workspace/delete "Calendar") + (doom-kill-matching-buffers "^\\*cfw:") + (set-window-configuration +calendar--wconf) + (setq +calendar--wconf nil))) ;;;###autoload (defun +calendar/open-calendar ()