Add ace-window to s-w

And get the commands more in line with my hydra. Less to think about.
This commit is contained in:
Howard Abrams 2022-10-10 21:57:50 -07:00
parent 595d435789
commit 5a26d457a7

View file

@ -351,10 +351,6 @@ Why would I ever quit Emacs with a simple keybinding? Lets override it:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(global-set-key (kbd "s-q") 'bury-buffer) (global-set-key (kbd "s-q") 'bury-buffer)
#+end_src #+end_src
Oh, and lets not close the frame, but instead, the window:
#+begin_src emacs-lisp
(global-set-key (kbd "s-w") 'delete-window)
#+end_src
** Undo ** Undo
I mean, I /always/ use ~C-/~ for [[help:undo][undo]] (and ~C-?~ for [[help:undo-redo][redo]]), but when Im on the Mac, I need to cover my bases. I mean, I /always/ use ~C-/~ for [[help:undo][undo]] (and ~C-?~ for [[help:undo-redo][redo]]), but when Im on the Mac, I need to cover my bases.
@ -789,36 +785,29 @@ And put it on the toggle menu:
*** Window Operations *** Window Operations
While it comes with Emacs, I use [[https://www.emacswiki.org/emacs/WinnerMode][winner-mode]] to undo window-related changes: While it comes with Emacs, I use [[https://www.emacswiki.org/emacs/WinnerMode][winner-mode]] to undo window-related changes:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package winner (use-package winner
:custom :custom
(winner-dont-bind-my-keys t) (winner-dont-bind-my-keys t)
:config :config
(winner-mode +1)) (winner-mode +1))
#+end_src #+end_src
Use the [[https://github.com/abo-abo/ace-window][ace-window]] project to jump to any window you see: Use the [[https://github.com/abo-abo/ace-window][ace-window]] project to jump to any window you see:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ace-window) (use-package ace-window
:bind ("s-w" . ace-window))
#+end_src #+end_src
This package, bound to ~SPC w w~, also allows operations specified before choosing the window: This package, bound to ~SPC w w~, also allows operations specified before choosing the window:
- ~x~ - delete window - ~x~ - delete window
- ~m~ - swap windows - ~m~ - swap windows, which allows you to place the current buffer in any other window
- ~M~ - move window - ~j~ - switch to a buffer in any other window
- ~c~ - copy window - ~?~ - show the rest of the command bindings
- ~j~ - select buffer
- ~n~ - select the previous window
- ~u~ - select buffer in the other window
- ~c~ - split window, either vertically or horizontally
- ~v~ - split window vertically
- ~b~ - split window horizontally
- ~o~ - maximize current window
- ~?~ - show these command bindings
Keep in mind, these shortcuts work with more than two windows open. For instance, ~SPC w w x 3~ closes the "3" window. Keep in mind, these shortcuts work with more than two windows open. For instance, ~SPC w w x 3~ closes the "3" window.
To jump to a window even quicker, use the [[https://github.com/deb0ch/emacs-winum][winum package]]: To jump to a window even quicker, use the [[https://github.com/deb0ch/emacs-winum][winum package]]:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package winum (use-package winum
:config :config
(winum-mode +1)) (winum-mode +1))
#+end_src #+end_src
And when creating new windows, why isn't the new window selected? And when creating new windows, why isn't the new window selected?
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -834,9 +823,9 @@ This is nice since the window numbers are always present on a Doom modeline, but
The ~0~ key/window should be always associated with a project-specific tree window: The ~0~ key/window should be always associated with a project-specific tree window:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-to-list 'winum-assign-functions (add-to-list 'winum-assign-functions
(lambda () (lambda ()
(when (string-match-p (buffer-name) ".*\\*NeoTree\\*.*") 10))) (when (string-match-p (buffer-name) ".*\\*NeoTree\\*.*") 10)))
#+end_src #+end_src
Let's try this out with a Hydra since some I can /repeat/ some commands (e.g. enlarge window). It also allows me to organize the helper text. Let's try this out with a Hydra since some I can /repeat/ some commands (e.g. enlarge window). It also allows me to organize the helper text.
@ -845,17 +834,16 @@ Let's try this out with a Hydra since some I can /repeat/ some commands (e.g. en
:config :config
(defhydra hydra-window-resize (:color blue :hint nil) " (defhydra hydra-window-resize (:color blue :hint nil) "
_w_: select _n_: new _^_: taller (t) _z_: Swap _+_: text larger _w_: select _n_: new _^_: taller (t) _z_: Swap _+_: text larger
_c_: cycle _d_: delete _V_: shorter (T) _u_: undo _-_: text smaller _c_: cycle _x_: delete _V_: shorter (T) _u_: undo _-_: text smaller
_j_: go up _=_: balance _>_: wider _U_: undo+ _F_: font larger _j_: go up _e_: balance _>_: wider _U_: undo+ _F_: font larger
_k_: down _m_: maximize _<_: narrower _r_: redo _f_: font smaller _k_: down _o_: maximize _<_: narrower _r_: redo _f_: font smaller
_h_: left _s_: h-split _e_: balanced _R_: redo+ _0_: toggle neotree _h_: left _b_: h-split _e_: balanced _R_: redo+ _0_: toggle neotree
_l_: right _v_: v-split _o_: choose by number (also 1-9) _l_: right _v_: v-split _o_: choose by number (also 1-9)
" "
("w" ace-window) ("w" ace-window)
("c" other-window) ("c" other-window)
("=" balance-windows) ("o" delete-other-windows)
("m" delete-other-windows) ("x" delete-window)
("d" delete-window)
("D" ace-delete-window) ("D" ace-delete-window)
("z" ace-swap-window) ("z" ace-swap-window)
@ -872,7 +860,7 @@ Let's try this out with a Hydra since some I can /repeat/ some commands (e.g. en
("l" evil-window-right) ("l" evil-window-right)
("o" other-window) ("o" other-window)
("s" evil-window-split) ("b" evil-window-split)
("v" evil-window-vsplit) ("v" evil-window-vsplit)
("F" font-size-increase :color pink) ("F" font-size-increase :color pink)