From 86777c54f341e3a0921c0970a4ed3fb99753e66d Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Thu, 21 Jul 2016 13:02:07 +0800 Subject: [PATCH] Improve the performance of workspace creation * exwm-workspace.el (exwm-workspace--add-frame-as-workspace): Do not run `exwm-workspace-list-change-hook' when create workspace in the background. (exwm-workspace-switch-create): Run the hook once. (exwm-workspace--prompt-add): Run the hook. --- exwm-workspace.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/exwm-workspace.el b/exwm-workspace.el index 2ff5e0c..b3c2390 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -110,14 +110,17 @@ NIL if FRAME is not a workspace" (defvar exwm-workspace--prompt-delete-allowed nil "Non-nil to allow deleting workspace from the prompt") (defvar exwm-workspace--create-silently nil - "When non-nil workspaces are created in the background (not switched to).") + "When non-nil workspaces are created in the background (not switched to). + +Please manually run the hook `exwm-workspace-list-change-hook' afterwards.") (defun exwm-workspace--prompt-add () "Add workspace from the prompt." (interactive) (when exwm-workspace--prompt-add-allowed (let ((exwm-workspace--create-silently t)) - (make-frame)) + (make-frame) + (run-hooks 'exwm-workspace-list-change-hook)) (exwm-workspace--update-switch-history) (goto-history-element minibuffer-history-position))) @@ -507,7 +510,8 @@ each time.") (dotimes (_ (min exwm-workspace-switch-create-limit (1+ (- frame-or-index (exwm-workspace--count))))) - (make-frame))) + (make-frame)) + (run-hooks 'exwm-workspace-list-change-hook)) (exwm-workspace-switch (car (last exwm-workspace--list))))) (defvar exwm-workspace-list-change-hook nil @@ -1174,8 +1178,8 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (exwm-workspace--update-ewmh-props) (if exwm-workspace--create-silently (setq exwm-workspace--switch-history-outdated t) - (exwm-workspace-switch frame t)) - (run-hooks 'exwm-workspace-list-change-hook)))) + (exwm-workspace-switch frame t) + (run-hooks 'exwm-workspace-list-change-hook))))) (defun exwm-workspace--remove-frame-as-workspace (frame) "Stop treating frame FRAME as a workspace."