tools/eshell: fix typo in condition in +eshell/switch
Also changes behavior to select the selected eshell window if it's already open.
This commit is contained in:
parent
f44a227e74
commit
43830a8498
1 changed files with 9 additions and 4 deletions
|
@ -201,13 +201,18 @@ delete."
|
||||||
(defun +eshell/switch (buffer)
|
(defun +eshell/switch (buffer)
|
||||||
"Interactively switch to another eshell buffer."
|
"Interactively switch to another eshell buffer."
|
||||||
(interactive
|
(interactive
|
||||||
(let ((buffers (delete (current-buffer) (ring-elements +eshell-buffers))))
|
(let ((buffers (cl-remove-if-not (lambda (buf) (eq (buffer-local-value 'major-mode buf) 'eshell-mode))
|
||||||
(if buffers
|
(delete (current-buffer) (ring-elements +eshell-buffers)))))
|
||||||
|
(if (not buffers)
|
||||||
(user-error "No eshell buffers are available")
|
(user-error "No eshell buffers are available")
|
||||||
(list (completing-read
|
(list (completing-read
|
||||||
"Eshell buffers"
|
"Eshell buffers"
|
||||||
(mapcar #'buffer-name buffers)
|
(mapcar #'buffer-name buffers)
|
||||||
#'get-buffer
|
#'get-buffer
|
||||||
'require-match
|
'require-match
|
||||||
nil nil (buffer-name (current-buffer)))))))
|
nil nil
|
||||||
(switch-to-buffer buffer))
|
(when (eq major-mode 'eshell-mode)
|
||||||
|
(buffer-name (current-buffer))))))))
|
||||||
|
(if-let* ((window (get-buffer-window buffer)))
|
||||||
|
(select-window window)
|
||||||
|
(switch-to-buffer buffer)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue