From 7933e54542d4a7c0ff58b8cc1bba7cb1f10deaae Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Tue, 21 Sep 2021 14:57:00 +0300 Subject: [PATCH] refactor!(:term): toggle commands now always hide BREAKING CHANGE: previously, o t commands would only hide the terminal popup if it was focused. If not, they would move the focus to the terminal window. This is unintuitive to the "toggle" description, and arguably less useful, since refocusing to the terminal can be easily done with regular window refocus commands. Therefore, o t now just hides the terminal popup. Fix #3374 --- modules/term/eshell/autoload/eshell.el | 11 +++-------- modules/term/shell/autoload.el | 13 ++++--------- modules/term/term/autoload.el | 7 +------ modules/term/vterm/autoload.el | 7 +------ 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/modules/term/eshell/autoload/eshell.el b/modules/term/eshell/autoload/eshell.el index b9d183332..c14519286 100644 --- a/modules/term/eshell/autoload/eshell.el +++ b/modules/term/eshell/autoload/eshell.el @@ -99,14 +99,9 @@ (fundamental-mode) (erase-buffer)))) (if-let (win (get-buffer-window eshell-buffer)) - (if (eq (selected-window) win) - (let (confirm-kill-processes) - (delete-window win) - (ignore-errors (kill-buffer eshell-buffer))) - (select-window win) - (when (bound-and-true-p evil-local-mode) - (evil-change-to-initial-state)) - (goto-char (point-max))) + (let (confirm-kill-processes) + (delete-window win) + (ignore-errors (kill-buffer eshell-buffer))) (with-current-buffer (pop-to-buffer eshell-buffer) (doom-mark-buffer-as-real-h) (if (eq major-mode 'eshell-mode) diff --git a/modules/term/shell/autoload.el b/modules/term/shell/autoload.el index 47dca9372..c6fdd8171 100644 --- a/modules/term/shell/autoload.el +++ b/modules/term/shell/autoload.el @@ -69,15 +69,10 @@ If popup is focused, kill it." "main")))) (dir default-directory)) (if-let (win (get-buffer-window buffer)) - (if (eq (selected-window) win) - (let (confirm-kill-processes) - (set-process-query-on-exit-flag (get-buffer-process buffer) nil) - (delete-window win) - (ignore-errors (kill-buffer buffer))) - (select-window win) - (when (bound-and-true-p evil-local-mode) - (evil-change-to-initial-state)) - (goto-char (point-max))) + (let (confirm-kill-processes) + (set-process-query-on-exit-flag (get-buffer-process buffer) nil) + (delete-window win) + (ignore-errors (kill-buffer buffer))) (with-current-buffer (pop-to-buffer buffer) (if (not (eq major-mode 'shell-mode)) (shell buffer) diff --git a/modules/term/term/autoload.el b/modules/term/term/autoload.el index 27219fba6..94d3b51e8 100644 --- a/modules/term/term/autoload.el +++ b/modules/term/term/autoload.el @@ -28,12 +28,7 @@ If prefix ARG, recreate the term buffer." (setq buffer (multi-term-get-buffer nil t))) ; recreates buffer (if (and (window-live-p window) (buffer-live-p buffer)) - (if (eq (selected-window) window) - (delete-window window) - (select-window window) - (when (bound-and-true-p evil-local-mode) - (evil-change-to-initial-state)) - (goto-char (point-max))) + (delete-window window) (setenv "PROOT" (or (doom-project-root) default-directory)) (with-current-buffer buffer (doom-mark-buffer-as-real-h) diff --git a/modules/term/vterm/autoload.el b/modules/term/vterm/autoload.el index 1804935ab..7467c04de 100644 --- a/modules/term/vterm/autoload.el +++ b/modules/term/vterm/autoload.el @@ -26,12 +26,7 @@ Returns the vterm buffer." (when (window-live-p window) (delete-window window)))) (if-let (win (get-buffer-window buffer-name)) - (if (eq (selected-window) win) - (delete-window win) - (select-window win) - (when (bound-and-true-p evil-local-mode) - (evil-change-to-initial-state)) - (goto-char (point-max))) + (delete-window win) (let ((buffer (get-buffer-create buffer-name))) (with-current-buffer buffer (unless (eq major-mode 'vterm-mode)