diff --git a/emacs/init.el b/emacs/init.el index df98911..3e72d04 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -468,6 +468,26 @@ :init (tab-bar-mode 1)) +;;;; Split window and focus +(defun split-window-and-focus (split-function) + "Split the window using SPLIT-FUNCTION and move the cursor to the new window." + (interactive "aSplit function: ") + (let ((new-window (funcall split-function))) + (select-window new-window))) + +(defun split-window-below-and-focus () + "Split the window horizontally and move the cursor below." + (interactive) + (split-window-and-focus 'split-window-below)) + +(defun split-window-right-and-focus () + "Split the window vertically and move the cursor to the right." + (interactive) + (split-window-and-focus 'split-window-right)) + +(use-package emacs + :bind (([remap split-window-below] . split-window-below-and-focus) + ([remap split-window-right] . split-window-right-and-focus))) ;;;; Popper (use-package popper :ensure t