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

[FIX] Restore old code that disable popwin when Helm is active #2101

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions spacemacs/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -1510,13 +1510,43 @@ Removes the automatic guessing of the initial value based on thing at point. "
(inhibit-same-window . t)
(window-height . 0.4)))
(defvar spacemacs-display-buffer-alist nil)
(defun spacemacs//helm-prepare-display ()
"Prepare necessary settings to make Helm display properly."
;; avoid Helm buffer being diplaye twice when user
;; sets this variable to some function that pop buffer to
;; a window. See https://github.com/syl20bnr/spacemacs/issues/1396
(let ((display-buffer-base-action '(nil)))
(setq spacemacs-display-buffer-alist display-buffer-alist)
;; the only buffer to display is Helm, nothing else we must set this
;; otherwise Helm cannot reuse its own windows for copyinng/deleting
;; etc... because of existing popwin buffers in the alist
(setq display-buffer-alist nil)
(popwin-mode -1)))

(defun spacemacs//display-helm-at-bottom (buffer)
(let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
;; this or any specialized case of Helm buffer must be added AFTER
;; `spacemacs-helm-display-buffer-regexp'. Otherwise,
;; `spacemacs-helm-display-buffer-regexp' will be used before
;; `spacemacs-helm-display-help-buffer-regexp' and display
;; configuration for normal Helm buffer is applied for helm help
;; buffer, making the help buffer unable to be displayed.
spacemacs-helm-display-buffer-regexp)))
(helm-default-display-buffer buffer)))

(setq helm-display-function 'spacemacs//display-helm-at-bottom)

(defun spacemacs//restore-previous-display-config ()
(popwin-mode 1)
;; we must enable popwin-mode first then restore `display-buffer-alist'
;; Otherwise, popwin keeps adding up its own buffers to `display-buffer-alist'
;; and could slow down Emacs as the list grows
(setq display-buffer-alist spacemacs-display-buffer-alist))

(add-hook 'helm-after-initialize-hook 'spacemacs//helm-prepare-display)
;; Restore popwin-mode after a Helm session finishes.
(add-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)

;; Add minibuffer history with `helm-minibuffer-history'
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)

Expand Down