From 1c7526b2d797beb6f66d155656eb33f93911c943 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Thu, 11 Jul 2024 19:27:28 +0800 Subject: [PATCH] feat: don't delete shell/term windows via C-g --- lisp/init-window.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/init-window.el b/lisp/init-window.el index 40122902c..afb1983f0 100644 --- a/lisp/init-window.el +++ b/lisp/init-window.el @@ -239,10 +239,16 @@ "Close popper window via `C-g'." ;; `C-g' can deactivate region (when (and ;(called-interactively-p 'interactive) - (not (region-active-p)) - popper-open-popup-alist) - (let ((window (caar popper-open-popup-alist))) - (when (window-live-p window) + (not (region-active-p)) + popper-open-popup-alist) + (when-let ((window (caar popper-open-popup-alist)) + (buffer (cdar popper-open-popup-alist))) + (when (and (with-current-buffer buffer + (not (derived-mode-p 'eshell-mode + 'shell-mode + 'term-mode + 'vterm-mode))) + (window-live-p window)) (delete-window window))))) (advice-add #'keyboard-quit :before #'popper-close-window-hack)))