From 2ea01a5b66dcc12e466fe36e13710a9d9ec6325e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 24 Sep 2017 20:46:53 +0200 Subject: [PATCH] Add basic support for moving popup windows (WIP) Relevant to #141 #171 --- core/autoload/popups.el | 10 +++++ modules/feature/evil/autoload/evil.el | 56 ++++++++++++++------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/core/autoload/popups.el b/core/autoload/popups.el index 344d95ad6..4a3324605 100644 --- a/core/autoload/popups.el +++ b/core/autoload/popups.el @@ -212,6 +212,16 @@ window parameter." (when (/= count 0) (other-window count))))) +;;;###autoload +(defun doom-popup-move (direction) + "Move a popup window to another side of the frame, in DIRECTION, which can be +one of the following: 'left 'right 'up 'down" + (when (doom-popup-p) + (let ((buffer (current-buffer)) + (doom-popup-inhibit-autokill t)) + (doom/popup-close) + (doom-popup-buffer buffer '(:align direction) 'extend)))) + (defun doom--popup-data (window) (unless (doom-popup-property :fixed window) (when-let (buffer (window-buffer window)) diff --git a/modules/feature/evil/autoload/evil.el b/modules/feature/evil/autoload/evil.el index 129b8230f..b9a27696a 100644 --- a/modules/feature/evil/autoload/evil.el +++ b/modules/feature/evil/autoload/evil.el @@ -101,34 +101,36 @@ flags. See http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers there and there is only one window, split in that direction and place this window there. If there are no windows and this isn't the only window, use evil-window-move-* (e.g. `evil-window-move-far-left')" - (let* ((this-window (get-buffer-window)) - (this-buffer (current-buffer)) - (that-window (windmove-find-other-window direction nil this-window)) - (that-buffer (window-buffer that-window))) - (when (or (minibufferp that-buffer) - (doom-popup-p that-window)) - (setq that-buffer nil that-window nil)) - (if (not (or that-window (one-window-p t))) - (funcall (pcase direction - ('left #'evil-window-move-far-left) - ('right #'evil-window-move-far-right) - ('up #'evil-window-move-very-top) - ('down #'evil-window-move-very-bottom))) - (unless that-window - (setq that-window - (split-window this-window nil - (pcase direction - ('up 'above) - ('down 'below) - (_ direction)))) + (if (doom-popup-p) + (doom-popup-move direction) + (let* ((this-window (get-buffer-window)) + (this-buffer (current-buffer)) + (that-window (windmove-find-other-window direction nil this-window)) + (that-buffer (window-buffer that-window))) + (when (or (minibufferp that-buffer) + (doom-popup-p that-window)) + (setq that-buffer nil that-window nil)) + (if (not (or that-window (one-window-p t))) + (funcall (pcase direction + ('left #'evil-window-move-far-left) + ('right #'evil-window-move-far-right) + ('up #'evil-window-move-very-top) + ('down #'evil-window-move-very-bottom))) + (unless that-window + (setq that-window + (split-window this-window nil + (pcase direction + ('up 'above) + ('down 'below) + (_ direction)))) + (with-selected-window that-window + (switch-to-buffer doom-buffer)) + (setq that-buffer (window-buffer that-window))) + (with-selected-window this-window + (switch-to-buffer that-buffer)) (with-selected-window that-window - (switch-to-buffer doom-buffer)) - (setq that-buffer (window-buffer that-window))) - (with-selected-window this-window - (switch-to-buffer that-buffer)) - (with-selected-window that-window - (switch-to-buffer this-buffer)) - (select-window that-window)))) + (switch-to-buffer this-buffer)) + (select-window that-window))))) ;;;###autoload (defun +evil/window-move-left () "See `+evil--window-swap'" (interactive) (+evil--window-swap 'left))