Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm-resume opens helm window in wrong position? #1976

Closed
bmag opened this issue Jun 13, 2015 · 10 comments
Closed

helm-resume opens helm window in wrong position? #1976

bmag opened this issue Jun 13, 2015 · 10 comments

Comments

@bmag
Copy link
Collaborator

bmag commented Jun 13, 2015

Steps to reproduce:

    1. open spacemacs
    1. split window - SPC w /
    1. run helm-mini - SPC b b
      helm window opens at the bottom of the screen, as expected
+--------------+-------------+
|              |             |
|              |             |
|              |             |
|              |             |
+--------------+-------------+
|        helm window         |
+----------------------------+
    1. quit helm session - C-g or ESC
    1. run helm-resume - SPC h l
      helm window splits the selected window, instead of opening at the bottom of the screen
+-------------+--------------+
|             |              |
|             |              |
|             |              |
+-------------+              |
|   helm      |              |
|   window    |              |
+-------------+--------------+

Can anyone confirm this bug?

In case this isn't just a bug in my configuration, I think we can fix this by setting helm-display-function to a custom function, instead of what we currently use to control helm window's display.

@sooheon
Copy link

sooheon commented Jun 13, 2015

Confirmed. It also doesn't respect window height set in spacemacs-helm-display-buffer-regexp

@bmag
Copy link
Collaborator Author

bmag commented Jun 15, 2015

Solved by adding the following to dotspacemacs/config:

(remove-hook 'helm-after-initialize-hook 'spacemacs//display-helm-at-bottom)
(remove-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)
(defun display-helm-at-bottom (buffer)
  (let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
                                    spacemacs-helm-display-buffer-regexp)))
    (helm-default-display-buffer buffer)))
(setq helm-display-function 'display-helm-at-bottom)

Spacemacs uses helm-after-initialize-hook and helm-cleanup-hook to control helm window display (here). The above uses helm-display-function instead.

@syl20bnr
Copy link
Owner

@sooheon can you provide a PR for this ?

@sooheon
Copy link

sooheon commented Jun 22, 2015

Went ahead and implemented @bmag's solution word for word for the PR

@StreakyCobra
Copy link
Contributor

This issue has been solved long time ago by #2081. I verified both on master and develop that it's really the case. I'm going forward and closing this issue. If it's not the case, let me know I'll reopen it, and anyway feel free to open a new issue in case of troubles ☺️

@zw963
Copy link

zw963 commented Jun 25, 2016

Hi, anyone could help me for display helm at bottom without popwin?

I am not spacemacs user, But I hope can reuse @bmag 's code.

I start emacs with -Q and following config:

(require 'helm-config)
(setq helm-mode-fuzzy-match t)
(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
                                               (display-buffer-in-side-window)
                                               (inhibit-same-window . nil)
                                               (side . bottom)
                                               (window-width . 0.6)
                                               (window-height . 0.4)))

(defun display-helm-at-bottom (buffer)
  (let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
                                    spacemacs-helm-display-buffer-regexp)))
    (helm-default-display-buffer buffer)))
(setq helm-display-function 'display-helm-at-bottom)

The problem is: in one window frame, when I start helm-mini, alway became three
window, two same wnidow and one helm-buffer, Is there other special config for helm
worked with spacemacs?

Following is a screenshot for this case:

Screenshot at 2016-06-26 00:27:29.png

@bmag
Copy link
Collaborator Author

bmag commented Jun 25, 2016

@zw963 replacing helm-default-display-buffer with display-buffer seems to work ok in stock emacs.

@zw963
Copy link

zw963 commented Jun 26, 2016

@bmag, It is worked! thanks.

@zw963
Copy link

zw963 commented May 13, 2018

this workaround not worked in newest 2.9.4. (2018-05-13)

I have to change to following to make it work again:

(defun display-helm-at-bottom (buffer &optional _resume)
  (let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
                                    spacemacs-helm-display-buffer-regexp)))
    (helm-default-display-buffer buffer)))

maybe need more tune to make _resume work as expect.

following is changed code in new version helm:

(defun helm-default-display-buffer (buffer &optional _resume)
  "Default function to display `helm-buffer' BUFFER.

It is the default value of `helm-display-function'
It uses `switch-to-buffer' or `display-buffer' depending on the
value of `helm-full-frame' or `helm-split-window-default-side'."
  (let (pop-up-frames)
    (if (or (buffer-local-value 'helm-full-frame (get-buffer buffer))
            (and (eq helm-split-window-default-side 'same)
                 (one-window-p t)))
        (progn (and (not (minibufferp helm-current-buffer))
                    (delete-other-windows))
               (switch-to-buffer buffer))
      (when (and (or helm-always-two-windows helm-autoresize-mode)
                 (not (eq helm-split-window-default-side 'same))
                 (not (minibufferp helm-current-buffer))
                 (not helm-split-window-inside-p))
        (delete-other-windows))
      (display-buffer
       buffer `(nil . ((window-height . ,helm-display-buffer-default-height)
                       (window-width  . ,helm-display-buffer-default-width))))
      (helm-log-run-hook 'helm-window-configuration-hook))))

Thanks

@syl20bnr
Copy link
Owner

syl20bnr commented May 13, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants