diff --git a/modules/tools/eshell/autoload/eshell.el b/modules/tools/eshell/autoload/eshell.el index d9ceb085a..57da503c8 100644 --- a/modules/tools/eshell/autoload/eshell.el +++ b/modules/tools/eshell/autoload/eshell.el @@ -36,7 +36,8 @@ (defun +eshell--remove-buffer (buf) (when-let* ((idx (ring-member +eshell-buffers buf))) - (ring-remove +eshell-buffers idx))) + (ring-remove +eshell-buffers idx) + t)) (defun +eshell--current-git-branch () (let ((branch (car (cl-loop for match in (split-string (shell-command-to-string "git branch") "\n") @@ -54,6 +55,11 @@ return buf)) (generate-new-buffer +eshell-buffer-name))) +(defun +eshell--set-window (window &optional flag) + (when window + (set-window-parameter window 'no-other-window flag) + (set-window-parameter window 'visible flag))) + ;;;###autoload (defun +eshell-prompt () "Generate the prompt string for eshell. Use for `eshell-prompt-function'." @@ -72,6 +78,7 @@ (interactive) (let ((buf (+eshell--buffer (eq major-mode 'eshell-mode)))) (switch-to-buffer buf) + (+eshell--set-window (get-buffer-window buf) t) (with-current-buffer buf (unless (eq major-mode 'eshell-mode) (eshell-mode))) (when command @@ -85,6 +92,7 @@ (with-current-buffer buf (unless (eq major-mode 'eshell-mode) (eshell-mode))) (pop-to-buffer buf) + (+eshell--set-window (get-buffer-window buf) t) (when command (+eshell-run-command command)))) @@ -104,6 +112,7 @@ module to be loaded." (+eshell/open)) (when command (+eshell-run-command command)) + (+eshell--set-window (selected-window) t) (doom/workspace-display)) (defun +eshell-run-command (command) @@ -129,29 +138,23 @@ module to be loaded." (dolist (buf (ring-elements +eshell-buffers)) (unless (buffer-live-p buf) (+eshell--remove-buffer buf))) - (let ((window (selected-window))) - (set-window-parameter window 'no-other-window t) - (set-window-parameter window 'visible t) - (set-window-dedicated-p window t)) (+eshell--add-buffer buf) (setq +eshell-last-buffer buf))) ;;;###autoload (defun +eshell|cleanup () "Close window (or workspace) on quit." - (let ((window (selected-window))) - (set-window-parameter window 'no-other-window nil) - (set-window-parameter window 'visible t) - (set-window-dedicated-p window nil)) - (+eshell--remove-buffer (current-buffer)) - (cond ((and (featurep! :feature workspaces) - (string= "eshell" (+workspace-current-name))) - (+workspace/delete "eshell")) - ((one-window-p) - (unless (doom-real-buffer-p (progn (previous-buffer) (current-buffer))) - (switch-to-buffer (doom-fallback-buffer)))) - ((delete (current-buffer) (get-buffer-window-list)) - (delete-window)))) + (let ((buf (current-buffer))) + (when (+eshell--remove-buffer buf) + (+eshell--set-window (get-buffer-window buf) nil) + (cond ((and (featurep! :feature workspaces) + (string= "eshell" (+workspace-current-name))) + (+workspace/delete "eshell")) + ((one-window-p) + (unless (doom-real-buffer-p (progn (previous-buffer) (current-buffer))) + (switch-to-buffer (doom-fallback-buffer)))) + ((and (fboundp '+popup-window-p) (+popup-window-p)) + (delete-window)))))) ;;