summaryrefslogtreecommitdiffhomepage
path: root/init.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-06-25 01:34:39 +0100
committerjao <jao@gnu.org>2022-06-25 01:34:39 +0100
commitd6283fc14939f6081f4414558ee8d95a085bb2e2 (patch)
treed354b44860571937a4719cef4ba007145c095c5a /init.el
parent2718ad3fa3446da3cd7a240e4fdd69e4819f0914 (diff)
downloadelibs-d6283fc14939f6081f4414558ee8d95a085bb2e2.tar.gz
elibs-d6283fc14939f6081f4414558ee8d95a085bb2e2.tar.bz2
switch-window
Diffstat (limited to 'init.el')
-rw-r--r--init.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/init.el b/init.el
index 597c0d8..7741cdc 100644
--- a/init.el
+++ b/init.el
@@ -1082,6 +1082,42 @@
(define-key ctl-x-4-map (kbd "t") 'transpose-windows)
+;;;; switch window
+(use-package switch-window
+ :ensure t
+ :custom ((switch-window-minibuffer-shortcut ?z)
+ (switch-window-background t)
+ (switch-window-shortcut-style 'qwerty)
+ (switch-window-shortcut-appearance 'text)
+ (switch-window-timeout 7)
+ (switch-window-threshold 2))
+ :init (defalias 'jao-other-window 'switch-window)
+ :config
+ (defun jao-switch-window--then (prompt cmd)
+ (let ((f `(lambda ()
+ (let ((default-directory ,default-directory))
+ (call-interactively ',cmd)))))
+ (switch-window--then prompt f f)))
+
+ (defun jao-switch-window-then-dired ()
+ (interactive)
+ (jao-switch-window--then "Find directory" 'dired))
+
+ (defun jao-switch-window-then-find-file ()
+ (interactive)
+ (jao-switch-window--then "Find file" 'find-file))
+
+ (defun jao-switch-window-then-consult-buffer ()
+ (interactive)
+ (jao-switch-window--then "Switch to buffer" 'consult-buffer))
+
+ :bind (("M-o" . switch-window)
+ ("M-O" . switch-window-then-swap-buffer)
+ ("s-o" . switch-window)
+ ("s-O" . switch-window-then-swap-buffer)
+ ("C-x 4 d" . jao-switch-window-then-dired)
+ ("C-x 4 f" . jao-switch-window-then-find-file)
+ ("C-x 4 b" . jao-switch-window-then-consult-buffer)))
;;;; winner mode
(winner-mode 1)