window gets splited when use helm with only one window?
xuchunyang opened this issue · 6 comments
for example, run helm-mini
from only one *scratch*
window:
I install helm and shackle from melpa recently, by using the config:
(setq shackle-rules
'(("\\`\\*helm.*?\\*\\'" :regexp t :align t :ratio 0.4)))
(shackle-mode)
am I missing something? (I'm new to shackle) BTW, it works as expected when there are more than one exiting windows.
To re-produce:
-
Don't use personal setting and existing packages (to make sure to install latest
helm
andshackle
from melpa via package.el)$ mv ~/.emacs.d /tmp
-
Start Emacs in terminal without any arguments or options
-
Insert the following into
*scratch*
buffer and eval it with M-x eval-buffer(package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (package-refresh-contents) (package-install 'helm) (package-install 'shackle) (require 'helm-config) (global-set-key (kbd "M-l") #'helm-mini) (setq shackle-rules '(("\\`\\*helm.*?\\*\\'" :regexp t :align t :ratio 0.4))) (shackle-mode)
My Emacs version is GNU Emacs 24.5.1 (x86_64-apple-darwin14.4.0) of 2015-08-19 on Chunyang-Xus-MacBook-Air.local
, installed with MacPorts.
Ugh, looks like the most recent version of helm broke display-buffer-alist
. This package is nothing but trouble and keeps getting worse over time.
anyway here is a work-around that I am using:
;; Turn off `shackle-mode' when there is only one window
(add-hook 'helm-before-initialize-hook
(defun helm-disable-shackle-mode-maybe ()
(when (one-window-p)
(shackle-mode -1))))
;; Turn on `shackle-mode' when quitting helm session normally
(add-hook 'helm-exit-minibuffer-hook #'shackle-mode)
;; Turn on `shackle-mode' when quitting helm session abnormally
(defun helm-keyboard-quit--enable-shackle-mode (orig-func &rest args)
(shackle-mode)
(apply orig-func args))
(advice-add 'helm-keyboard-quit :around #'helm-keyboard-quit--enable-shackle-mode)
I didn't expect it to be possible for a package to use display-buffer
(indirectly) and break customizability with display-buffer-alist
, but it looks like we've got a winner here! helm-default-display-buffer
checks way too many customization variables, then decides based on these whether to delete all other windows. While it's doing that, it conditionally opens a new window split for who knows what reason. Finally, it's calling pop-to-buffer
which is basically like display-buffer
, but ensures the window is selected afterwards.
Wait a second. If we've started out with one window, helm decides to open an extra split and calls pop-to-buffer
, how can pop-to-buffer
not go ahead and open a third window, resulting in the described layout you've handed a bug in for? Simple, it relies on you not having display-buffer-alist
customized for it to not to pop up a window, but as we're using Shackle with :align
, a new window is always displayed. If you customize helm-display-function
to pop-to-buffer
, its window is displayed as it should. Particularly ironic considering helm-default-display-buffer
claims doing that already.
Personally, I believe @thierryvolpiatto should follow his own statement of helm being "not tied in the trap of backward compatibility" a little bit more closely and get rid of these ad-hoc hacks to just use what Emacs is already offering with display-buffer
and friends. If someone doesn't like their default way of displaying a buffer, they are free to customize display-buffer-alist
or to use a package like Shackle or popwin to simplify that. It would allow him to remove a good chunk of the legacy code his project is supposed to reduce and ensure horrific workarounds like yours aren't necessary.
Vasilij Schneidermann notifications@github.com writes:
Personally, I believe @thierryvolpiatto should follow his own
statement of helm being "not tied in the trap of backward
compatibility" a little bit more closely and get rid of these ad-hoc
hacks to just use what Emacs is already offering with display-buffer
and friends. If someone doesn't like their default way of displaying a
buffer, they are free to customize display-buffer-alist or to use a
package like Shackle or popwin to simplify that.
thierryvolpiatto don't care about your comments about helm you are
sending here and there on github and wonder why you are still using
it.
Thierry