Hydra for Buffer-menu
20 Feb 2015Here's a little code I've made today for Buffer-menu-mode
:
(defhydra hydra-buffer-menu (:color pink)
"
Mark Unmark Actions Search
-------------------------------------------------------------------------
_m_: mark _u_: unmark _x_: execute _R_: re-isearch
_s_: save _U_: unmark up _b_: bury _I_: isearch
_d_: delete _g_: refresh _O_: multi-occur
_D_: delete up _T_: files only: %`Buffer-menu-files-only
_~_: modified
"
("m" Buffer-menu-mark nil)
("u" Buffer-menu-unmark nil)
("U" Buffer-menu-backup-unmark nil)
("d" Buffer-menu-delete nil)
("D" Buffer-menu-delete-backwards nil)
("s" Buffer-menu-save nil)
("~" Buffer-menu-not-modified nil)
("x" Buffer-menu-execute nil)
("b" Buffer-menu-bury nil)
("g" revert-buffer nil)
("T" Buffer-menu-toggle-files-only nil)
("O" Buffer-menu-multi-occur nil :color blue)
("I" Buffer-menu-isearch-buffers nil :color blue)
("R" Buffer-menu-isearch-buffers-regexp nil :color blue)
("c" nil "cancel")
("v" Buffer-menu-select "select" :color blue)
("o" Buffer-menu-other-window "other-window" :color blue)
("q" quit-window "quit" :color blue))
(define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body)
You can change the color on the top to your taste: either red or pink or amaranth will work. For extensive Hydras I tend to pick pink, since I don't want to quit by accident, while still keeping the non-head bindings. For small ones, red is better. Here's how the result looks like:
You can install the cow with:
apt-get moo
I didn't list it in the source, since Jekyll would wrap the long lines. The source is already in hydra-examples.el. You only have to:
(require 'hydra-examples)
(define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body)
I've been hearing some opinions lately that the growing number of Hydra options makes it intimidating or unclear. I hope that's not the majority's feeling and that the gentle repetitiveness of this example proves otherwise.
On the other hand, I've started reading "The Reasoned Schemer" this week. Now that's intimidating.