Do not restrict shell buffer display to frame sides
Give buffers running ephemeral `eshell` or `shell` sessions a name that is different from the default name chosen by these commands, and only restrict those ephemeral shell buffers to be displayed at the side. This way, running the commands `eshell` and `shell` will yield windows can be handled like any others and can be used for long-running sessions.
This commit is contained in:
parent
5438a71cca
commit
f2f98c3ac5
4
init.el
4
init.el
@ -322,14 +322,14 @@
|
|||||||
;; Inspired by masteringemacs and
|
;; Inspired by masteringemacs and
|
||||||
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html
|
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html
|
||||||
(add-to-list 'display-buffer-alist
|
(add-to-list 'display-buffer-alist
|
||||||
'("^\\*eshell\\*"
|
'("^\\*eshell-side\\*"
|
||||||
display-buffer-in-side-window
|
display-buffer-in-side-window
|
||||||
(side . bottom)
|
(side . bottom)
|
||||||
(slot . -1)
|
(slot . -1)
|
||||||
(window-height . 0.33)
|
(window-height . 0.33)
|
||||||
(window-parameters . ((no-other-window . t)))))
|
(window-parameters . ((no-other-window . t)))))
|
||||||
(add-to-list 'display-buffer-alist
|
(add-to-list 'display-buffer-alist
|
||||||
'("^\\*shell\\*"
|
'("^\\*shell-side\\*"
|
||||||
display-buffer-in-side-window
|
display-buffer-in-side-window
|
||||||
(side . bottom)
|
(side . bottom)
|
||||||
(slot . 1)
|
(slot . 1)
|
||||||
|
|||||||
@ -26,17 +26,17 @@
|
|||||||
|
|
||||||
Otherwise moves the cursor to the window where we have been before.
|
Otherwise moves the cursor to the window where we have been before.
|
||||||
|
|
||||||
The buffer's name has to start with “*eshell*” to be recognized
|
The buffer's name has to start with “*eshell-side*” to be recognized by
|
||||||
by this function. Otherwise the current buffer is not treated as
|
this function. Otherwise the current buffer is not treated as an eshell
|
||||||
an eshell buffer.
|
buffer.
|
||||||
|
|
||||||
When ARG is given, change to `default-directory' after switching
|
When ARG is given, change to `default-directory' after switching to the
|
||||||
to the eshell buffer."
|
eshell buffer."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((current-dir (expand-file-name default-directory)))
|
(let ((current-dir (expand-file-name default-directory)))
|
||||||
(cl-flet ((in-eshell-buffer-p ()
|
(cl-flet ((in-eshell-buffer-p ()
|
||||||
(and (derived-mode-p 'eshell-mode)
|
(and (derived-mode-p 'eshell-mode)
|
||||||
(string-match-p "^\\*eshell\\*" (buffer-name)))))
|
(string-match-p "^\\*eshell-side\\*" (buffer-name)))))
|
||||||
|
|
||||||
(if (and (not arg)
|
(if (and (not arg)
|
||||||
(in-eshell-buffer-p))
|
(in-eshell-buffer-p))
|
||||||
@ -49,7 +49,7 @@ to the eshell buffer."
|
|||||||
(window-list-1))))
|
(window-list-1))))
|
||||||
(select-window eshell-window)
|
(select-window eshell-window)
|
||||||
;; No running eshell found, open new one.
|
;; No running eshell found, open new one.
|
||||||
(--if-let (display-buffer (eshell 1))
|
(--if-let (display-buffer (let ((eshell-buffer-name "*eshell-side*")) (eshell)))
|
||||||
(select-window it)
|
(select-window it)
|
||||||
(error "Could not start eshell (`display-buffer' returned nil)"))))
|
(error "Could not start eshell (`display-buffer' returned nil)"))))
|
||||||
|
|
||||||
|
|||||||
@ -75,9 +75,9 @@ If already in *ansi-term* buffer, bury it."
|
|||||||
|
|
||||||
Otherwise, closes the current shell window.
|
Otherwise, closes the current shell window.
|
||||||
|
|
||||||
The buffer's name has to start with “*shell*” to be recognized
|
The buffer's name has to start with “*shell-side*” to be recognized by
|
||||||
by this function. Otherwise the current buffer is not treated as
|
this function. Otherwise the current buffer is not treated as a shell
|
||||||
a shell buffer.
|
buffer.
|
||||||
|
|
||||||
With ARG, switch to `default-directory' of the current buffer first."
|
With ARG, switch to `default-directory' of the current buffer first."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
@ -85,16 +85,16 @@ With ARG, switch to `default-directory' of the current buffer first."
|
|||||||
(if-let ((shell-window (cl-find-if (lambda (window)
|
(if-let ((shell-window (cl-find-if (lambda (window)
|
||||||
(with-current-buffer (window-buffer window)
|
(with-current-buffer (window-buffer window)
|
||||||
(and (derived-mode-p 'shell-mode)
|
(and (derived-mode-p 'shell-mode)
|
||||||
(string-match-p "^\\*shell\\*" (buffer-name)))))
|
(string-match-p "^\\*shell-side\\*" (buffer-name)))))
|
||||||
(window-list-1))))
|
(window-list-1))))
|
||||||
(select-window shell-window)
|
(select-window shell-window)
|
||||||
(--if-let (display-buffer (shell))
|
(--if-let (display-buffer (shell (get-buffer-create "*shell-side*")))
|
||||||
(select-window it)
|
(select-window it)
|
||||||
(error "Could not start shell (`display-buffer' returned nil)")))))
|
(error "Could not start shell (`display-buffer' returned nil)")))))
|
||||||
(if (not arg)
|
(if (not arg)
|
||||||
;; toggle shell window
|
;; toggle shell window
|
||||||
(if (and (derived-mode-p 'shell-mode)
|
(if (and (derived-mode-p 'shell-mode)
|
||||||
(string-match-p "^\\*shell\\*" (buffer-name)))
|
(string-match-p "^\\*shell-side\\*" (buffer-name)))
|
||||||
(bury-buffer)
|
(bury-buffer)
|
||||||
(change-to-shell))
|
(change-to-shell))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user