summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-09-19 07:11:39 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-09-19 07:11:39 +0200
commitfd3bc2707d92bfb21accf57972a17a4e0ebd6516 (patch)
tree403b5fadb11980125d70fc66f0d7d92b82d86c77
parent44bc49fbf921a1a4afe29cacf0085c2d12fc6226 (diff)
Don't create a new window when one already exists (#1874)
Modify C-c C-o in HFF and buffers listing, should affect moccur and grep as well. * helm-files.el (helm-find-files-other-window): Do it. * helm-utils.el (helm-switch-to-buffers): Do it.
-rw-r--r--helm-files.el2
-rw-r--r--helm-utils.el9
2 files changed, 7 insertions, 4 deletions
diff --git a/helm-files.el b/helm-files.el
index 5952a62c..6a63ad1f 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -748,7 +748,7 @@ This reproduce the behavior of \"cp --backup=numbered from to\"."
"Keep current-buffer and open files in separate windows."
(let* ((files (helm-marked-candidates))
(buffers (mapcar 'find-file-noselect files)))
- (helm-switch-to-buffer-other-window (car buffers))
+ (switch-to-buffer-other-window (car buffers))
(helm-aif (cdr buffers)
(save-selected-window
(cl-loop for buffer in it
diff --git a/helm-utils.el b/helm-utils.el
index 3df5b947..1400e0f9 100644
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -224,11 +224,14 @@ If more than one buffer marked switch to these buffers in separate windows.
If OTHER-WINDOW is specified keep current-buffer and switch to others buffers
in separate windows.
If a prefix arg is given split windows vertically."
- (let ((mkds (helm-marked-candidates)))
+ (let ((mkds (helm-marked-candidates))
+ (initial-ow-fn (if (cdr (window-list))
+ #'switch-to-buffer-other-window
+ #'helm-switch-to-buffer-other-window)))
(helm-aif (cdr mkds)
(progn
(if other-window
- (helm-switch-to-buffer-other-window (car mkds))
+ (funcall initial-ow-fn (car mkds))
(switch-to-buffer (car mkds)))
(save-selected-window
(cl-loop with nosplit
@@ -239,7 +242,7 @@ If a prefix arg is given split windows vertically."
(helm-switch-to-buffer-other-window b 'balance)
(error (setq nosplit t) nil)))))
(if other-window
- (helm-switch-to-buffer-other-window buffer-or-name)
+ (funcall initial-ow-fn buffer-or-name)
(switch-to-buffer buffer-or-name)))))
(defun helm-simultaneous-find-file (files)