From ab3907d9fae222a744168f9d068f63616e11761d Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 4 Jan 2021 13:13:32 -0500 Subject: [PATCH] Make split-window-below-i3 behave nicer in a terminal or missing i3 --- .emacs.d/init.el | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 693bf9f..daaf007 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -532,23 +532,26 @@ (defun x-focus-frame (FRAME &optional NOACTIVATE)) (frames-only-mode t) (menu-bar-mode 0) - (if (executable-find "i3") - (progn - (defun split-window-below-i3 () - "It's like `split-window-below', but uses i3 stuff" - (interactive) - (call-process "i3" nil nil nil "split v") - (make-frame)) - (defun split-window-right-i3 () - "It's like `split-window-right', but uses i3 stuff" - (interactive) - (call-process "i3" nil nil nil "split h") - (make-frame)) - (bind-key "C-x 2" 'split-window-below-i3) - (bind-key "C-x 3" 'split-window-right-i3)) - (progn - (bind-key "C-x 2" 'make-frame-command) - (bind-key "C-x 3" 'make-frame-command)))) + + (defun split-window-below-i3 () + "It's like `split-window-below', but uses i3 stuff when available" + (interactive) + (cond ((not (display-graphic-p)) (split-window-below)) + ((executable-find "i3") + (call-process "i3" nil nil nil "split v") + (make-frame)) + (t (make-frame)))) + + (defun split-window-right-i3 () + "It's like `split-window-right', but uses i3 stuff when available" + (interactive) + (cond ((not (display-graphic-p)) (split-window-right)) + ((executable-find "i3") + (call-process "i3" nil nil nil "split h") + (make-frame)) + (t (make-frame)))) + (bind-key "C-x 2" 'split-window-below-i3) + (bind-key "C-x 3" 'split-window-right-i3)) (use-package crux :ensure :bind (("C-a" . crux-move-beginning-of-line)))