Moved modal section into its own file.

This commit is contained in:
Micheal Smith
2025-10-30 13:50:08 -05:00
parent 97b4a23582
commit c6b1f34a2b
2 changed files with 119 additions and 222 deletions

View File

@@ -212,228 +212,7 @@ features.
#+INCLUDE: "config/social.org" :minlevel 1 #+INCLUDE: "config/social.org" :minlevel 1
* Hail Hydra?! #+INCLUDE: "config/modal.org" :minlevel 1
I find that [[https://github.com/abo-abo/hydra][Hydra]] is great for providing visual menus for tasks that might
otherwise be fairly unwieldy. I use them hydra's for windows, tabs, and a
few other things in the future perhaps.
** Tabs
Pretty simple tab hydra. Handles opening, closing, and simple navigation.
#+name: tab-hydra
#+begin_src emacs-lisp :tangle no
(defhydra hydra-tab (:color red :hint nil)
"
Movement^^ ^Modifier^
----------------------------------------------------------------
_h_ ← _n_ ew
_l_ → _c_ lose
"
("h" tab-previous)
("l" tab-next)
("n" tab-new)
("c" tab-close)
("SPC" nil))
(global-set-key (kbd "C-c t") 'hydra-tab/body)
#+end_src
** Windows
Quite a helpful window hydra. I cannot take credit for this. I copied it
from somewhere. When I find the link I'll add it here.
#+name: window-hydra
#+begin_src emacs-lisp :tangle no
(defhydra hydra-window (:color red :hint nil)
"
Movement^^ ^Split^ ^Switch^ ^Resize^
----------------------------------------------------------------
_h_ ← _v_ertical _b_uffer _q_ X←
_j_ ↓ _x_ horizontal _f_ind files _w_ X↓
_k_ ↑ _z_ undo _a_ce 1 _e_ X↑
_l_ → _Z_ reset _s_wap _r_ X→
_F_ollow _D_lt Other _S_ave max_i_mize
_SPC_ cancel _o_nly this _d_elete
"
("h" windmove-left )
("j" windmove-down )
("k" windmove-up )
("l" windmove-right )
("q" hydra-move-splitter-left)
("w" hydra-move-splitter-down)
("e" hydra-move-splitter-up)
("r" hydra-move-splitter-right)
("b" consult-buffer)
("f" consult-fd)
("F" follow-mode)
("a" (lambda ()
(interactive)
(ace-window 1)
(add-hook 'ace-window-end-once-hook
'hydra-window/body))
)
("v" (lambda ()
(interactive)
(split-window-right)
(windmove-right))
)
("x" (lambda ()
(interactive)
(split-window-below)
(windmove-down))
)
("s" (lambda ()
(interactive)
(ace-window 4)
(add-hook 'ace-window-end-once-hook
'hydra-window/body)))
("S" save-buffer)
("d" delete-window)
("D" (lambda ()
(interactive)
(ace-window 16)
(add-hook 'ace-window-end-once-hook
'hydra-window/body))
)
("o" delete-other-windows)
("i" ace-maximize-window)
("z" (progn
(winner-undo)
(setq this-command 'winner-undo))
)
("Z" winner-redo)
("SPC" nil))
(global-set-key (kbd "C-c w") 'hydra-window/body)
#+end_src
** Pulling it all together
#+begin_src emacs-lisp
(use-package hydra
:demand t
:config
<<tab-hydra>>
<<window-hydra>>)
#+end_src
* Modal Editing
I like using =vi= inspired modal editing. For a while I tried project evil, but
I had issues keeping up with all the binding management. This is how I came to
start using [[https://github.com/meow-edit/meow][meow]]. Aside from motions and a few other changes the meow system
mostly keeps emacs bindings similar, and also accessible via space. This
way you can switch between meow, and emacs bindings pretty seemlessly.
Here are my bindings which come from the Meow wiki. It is /mostly/ akin to
=vi= bindings. Though deletion and line editing are a good deal different.
#+begin_src emacs-lisp
(defun meow-setup ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(dolist (state '((notmuch-hello-mode . motion)
(notmuch-search-mode . motion)
(notmuch-tree-mode . motion)
(notmuch-show-mode . motion)))
(add-to-list 'meow-mode-state-list state))
(meow-motion-define-key
'("j" . meow-next)
'("k" . meow-prev)
'("<escape>" . ignore))
(meow-leader-define-key
;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument)
'("2" . meow-digit-argument)
'("3" . meow-digit-argument)
'("4" . meow-digit-argument)
'("5" . meow-digit-argument)
'("6" . meow-digit-argument)
'("7" . meow-digit-argument)
'("8" . meow-digit-argument)
'("9" . meow-digit-argument)
'("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key)
'("?" . meow-cheatsheet))
(meow-normal-define-key
'("C-," . major-mode-hydra)
'("0" . meow-expand-0)
'("9" . meow-expand-9)
'("8" . meow-expand-8)
'("7" . meow-expand-7)
'("6" . meow-expand-6)
'("5" . meow-expand-5)
'("4" . meow-expand-4)
'("3" . meow-expand-3)
'("2" . meow-expand-2)
'("1" . meow-expand-1)
'("-" . negative-argument)
'(";" . meow-reverse)
'("," . meow-inner-of-thing)
'("." . meow-bounds-of-thing)
'("[" . meow-beginning-of-thing)
'("]" . meow-end-of-thing)
'("a" . meow-append)
'("A" . meow-open-below)
'("b" . meow-back-word)
'("B" . meow-back-symbol)
'("c" . meow-change)
'("d" . meow-delete)
'("D" . meow-backward-delete)
'("e" . meow-next-word)
'("E" . meow-next-symbol)
'("f" . meow-find)
'("g" . meow-cancel-selection)
'("G" . meow-grab)
'("h" . meow-left)
'("H" . meow-left-expand)
'("i" . meow-insert)
'("I" . meow-open-above)
'("j" . meow-next)
'("J" . meow-next-expand)
'("k" . meow-prev)
'("K" . meow-prev-expand)
'("l" . meow-right)
'("L" . meow-right-expand)
'("m" . meow-join)
'("n" . meow-search)
'("o" . meow-block)
'("O" . meow-to-block)
'("p" . meow-yank)
'("P" . meow-yank-pop)
'("q" . meow-quit)
'("Q" . meow-goto-line)
'("r" . meow-replace)
'("R" . meow-swap-grab)
'("s" . meow-kill)
'("t" . meow-till)
'("u" . meow-undo)
'("U" . meow-undo-in-selection)
'("v" . meow-visit)
'("w" . meow-mark-word)
'("W" . meow-mark-symbol)
'("x" . meow-line)
'("X" . meow-goto-line)
'("y" . meow-save)
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("/" . consult-line)
'("'" . repeat)
'("<escape>" . ignore)))
#+end_src
There's also no dependencies that rely on meow so adding this is pretty straight
forward.
#+begin_src emacs-lisp
(use-package meow
:ensure t
:config
(meow-setup)
(meow-global-mode 1))
#+end_src
* Quality of Life * Quality of Life

118
config/modal.org Normal file
View File

@@ -0,0 +1,118 @@
* Modal Editing
I like using =vi= inspired modal editing. For a while I tried project evil, but
I had issues keeping up with all the binding management. This is how I came to
start using [[https://github.com/meow-edit/meow][meow]]. Aside from motions and a few other changes the meow system
mostly keeps emacs bindings similar, and also accessible via space. This
way you can switch between meow, and emacs bindings pretty seemlessly.
Here are my bindings which come from the Meow wiki. It is /mostly/ akin to
=vi= bindings. Though deletion and line editing are a good deal different.
#+begin_src emacs-lisp
(defun meow-setup ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(dolist (state '((notmuch-hello-mode . motion)
(notmuch-search-mode . motion)
(notmuch-tree-mode . motion)
(notmuch-show-mode . motion)))
(add-to-list 'meow-mode-state-list state))
(meow-motion-define-key
'("j" . meow-next)
'("k" . meow-prev)
'("<escape>" . ignore))
(meow-leader-define-key
;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument)
'("2" . meow-digit-argument)
'("3" . meow-digit-argument)
'("4" . meow-digit-argument)
'("5" . meow-digit-argument)
'("6" . meow-digit-argument)
'("7" . meow-digit-argument)
'("8" . meow-digit-argument)
'("9" . meow-digit-argument)
'("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key)
'("?" . meow-cheatsheet))
(meow-normal-define-key
'("C-," . major-mode-hydra)
'("0" . meow-expand-0)
'("9" . meow-expand-9)
'("8" . meow-expand-8)
'("7" . meow-expand-7)
'("6" . meow-expand-6)
'("5" . meow-expand-5)
'("4" . meow-expand-4)
'("3" . meow-expand-3)
'("2" . meow-expand-2)
'("1" . meow-expand-1)
'("-" . negative-argument)
'(";" . meow-reverse)
'("," . meow-inner-of-thing)
'("." . meow-bounds-of-thing)
'("[" . meow-beginning-of-thing)
'("]" . meow-end-of-thing)
'("a" . meow-append)
'("A" . meow-open-below)
'("b" . meow-back-word)
'("B" . meow-back-symbol)
'("c" . meow-change)
'("d" . meow-delete)
'("D" . meow-backward-delete)
'("e" . meow-next-word)
'("E" . meow-next-symbol)
'("f" . meow-find)
'("g" . meow-cancel-selection)
'("G" . meow-grab)
'("h" . meow-left)
'("H" . meow-left-expand)
'("i" . meow-insert)
'("I" . meow-open-above)
'("j" . meow-next)
'("J" . meow-next-expand)
'("k" . meow-prev)
'("K" . meow-prev-expand)
'("l" . meow-right)
'("L" . meow-right-expand)
'("m" . meow-join)
'("n" . meow-search)
'("o" . meow-block)
'("O" . meow-to-block)
'("p" . meow-yank)
'("P" . meow-yank-pop)
'("q" . meow-quit)
'("Q" . meow-goto-line)
'("r" . meow-replace)
'("R" . meow-swap-grab)
'("s" . meow-kill)
'("t" . meow-till)
'("u" . meow-undo)
'("U" . meow-undo-in-selection)
'("v" . meow-visit)
'("w" . meow-mark-word)
'("W" . meow-mark-symbol)
'("x" . meow-line)
'("X" . meow-goto-line)
'("y" . meow-save)
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("/" . consult-line)
'("'" . repeat)
'("<escape>" . ignore)))
#+end_src
There's also no dependencies that rely on meow so adding this is pretty straight
forward.
#+begin_src emacs-lisp
(use-package meow
:ensure t
:config
(meow-setup)
(meow-global-mode 1))
#+end_src