]> code.delx.au - gnu-emacs-elpa/blob - packages/hydra/hydra-examples.el
hydra: New package
[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 ;;; Code:
27
28 (require 'hydra)
29
30 (defvar hydra-example-text-scale
31 '(("g" text-scale-increase "zoom in")
32 ("l" text-scale-decrease "zoom out"))
33 "A two-headed hydra for text scale manipulation.")
34
35 (require 'windmove)
36
37 (defun hydra-move-splitter-left ()
38 "Move window splitter left."
39 (interactive)
40 (if (let ((windmove-wrap-around))
41 (windmove-find-other-window 'right))
42 (shrink-window-horizontally 1)
43 (enlarge-window-horizontally 1)))
44
45 (defun hydra-move-splitter-right ()
46 "Move window splitter right."
47 (interactive)
48 (if (let ((windmove-wrap-around))
49 (windmove-find-other-window 'right))
50 (enlarge-window-horizontally 1)
51 (shrink-window-horizontally 1)))
52
53 (defun hydra-move-splitter-up ()
54 "Move window splitter up."
55 (interactive)
56 (if (let ((windmove-wrap-around))
57 (windmove-find-other-window 'up))
58 (enlarge-window 1)
59 (shrink-window 1)))
60
61 (defun hydra-move-splitter-down ()
62 "Move window splitter down."
63 (interactive)
64 (if (let ((windmove-wrap-around))
65 (windmove-find-other-window 'up))
66 (shrink-window 1)
67 (enlarge-window 1)))
68
69 (defvar hydra-example-move-window-splitter
70 '(("h" hydra-move-splitter-left)
71 ("j" hydra-move-splitter-down)
72 ("k" hydra-move-splitter-up)
73 ("l" hydra-move-splitter-right))
74 "A four-headed hydra for the window splitter manipulation.
75 Works best if you have not more than 4 windows.")
76
77 (defvar hydra-example-goto-error
78 '(("h" first-error "first")
79 ("j" next-error "next")
80 ("k" previous-error "prev"))
81 "A three-headed hydra for jumping between \"errors\".
82 Useful for e.g. `occur', `rgrep' and the like.")
83
84 (provide 'hydra-examples)
85 ;;; hydra-examples.el ends here