]> code.delx.au - gnu-emacs-elpa/blob - ivy-hydra.el
Bind "C-o" to hydra-ivy/body
[gnu-emacs-elpa] / ivy-hydra.el
1 ;;; ivy-hydra.el --- Additional key bindings for Ivy -*- lexical-binding: t -*-
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 ;; This file 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, or (at your option)
12 ;; any later version.
13
14 ;; This program 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 ;; For a full copy of the GNU General Public License
20 ;; see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23 ;;
24 ;; This package provides the `hydra-ivy/body' command, which is a
25 ;; quasi-prefix map, with many useful bindings. These bindings are
26 ;; shorter than usual, using mostly unprefixed keys.
27
28 ;;; Code:
29 (require 'hydra)
30 (require 'ivy)
31
32 (unless (package-installed-p 'hydra)
33 (defmacro defhydra (name &rest _)
34 "This is a stub for the uninstalled `hydra' package."
35 `(defun ,(intern (format "%S/body" name)) ()
36 (interactive)
37 (if (yes-or-no-p "Package `hydra' not installed. Install?")
38 (progn
39 (package-install 'hydra)
40 (save-window-excursion
41 (find-library "ivy-hydra")
42 (byte-compile-file (buffer-file-name) t)))
43 (error "Please install `hydra' and recompile/reinstall `ivy-hydra'")))))
44
45 (defhydra hydra-ivy (:hint nil
46 :color pink)
47 "
48 ^^^^^^ ^Yes^ ^No^ ^Maybe^
49 ^^^^^^^^^^^^^^---------------------------------------
50 ^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %s(if ivy-calling \"on\" \"off\")
51 _h_ ^✜^ _l_ _d_one _o_ops
52 ^ ^ _j_ ^ ^
53 "
54 ;; arrows
55 ("h" ivy-beginning-of-buffer)
56 ("j" ivy-next-line)
57 ("k" ivy-previous-line)
58 ("l" ivy-end-of-buffer)
59 ;; actions
60 ("o" keyboard-escape-quit :exit t)
61 ("i" nil)
62 ("f" ivy-alt-done :exit nil)
63 ("d" ivy-done :exit t)
64 ("c" ivy-toggle-calling))
65
66 (provide 'ivy-hydra)
67
68 ;;; ivy-hydra.el ends here