Add basic support for moving popup windows (WIP)

Relevant to #141 #171
This commit is contained in:
Henrik Lissner 2017-09-24 20:46:53 +02:00
parent cfb094e589
commit 2ea01a5b66
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 39 additions and 27 deletions

View file

@ -212,6 +212,16 @@ window parameter."
(when (/= count 0) (when (/= count 0)
(other-window count))))) (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) (defun doom--popup-data (window)
(unless (doom-popup-property :fixed window) (unless (doom-popup-property :fixed window)
(when-let (buffer (window-buffer window)) (when-let (buffer (window-buffer window))

View file

@ -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 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 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')" evil-window-move-* (e.g. `evil-window-move-far-left')"
(let* ((this-window (get-buffer-window)) (if (doom-popup-p)
(this-buffer (current-buffer)) (doom-popup-move direction)
(that-window (windmove-find-other-window direction nil this-window)) (let* ((this-window (get-buffer-window))
(that-buffer (window-buffer that-window))) (this-buffer (current-buffer))
(when (or (minibufferp that-buffer) (that-window (windmove-find-other-window direction nil this-window))
(doom-popup-p that-window)) (that-buffer (window-buffer that-window)))
(setq that-buffer nil that-window nil)) (when (or (minibufferp that-buffer)
(if (not (or that-window (one-window-p t))) (doom-popup-p that-window))
(funcall (pcase direction (setq that-buffer nil that-window nil))
('left #'evil-window-move-far-left) (if (not (or that-window (one-window-p t)))
('right #'evil-window-move-far-right) (funcall (pcase direction
('up #'evil-window-move-very-top) ('left #'evil-window-move-far-left)
('down #'evil-window-move-very-bottom))) ('right #'evil-window-move-far-right)
(unless that-window ('up #'evil-window-move-very-top)
(setq that-window ('down #'evil-window-move-very-bottom)))
(split-window this-window nil (unless that-window
(pcase direction (setq that-window
('up 'above) (split-window this-window nil
('down 'below) (pcase direction
(_ 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 (with-selected-window that-window
(switch-to-buffer doom-buffer)) (switch-to-buffer this-buffer))
(setq that-buffer (window-buffer that-window))) (select-window 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 ;;;###autoload
(defun +evil/window-move-left () "See `+evil--window-swap'" (interactive) (+evil--window-swap 'left)) (defun +evil/window-move-left () "See `+evil--window-swap'" (interactive) (+evil--window-swap 'left))