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
This commit is contained in:
Henrik Lissner 2017-09-25 13:02:20 +02:00
parent 311e15487a
commit e7a9a1a3ca
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 44 additions and 35 deletions

View file

@ -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)

View file

@ -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))

View file

@ -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))