diff options
Diffstat (limited to 'init.org')
-rw-r--r-- | init.org | 80 |
1 files changed, 39 insertions, 41 deletions
@@ -1255,49 +1255,47 @@ (global-set-key (kbd "C-x _") #'delete-other-windows-vertically) #+end_src -*** ace-window - An alternative is switch-window. The problem with it is that - commands such as C-x 4 f will use as default-dir the destination's - rather than the origin's, which kills the fun of it. ace-window - is not without warts, notably, lack of overlay for org buffers, - although, to be fair, that's possibly org's fault (but then, why - does switch-window's overlays work?). - #+begin_src emacs-lisp - (use-package ace-window +*** 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 :load no + (use-package switch-window :ensure t :demand t - :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?\;) - aw-ignore-current nil - aw-dispatch-when-more-than 3 - aw-leading-char-style 'path - aw-display-mode-overlay t - aw-scope 'frame) - :bind (("M-o" . ace-window) - ("M-O" . ace-swap-window) - ("H-s-o" . ace-window) - ("H-s-O" . ace-swap-window) - ("C-x p" . ace-window))) - - (defun jao-ace-switch-buffer-other-window () - (interactive) - (aw-select "Other window" - (if (eq jao-completion-engine 'consult) - (lambda (w) - (aw-switch-to-window w) - (call-interactively 'consult-buffer)) - #'aw-switch-buffer-in-window))) - - (defun jao-ace-find-file-other-window () - (interactive) - (aw-select "Other window" - (lambda (w) - (let ((df default-directory)) - (aw-switch-to-window w) - (let ((default-directory df)) - (call-interactively 'find-file)))))) - - (global-set-key (kbd "C-x 4 f") #'jao-ace-find-file-other-window) - (global-set-key (kbd "C-x 4 b") #'jao-ace-switch-buffer-other-window) + :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 ((d default-directory)) + (switch-window--then prompt + cmd + `(lambda () + (let ((default-directory ,d)) + (call-interactively ',cmd)))))) + + (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 *** first window and transient other window #+begin_src emacs-lisp |