[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a071b60 09/28: README.md: update
From: |
Oleh Krehel |
Subject: |
[elpa] master a071b60 09/28: README.md: update |
Date: |
Sun, 22 Mar 2015 16:34:41 +0000 |
branch: master
commit a071b604144c78d2b3021921b98b7228e231b19f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
README.md: update
---
README.md | 104 +++++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 71 insertions(+), 33 deletions(-)
diff --git a/README.md b/README.md
index 70b31bf..e0441a0 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,21 @@
[](https://travis-ci.org/abo-abo/hydra)
-This is a package for GNU Emacs that can be used to tie related
-commands into a family of short bindings with a common prefix - a
-Hydra.
+This is a package for GNU Emacs that can be used to tie related commands into
a family of short
+bindings with a common prefix - a Hydra.
-
+
-Once you summon the Hydra through the prefixed binding (the body + any
-one head), all heads can be called in succession with only a short
-extension.
+Once you summon the Hydra through the prefixed binding (the body + any one
head), all heads can be
+called in succession with only a short extension.
-The Hydra is vanquished once Hercules, any binding that isn't the
-Hydra's head, arrives. Note that Hercules, besides vanquishing the
-Hydra, will still serve his orignal purpose, calling his proper
-command. This makes the Hydra very seamless, it's like a minor mode
-that disables itself auto-magically.
+The Hydra is vanquished once Hercules, any binding that isn't the Hydra's
head, arrives. Note that
+Hercules, besides vanquishing the Hydra, will still serve his orignal purpose,
calling his proper
+command. This makes the Hydra very seamless, it's like a minor mode that
disables itself
+auto-magically.
-## Sample global Hydras
-### Zoom
+## Sample Hydras
+
+### The one with the least amount of code
```cl
(defhydra hydra-zoom (global-map "<f2>")
@@ -26,32 +24,72 @@ that disables itself auto-magically.
("l" text-scale-decrease "out"))
```
-### Goto-error
+With this simple code, you can:
-```cl
-(defhydra hydra-error (global-map "M-g")
- "goto-error"
- ("h" first-error "first")
- ("j" next-error "next")
- ("k" previous-error "prev")
- ("v" recenter-top-bottom "recenter")
- ("q" nil "quit"))
-```
+- Start zooming in with <kbd><f2> g</kbd>.
+- Continue to zoom in with <kbd>g</kbd>.
+- Or zoom out with <kbd>l</kbd>.
+- Zoom in five times at once with <kbd>5g</kbd>.
+- Stop zooming with *any* key that isn't <kbd>g</kbd> or <kbd>l</kbd>.
+
+### The impressive-looking one
+
+Here's the result of pressing <kbd>.</kbd> in the good-old Buffer menu:
-### Splitter
+
+
+The code is large but very simple:
```cl
-(require 'hydra-examples)
-(defhydra hydra-splitter (global-map "C-M-s")
- "splitter"
- ("h" hydra-move-splitter-left)
- ("j" hydra-move-splitter-down)
- ("k" hydra-move-splitter-up)
- ("l" hydra-move-splitter-right))
+(defhydra hydra-buffer-menu (:color pink
+ :hint nil)
+ "
+^Mark^ ^Unmark^ ^Actions^ ^Search
+^^^^^^^^-----------------------------------------------------------------
(__)
+_m_: mark _u_: unmark _x_: execute _R_: re-isearch
(oo)
+_s_: save _U_: unmark up _b_: bury _I_: isearch
/------\\/
+_d_: delete ^ ^ _g_: refresh _O_: multi-occur
/ | ||
+_D_: delete up ^ ^ _T_: files only: %
-28`Buffer-menu-files-only^^ * /\\---/\\
+_~_: modified ^ ^ ^ ^ ^^
~~ ~~
+"
+ ("m" Buffer-menu-mark)
+ ("u" Buffer-menu-unmark)
+ ("U" Buffer-menu-backup-unmark)
+ ("d" Buffer-menu-delete)
+ ("D" Buffer-menu-delete-backwards)
+ ("s" Buffer-menu-save)
+ ("~" Buffer-menu-not-modified)
+ ("x" Buffer-menu-execute)
+ ("b" Buffer-menu-bury)
+ ("g" revert-buffer)
+ ("T" Buffer-menu-toggle-files-only)
+ ("O" Buffer-menu-multi-occur :color blue)
+ ("I" Buffer-menu-isearch-buffers :color blue)
+ ("R" Buffer-menu-isearch-buffers-regexp :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)
```
+Looking at the code you can see `hydra-buffer-menu` as sort of a namespace
construct that wraps each
+function that it's given in code that shows that hint and makes it easy to
call the related
+functions. One additional function is created and returned as the result of
`defhydra` -
+`hydra-buffer-menu/body`. This function does nothing except setting up the
hint and the keymap, and
+is usually the entry point to complex hydras.
+
+To write your own hydras, you can:
+
+- Either modify an existing hydra to do what you want to do.
+- Read the docstrings and comments in the source to learn the rules.
+
### Community wiki
-A few useful hydras are aggregated in projects [community
wiki](https://github.com/abo-abo/hydra/wiki/Hydras%20by%20Topic). Feel free to
add your own or edit existing ones.
+
+A good amount of useful hydras are aggregated in projects
+[community wiki](https://github.com/abo-abo/hydra/wiki/Hydras%20by%20Topic).
Feel free to add your
+own or edit the existing ones.
## Using the functions generated by `defhydra`
- [elpa] master 9f9dcf9 17/28: Bind [switch-frame] to `hydra-keyboard-quit', (continued)
- [elpa] master 9f9dcf9 17/28: Bind [switch-frame] to `hydra-keyboard-quit', Oleh Krehel, 2015/03/22
- [elpa] master 543e97b 19/28: Fix switch-frame handling., Oleh Krehel, 2015/03/22
- [elpa] master 97d6987 21/28: Add hydra-rectangle example, Oleh Krehel, 2015/03/22
- [elpa] master bfe65da 15/28: README.md: Fix up typos, Oleh Krehel, 2015/03/22
- [elpa] master d44bf58 22/28: Don't bind `hydra-keyboard-quit' in foreign keymaps, Oleh Krehel, 2015/03/22
- [elpa] master eb181fd 23/28: Call :post for :timeout, Oleh Krehel, 2015/03/22
- [elpa] master 30a073b 25/28: hydra.el (hydra-keyboard-quit): Clean up the message area, Oleh Krehel, 2015/03/22
- [elpa] master 8e4b1fa 24/28: lv.el (lv-message): Use setq-local for window-min-height, Oleh Krehel, 2015/03/22
- [elpa] master 498d78b 26/28: Set pink/amaranth override recursively, Oleh Krehel, 2015/03/22
- [elpa] master 7783f89 27/28: Minor fixes, Oleh Krehel, 2015/03/22
- [elpa] master a071b60 09/28: README.md: update,
Oleh Krehel <=
- [elpa] master 5aa7896 28/28: Merge commit '7783f89cdbb3e3ba57f232552729715148e0b9a1' from hydra, Oleh Krehel, 2015/03/22