From c8a7005a22fc8c4cb023e921239ef321248e8e21 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 1 Jun 2018 15:36:14 +0200 Subject: [PATCH] app/twitter: decouple from feature/workspaces --- modules/app/twitter/autoload.el | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/app/twitter/autoload.el b/modules/app/twitter/autoload.el index 97e23eb02..1214c0537 100644 --- a/modules/app/twitter/autoload.el +++ b/modules/app/twitter/autoload.el @@ -1,5 +1,8 @@ ;;; app/twitter/autoload.el -*- lexical-binding: t; -*- +(defvar +twitter-workspace-name "*Twitter*" + "The name to use for the twitter workspace.") + ;;;###autoload (defun +twitter-display-buffer (buf) "A replacement display-buffer command for `twittering-pop-to-buffer-function' @@ -20,13 +23,18 @@ that works with the feature/popup module." ;; Commands ;; +(defvar +twitter--old-wconf nil) ;;;###autoload -(defun =twitter () +(defun =twitter (arg) "Opens a workspace dedicated to `twittering-mode'." - (interactive) + (interactive "P") (condition-case _ (progn - (+workspace/new "*Twitter*") + (if (and (not arg) (featurep! :feature workspaces)) + (+workspace/new +twitter-workspace-name) + (setq +twitter--old-wconf (current-window-configuration)) + (delete-other-windows) + (switch-to-buffer (doom-fallback-buffer))) (call-interactively #'twit) (unless (get-buffer (car twittering-initial-timeline-spec-string)) (error "Failed to open twitter")) @@ -44,13 +52,20 @@ that works with the feature/popup module." (interactive) (when (eq major-mode 'twittering-mode) (twittering-kill-buffer) - (+workspace/close-window-or-workspace))) + (cond ((one-window-p) (+twitter/quit-all)) + ((featurep! :feature workspaces) + (+workspace/close-window-or-workspace)) + ((delete-window))))) ;;;###autoload (defun +twitter/quit-all () "Close all open `twitter-mode' buffers and the associated workspace, if any." (interactive) - (+workspace/delete "*Twitter*") + (when (featurep! :feature workspaces) + (+workspace/delete +twitter-workspace-name)) + (when +twitter--old-wconf + (set-window-configuration +twitter--old-wconf) + (setq +twitter--old-wconf nil)) (dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list) t)) (twittering-kill-buffer buf)))