Smarter window keybindings; including single step window-moving

This commit is contained in:
Henrik Lissner 2015-11-17 02:13:38 -05:00
parent 0596a0cb23
commit c27643c5e9
2 changed files with 61 additions and 3 deletions

View file

@ -87,12 +87,64 @@
(call-interactively 'evil-window-split)
(evil-window-down 1))
;;;###autoload
(defun narf/undo-window-change ()
(interactive)
(call-interactively (if (wg-current-workgroup t) 'wg-undo-wconfig-change 'winner-undo)))
;;;###autoload
(defun narf/redo-window-change ()
(interactive)
(call-interactively (if (wg-current-workgroup t) 'wg-redo-wconfig-change 'winner-redo)))
;;;###autoload
(defun narf/evil-window-vsplit ()
(interactive)
(call-interactively 'evil-window-vsplit)
(evil-window-right 1))
(defun narf--evil-window-move (direction)
"Move current window to the next window in DIRECTION. If there is no window,
then make an empty split and switch their buffers."
(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)))
(unless that-window
(setq that-window
(split-window this-window nil (cond ((eq direction 'up) 'above)
((eq direction 'down) 'below)
(t direction))))
(with-selected-window that-window
(switch-to-buffer "*scratch*"))
(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 narf/evil-window-move-left ()
"See `narf--evil-window-move'"
(interactive)
(narf--evil-window-move 'left))
;;;###autoload
(defun narf/evil-window-move-down ()
"See `narf--evil-window-move'"
(interactive)
(narf--evil-window-move 'down))
;;;###autoload
(defun narf/evil-window-move-up ()
"See `narf--evil-window-move'"
(interactive)
(narf--evil-window-move 'up))
;;;###autoload
(defun narf/evil-window-move-right ()
"See `narf--evil-window-move'"
(interactive)
(narf--evil-window-move 'right))
;;;###autoload
(defmacro define-text-object! (key start-regex end-regex)
(let ((inner-name (make-symbol "narf--inner-name"))