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:
Henrik Lissner 2018-03-28 19:07:48 -04:00
parent f44a227e74
commit 43830a8498
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -201,13 +201,18 @@ delete."
(defun +eshell/switch (buffer)
"Interactively switch to another eshell buffer."
(interactive
(let ((buffers (delete (current-buffer) (ring-elements +eshell-buffers))))
(if buffers
(let ((buffers (cl-remove-if-not (lambda (buf) (eq (buffer-local-value 'major-mode buf) 'eshell-mode))
(delete (current-buffer) (ring-elements +eshell-buffers)))))
(if (not buffers)
(user-error "No eshell buffers are available")
(list (completing-read
"Eshell buffers"
(mapcar #'buffer-name buffers)
#'get-buffer
'require-match
nil nil (buffer-name (current-buffer)))))))
(switch-to-buffer buffer))
nil nil
(when (eq major-mode 'eshell-mode)
(buffer-name (current-buffer))))))))
(if-let* ((window (get-buffer-window buffer)))
(select-window window)
(switch-to-buffer buffer)))