branch: elpa/helm commit f655faa0b3491aa30aac1000d387e8ecf1930abf Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Change behavior of helm-buffers-switch-to-buffer-new-tab (#2684) --- helm-buffers.el | 15 +++++++++++---- helm-types.el | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/helm-buffers.el b/helm-buffers.el index 8193fea829..181c7c815b 100644 --- a/helm-buffers.el +++ b/helm-buffers.el @@ -972,15 +972,22 @@ If REGEXP-FLAG is given use `query-replace-regexp'." "Run switch to other frame action from `helm-source-buffers-list'." 'helm-buffer-switch-to-buffer-other-frame) -(defun helm-buffers-switch-to-buffer-other-tab (_candidate) +(defun helm-buffers-switch-buffers-in-tab (candidate) + "Switch marked buffers in a new tab. +If no marked candidates or only one marked, try to switch to CANDIDATE in its +tab if some, otherwise, display it in a new tab." (when (fboundp 'switch-to-buffer-other-tab) (let ((bufs (helm-marked-candidates))) - (cl-loop for buf in bufs - do (switch-to-buffer-other-tab buf))))) + (if (cdr bufs) + (progn + (switch-to-buffer-other-tab (car bufs)) + (helm-window-show-buffers bufs)) + (helm-buffers-maybe-switch-to-buffer-in-tab + candidate #'switch-to-buffer-other-tab))))) (helm-make-command-from-action helm-buffers-switch-to-buffer-new-tab "Run switch to buffer in other tab action from `helm-source-buffers-list'." - 'helm-buffers-switch-to-buffer-other-tab + 'helm-buffers-switch-buffers-in-tab (cl-assert (fboundp 'tab-bar-mode) nil "Tab-bar-mode not available")) (defun helm-buffer-switch-buffers (_candidate) diff --git a/helm-types.el b/helm-types.el index be6cb24435..b33488fb27 100644 --- a/helm-types.el +++ b/helm-types.el @@ -177,7 +177,7 @@ 'helm-buffers-maybe-raise-buffer-frame (lambda () (and (fboundp 'tab-bar-mode) "Switch to buffer(s) other tab `C-c C-t'")) - 'helm-buffers-switch-to-buffer-other-tab + 'helm-buffers-switch-buffers-in-tab "Switch to buffer at line number" 'helm-switch-to-buffer-at-linum "Browse project `C-x C-d'"