summaryrefslogtreecommitdiffhomepage
path: root/init.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-02 01:09:48 +0100
committerjao <jao@gnu.org>2021-05-02 01:09:48 +0100
commitc54b15d8563424a1f8760bb187e175cba6ba9fee (patch)
tree3d596b192e2d147f25c498f3b84e870c7f0b9d44 /init.org
parentac9201a7d7ebc6dc4e4e8f3a542f7f209be585ee (diff)
downloadelibs-c54b15d8563424a1f8760bb187e175cba6ba9fee.tar.gz
elibs-c54b15d8563424a1f8760bb187e175cba6ba9fee.tar.bz2
vanilla other-window plus transpose function
Diffstat (limited to 'init.org')
-rw-r--r--init.org54
1 files changed, 16 insertions, 38 deletions
diff --git a/init.org b/init.org
index 3e2052d..f01bda4 100644
--- a/init.org
+++ b/init.org
@@ -1235,48 +1235,25 @@
(global-set-key (kbd "C-x _") #'delete-other-windows-vertically)
#+end_src
-*** switch window
- An alternative for this one is ace-window, but it has the problem
- of not displaying its overlay over org buffers (sometimes) and
- introducing a dependency (avy).
+*** Transpose
#+begin_src emacs-lisp
- (use-package switch-window
- :ensure t
- :custom ((switch-window-minibuffer-shortcut ?z)
- (switch-window-background t)
- (switch-window-shortcut-style 'qwerty)
- (switch-window-timeout 7)
- (switch-window-threshold 3))
- :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-transpose-windows (arg)
+ "Transpose the buffers shown in two windows."
+ (interactive "p")
+ (let ((selector (if (>= arg 0) 'next-window 'previous-window)))
+ (while (/= arg 0)
+ (let ((this-win (window-buffer))
+ (next-win (window-buffer (funcall selector))))
+ (set-window-buffer (selected-window) next-win)
+ (set-window-buffer (funcall selector) this-win)
+ (select-window (funcall selector)))
+ (setq arg (if (plusp arg) (1- arg) (1+ arg))))))
- (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)
- ("H-s-o" . switch-window)
- ("H-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)))
+ (define-key ctl-x-4-map (kbd "t") #'jao-transpose-windows)
+ (global-set-key (kbd "M-O") #'jao-transpose-windows)
#+end_src
-*** first window and transient other window
+*** First window
#+begin_src emacs-lisp
-
(defvar jao-first-window--from nil)
(defun jao-first-window ()
@@ -1288,6 +1265,7 @@
(global-set-key (kbd "s-a") #'jao-first-window)
(global-set-key (kbd "H-s-a") #'jao-first-window)
+ (global-set-key (kbd "M-o") #'other-window)
#+end_src
*** winner mode
#+begin_src emacs-lisp