From 43830a84988c9fece5f27de00f6bce403d91f7a1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 28 Mar 2018 19:07:48 -0400 Subject: [PATCH] tools/eshell: fix typo in condition in +eshell/switch Also changes behavior to select the selected eshell window if it's already open. --- modules/tools/eshell/autoload/eshell.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/tools/eshell/autoload/eshell.el b/modules/tools/eshell/autoload/eshell.el index 71e40319b..e3bb5e35b 100644 --- a/modules/tools/eshell/autoload/eshell.el +++ b/modules/tools/eshell/autoload/eshell.el @@ -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)))