tools/eshell: fix parameters being set on the wrong window
This would cause find-file commands to ignore certain windows, as well as eshell buffers closing the incorrect window when they are quit. Addresses #593
This commit is contained in:
parent
80adb9c1f6
commit
8807471846
1 changed files with 21 additions and 18 deletions
|
@ -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))
|
||||
(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))))
|
||||
((delete (current-buffer) (get-buffer-window-list))
|
||||
(delete-window))))
|
||||
((and (fboundp '+popup-window-p) (+popup-window-p))
|
||||
(delete-window))))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue