From e7a9a1a3cadf5065e285feeb06a4213d034389ac Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 25 Sep 2017 13:02:20 +0200 Subject: [PATCH] Improve support for moving popup windows (WIP) Now, the +evil/window-move-* commands are consistent when used with popups. Also added doom/popup-move-* as popup-alternatives to evil-window-move-{very,far}-* commands. Relevant to #141 #171 --- core/autoload/popups.el | 13 +++++- core/core-popups.el | 8 ++-- modules/feature/evil/autoload/evil.el | 58 +++++++++++++-------------- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/core/autoload/popups.el b/core/autoload/popups.el index 1a97c9a64..d54ab5cf3 100644 --- a/core/autoload/popups.el +++ b/core/autoload/popups.el @@ -243,12 +243,21 @@ prevent the popup(s) from messing up the UI (or vice versa)." ;;;###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" +one of the following: 'left 'right 'above 'below" (when (doom-popup-p) (let ((buffer (current-buffer)) (doom-popup-inhibit-autokill t)) (doom/popup-close) - (doom-popup-buffer buffer '(:align direction) 'extend)))) + (doom-popup-buffer buffer `(:align ,direction) 'extend)))) + +;;;###autoload +(defun doom/popup-move-top () "See `doom-popup-move'." (interactive) (doom-popup-move 'above)) +;;;###autoload +(defun doom/popup-move-bottom () "See `doom-popup-move'." (interactive) (doom-popup-move 'below)) +;;;###autoload +(defun doom/popup-move-left () "See `doom-popup-move'." (interactive) (doom-popup-move 'left)) +;;;###autoload +(defun doom/popup-move-right () "See `doom-popup-move'." (interactive) (doom-popup-move 'right)) (defun doom--popup-data (window) (unless (doom-popup-property :fixed window) diff --git a/core/core-popups.el b/core/core-popups.el index 815fbb513..37773f38e 100644 --- a/core/core-popups.el +++ b/core/core-popups.el @@ -312,10 +312,10 @@ properties." (let ((map doom-popup-mode-map)) (define-key map [remap evil-window-delete] #'doom/popup-close) (define-key map [remap evil-save-modified-and-close] #'doom/popup-close) - (define-key map [remap evil-window-move-very-bottom] #'ignore) - (define-key map [remap evil-window-move-very-top] #'ignore) - (define-key map [remap evil-window-move-far-left] #'ignore) - (define-key map [remap evil-window-move-far-right] #'ignore) + (define-key map [remap evil-window-move-very-bottom] #'doom/popup-move-bottom) + (define-key map [remap evil-window-move-very-top] #'doom/popup-move-top) + (define-key map [remap evil-window-move-far-left] #'doom/popup-move-left) + (define-key map [remap evil-window-move-far-right] #'doom/popup-move-right) (define-key map [remap evil-window-split] #'ignore) (define-key map [remap evil-window-vsplit] #'ignore)) diff --git a/modules/feature/evil/autoload/evil.el b/modules/feature/evil/autoload/evil.el index b9a27696a..2bb850496 100644 --- a/modules/feature/evil/autoload/evil.el +++ b/modules/feature/evil/autoload/evil.el @@ -101,36 +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')" - (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)) + (when (doom-popup-p) + (doom/popup-raise)) + (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 this-buffer)) - (select-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)))) ;;;###autoload (defun +evil/window-move-left () "See `+evil--window-swap'" (interactive) (+evil--window-swap 'left))