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 ;;;###autoload
(defun doom-popup-move (direction) (defun doom-popup-move (direction)
"Move a popup window to another side of the frame, in DIRECTION, which can be "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) (when (doom-popup-p)
(let ((buffer (current-buffer)) (let ((buffer (current-buffer))
(doom-popup-inhibit-autokill t)) (doom-popup-inhibit-autokill t))
(doom/popup-close) (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) (defun doom--popup-data (window)
(unless (doom-popup-property :fixed window) (unless (doom-popup-property :fixed window)

View file

@ -312,10 +312,10 @@ properties."
(let ((map doom-popup-mode-map)) (let ((map doom-popup-mode-map))
(define-key map [remap evil-window-delete] #'doom/popup-close) (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-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-bottom] #'doom/popup-move-bottom)
(define-key map [remap evil-window-move-very-top] #'ignore) (define-key map [remap evil-window-move-very-top] #'doom/popup-move-top)
(define-key map [remap evil-window-move-far-left] #'ignore) (define-key map [remap evil-window-move-far-left] #'doom/popup-move-left)
(define-key map [remap evil-window-move-far-right] #'ignore) (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-split] #'ignore)
(define-key map [remap evil-window-vsplit] #'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 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')"
(if (doom-popup-p) (when (doom-popup-p)
(doom-popup-move direction) (doom/popup-raise))
(let* ((this-window (get-buffer-window)) (let* ((this-window (get-buffer-window))
(this-buffer (current-buffer)) (this-buffer (current-buffer))
(that-window (windmove-find-other-window direction nil this-window)) (that-window (windmove-find-other-window direction nil this-window))
(that-buffer (window-buffer that-window))) (that-buffer (window-buffer that-window)))
(when (or (minibufferp that-buffer) (when (or (minibufferp that-buffer)
(doom-popup-p that-window)) (doom-popup-p that-window))
(setq that-buffer nil that-window nil)) (setq that-buffer nil that-window nil))
(if (not (or that-window (one-window-p t))) (if (not (or that-window (one-window-p t)))
(funcall (pcase direction (funcall (pcase direction
('left #'evil-window-move-far-left) ('left #'evil-window-move-far-left)
('right #'evil-window-move-far-right) ('right #'evil-window-move-far-right)
('up #'evil-window-move-very-top) ('up #'evil-window-move-very-top)
('down #'evil-window-move-very-bottom))) ('down #'evil-window-move-very-bottom)))
(unless that-window (unless that-window
(setq that-window (setq that-window
(split-window this-window nil (split-window this-window nil
(pcase direction (pcase direction
('up 'above) ('up 'above)
('down 'below) ('down 'below)
(_ direction)))) (_ 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 this-buffer)) (switch-to-buffer doom-buffer))
(select-window that-window))))) (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 ;;;###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))