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
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html
|
||||
(add-to-list 'display-buffer-alist
|
||||
'("^\\*eshell\\*"
|
||||
'("^\\*eshell-side\\*"
|
||||
display-buffer-in-side-window
|
||||
(side . bottom)
|
||||
(slot . -1)
|
||||
(window-height . 0.33)
|
||||
(window-parameters . ((no-other-window . t)))))
|
||||
(add-to-list 'display-buffer-alist
|
||||
'("^\\*shell\\*"
|
||||
'("^\\*shell-side\\*"
|
||||
display-buffer-in-side-window
|
||||
(side . bottom)
|
||||
(slot . 1)
|
||||
|
||||
@ -26,17 +26,17 @@
|
||||
|
||||
Otherwise moves the cursor to the window where we have been before.
|
||||
|
||||
The buffer's name has to start with “*eshell*” to be recognized
|
||||
by this function. Otherwise the current buffer is not treated as
|
||||
an eshell buffer.
|
||||
The buffer's name has to start with “*eshell-side*” to be recognized by
|
||||
this function. Otherwise the current buffer is not treated as an eshell
|
||||
buffer.
|
||||
|
||||
When ARG is given, change to `default-directory' after switching
|
||||
to the eshell buffer."
|
||||
When ARG is given, change to `default-directory' after switching to the
|
||||
eshell buffer."
|
||||
(interactive "P")
|
||||
(let ((current-dir (expand-file-name default-directory)))
|
||||
(cl-flet ((in-eshell-buffer-p ()
|
||||
(and (derived-mode-p 'eshell-mode)
|
||||
(string-match-p "^\\*eshell\\*" (buffer-name)))))
|
||||
(string-match-p "^\\*eshell-side\\*" (buffer-name)))))
|
||||
|
||||
(if (and (not arg)
|
||||
(in-eshell-buffer-p))
|
||||
@ -49,7 +49,7 @@ to the eshell buffer."
|
||||
(window-list-1))))
|
||||
(select-window eshell-window)
|
||||
;; 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)
|
||||
(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.
|
||||
|
||||
The buffer's name has to start with “*shell*” to be recognized
|
||||
by this function. Otherwise the current buffer is not treated as
|
||||
a shell buffer.
|
||||
The buffer's name has to start with “*shell-side*” to be recognized by
|
||||
this function. Otherwise the current buffer is not treated as a shell
|
||||
buffer.
|
||||
|
||||
With ARG, switch to `default-directory' of the current buffer first."
|
||||
(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)
|
||||
(with-current-buffer (window-buffer window)
|
||||
(and (derived-mode-p 'shell-mode)
|
||||
(string-match-p "^\\*shell\\*" (buffer-name)))))
|
||||
(string-match-p "^\\*shell-side\\*" (buffer-name)))))
|
||||
(window-list-1))))
|
||||
(select-window shell-window)
|
||||
(--if-let (display-buffer (shell))
|
||||
(--if-let (display-buffer (shell (get-buffer-create "*shell-side*")))
|
||||
(select-window it)
|
||||
(error "Could not start shell (`display-buffer' returned nil)")))))
|
||||
(if (not arg)
|
||||
;; toggle shell window
|
||||
(if (and (derived-mode-p 'shell-mode)
|
||||
(string-match-p "^\\*shell\\*" (buffer-name)))
|
||||
(string-match-p "^\\*shell-side\\*" (buffer-name)))
|
||||
(bury-buffer)
|
||||
(change-to-shell))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user