summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-23 02:16:27 +0100
committerjao <jao@gnu.org>2021-05-23 02:16:27 +0100
commit6c22e83492d4acdaadf6507edc2e0100dc2fd418 (patch)
tree6d4f6cc9681d63eeebc7228b90d4ea8e649886b7
parenteebfc8a0dabf93d16b0103b8edb4c6598343d257 (diff)
downloadelibs-6c22e83492d4acdaadf6507edc2e0100dc2fd418.tar.gz
elibs-6c22e83492d4acdaadf6507edc2e0100dc2fd418.tar.bz2
trying switch-window again
-rw-r--r--init.org54
1 files changed, 46 insertions, 8 deletions
diff --git a/init.org b/init.org
index 7a7a038..cb70607 100644
--- a/init.org
+++ b/init.org
@@ -1189,23 +1189,61 @@
(interactive)
(other-window -1))
- (defun jao--nth-windower (n)
- (if (zerop n) #'jao-first-window
- `(lambda ()
- (interactive)
- (jao-first-window)
- (dotimes (x ,n) (other-window 1)))))
+ (defun jao--nth-window (n)
+ (let ((jao-minibuffer-enabled-p nil))
+ (select-window (frame-first-window))
+ (dotimes (x n) (other-window 1)))
+ (jao-minibuffer-refresh))
(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)
(global-set-key (kbd "C-x p") 'jao-prev-window)
(global-set-key (kbd "C-c 0") #'jao-first-window)
(dolist (n '(0 1 2 3 4 5 6 7 8))
- (global-set-key (format "\C-c%s" (1+ n)) (jao--nth-windower n)))
+ (global-set-key (format "\C-c%s" (1+ n))
+ `(lambda () (interactive) (jao--nth-window ,n))))
#+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).
+ #+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 2))
+ :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)
+ ("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)))
+ #+end_src
*** winner mode
#+begin_src emacs-lisp
(winner-mode 1)