]> code.delx.au - gnu-emacs-elpa/blob - packages/hydra/hydra-examples.el
Merge commit '59de0b7591713d38c6d5c99cb49c4a4cc434a272' from context-coloring
[gnu-emacs-elpa] / packages / hydra / hydra-examples.el
1 ;;; hydra-examples.el --- Some applications for Hydra
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5 ;; Author: Oleh Krehel
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23 ;;
24 ;; These are the sample Hydras that you can use.
25 ;;
26 ;; Note that the better way to create Hydras is with `defhydra':
27 ;;
28 ;; (defhydra hydra-zoom (global-map "<f2>")
29 ;; "zoom"
30 ;; ("g" text-scale-increase "in")
31 ;; ("l" text-scale-decrease "out"))
32 ;;
33 ;; This way, you have more options, and everything is in one place.
34
35 ;;; Code:
36
37 (require 'hydra)
38
39 (defvar hydra-example-text-scale
40 '(("g" text-scale-increase "zoom in")
41 ("l" text-scale-decrease "zoom out"))
42 "A two-headed hydra for text scale manipulation.")
43
44 (require 'windmove)
45
46 (defun hydra-move-splitter-left (arg)
47 "Move window splitter left."
48 (interactive "p")
49 (if (let ((windmove-wrap-around))
50 (windmove-find-other-window 'right))
51 (shrink-window-horizontally arg)
52 (enlarge-window-horizontally arg)))
53
54 (defun hydra-move-splitter-right (arg)
55 "Move window splitter right."
56 (interactive "p")
57 (if (let ((windmove-wrap-around))
58 (windmove-find-other-window 'right))
59 (enlarge-window-horizontally arg)
60 (shrink-window-horizontally arg)))
61
62 (defun hydra-move-splitter-up (arg)
63 "Move window splitter up."
64 (interactive "p")
65 (if (let ((windmove-wrap-around))
66 (windmove-find-other-window 'up))
67 (enlarge-window arg)
68 (shrink-window arg)))
69
70 (defun hydra-move-splitter-down (arg)
71 "Move window splitter down."
72 (interactive "p")
73 (if (let ((windmove-wrap-around))
74 (windmove-find-other-window 'up))
75 (shrink-window arg)
76 (enlarge-window arg)))
77
78 (defvar hydra-example-move-window-splitter
79 '(("h" hydra-move-splitter-left)
80 ("j" hydra-move-splitter-down)
81 ("k" hydra-move-splitter-up)
82 ("l" hydra-move-splitter-right))
83 "A four-headed hydra for the window splitter manipulation.
84 Works best if you have not more than 4 windows.")
85
86 (defvar hydra-example-goto-error
87 '(("h" first-error "first")
88 ("j" next-error "next")
89 ("k" previous-error "prev"))
90 "A three-headed hydra for jumping between \"errors\".
91 Useful for e.g. `occur', `rgrep' and the like.")
92
93 (defvar hydra-example-windmove
94 '(("h" windmove-left)
95 ("j" windmove-down)
96 ("k" windmove-up)
97 ("l" windmove-right))
98 "A four-headed hydra for `windmove'.")
99
100 (provide 'hydra-examples)
101 ;;; hydra-examples.el ends here