102-hydra: update functions as referenced in upstream documentation
* update reference hyperlink * introduce new defun Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1,29 +1,160 @@
|
|||||||
;;; 102-hydra.el --- tie related commands into a family of short bindings
|
;;; 102-hydra.el --- tie related commands into a family of short bindings
|
||||||
|
|
||||||
|
;; Copyright (C) 2015 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
;; Author: Oleh Krehel
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; Hydra enables you to tie related commands into a family of short bindings
|
;; Hydra enables you to tie related commands into a family of short bindings
|
||||||
;; with a common prefix - a Hydra.
|
;; with a common prefix - a Hydra.
|
||||||
;; reference: https://github.com/abo-abo/hydra
|
;; reference: https://github.com/abo-abo/hydra
|
||||||
|
;; examples: https://github.com/abo-abo/hydra/blob/05871dd6c8af7b2268bd1a10eb9f8a3e423209cd/hydra-examples.el#L337
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(use-package hydra
|
(use-package hydra
|
||||||
:config
|
:config
|
||||||
(setq hydra-lv nil))
|
;;(setq hydra-lv nil)
|
||||||
|
|
||||||
;; Zooming
|
(defun hydra-move-splitter-left (arg)
|
||||||
(defhydra hydra-zoom ()
|
"Move window splitter left."
|
||||||
"zoom"
|
(interactive "p")
|
||||||
("+" text-scale-increase "in")
|
(if (let ((windmove-wrap-around))
|
||||||
("=" text-scale-increase "in")
|
(windmove-find-other-window 'right))
|
||||||
("-" text-scale-decrease "out")
|
(shrink-window-horizontally arg)
|
||||||
("_" text-scale-decrease "out")
|
(enlarge-window-horizontally arg)))
|
||||||
("0" (text-scale-adjust 0) "reset")
|
|
||||||
("q" nil "quit" :color blue))
|
|
||||||
|
|
||||||
(bind-keys ("C-x C-0" . hydra-zoom/body)
|
(defun hydra-move-splitter-right (arg)
|
||||||
("C-x C-=" . hydra-zoom/body)
|
"Move window splitter right."
|
||||||
("C-x C--" . hydra-zoom/body)
|
(interactive "p")
|
||||||
("C-x C-+" . hydra-zoom/body))
|
(if (let ((windmove-wrap-around))
|
||||||
|
(windmove-find-other-window 'right))
|
||||||
|
(enlarge-window-horizontally arg)
|
||||||
|
(shrink-window-horizontally arg)))
|
||||||
|
|
||||||
|
(defun hydra-move-splitter-up (arg)
|
||||||
|
"Move window splitter up."
|
||||||
|
(interactive "p")
|
||||||
|
(if (let ((windmove-wrap-around))
|
||||||
|
(windmove-find-other-window 'up))
|
||||||
|
(enlarge-window arg)
|
||||||
|
(shrink-window arg)))
|
||||||
|
|
||||||
|
(defun hydra-move-splitter-down (arg)
|
||||||
|
"Move window splitter down."
|
||||||
|
(interactive "p")
|
||||||
|
(if (let ((windmove-wrap-around))
|
||||||
|
(windmove-find-other-window 'up))
|
||||||
|
(shrink-window arg)
|
||||||
|
(enlarge-window arg)))
|
||||||
|
|
||||||
|
(defvar rectangle-mark-mode)
|
||||||
|
(defun hydra-ex-point-mark ()
|
||||||
|
"Exchange point and mark."
|
||||||
|
(interactive)
|
||||||
|
(if rectangle-mark-mode
|
||||||
|
(rectangle-exchange-point-and-mark)
|
||||||
|
(let ((mk (mark)))
|
||||||
|
(rectangle-mark-mode 1)
|
||||||
|
(goto-char mk))))
|
||||||
|
|
||||||
|
;; move window splitter
|
||||||
|
(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))
|
||||||
|
|
||||||
|
;; Hydra powered rectangle mode
|
||||||
|
(require 'rect)
|
||||||
|
(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
|
||||||
|
:color pink
|
||||||
|
:post (deactivate-mark))
|
||||||
|
"
|
||||||
|
^_k_^ _d_elete _s_tring
|
||||||
|
_h_ _l_ _o_k _y_ank
|
||||||
|
^_j_^ _n_ew-copy _r_eset
|
||||||
|
^^^^ _e_xchange _u_ndo
|
||||||
|
^^^^ ^ ^ _p_aste
|
||||||
|
"
|
||||||
|
("h" rectangle-backward-char nil)
|
||||||
|
("l" rectangle-forward-char nil)
|
||||||
|
("k" rectangle-previous-line nil)
|
||||||
|
("j" rectangle-next-line nil)
|
||||||
|
("e" hydra-ex-point-mark nil)
|
||||||
|
("n" copy-rectangle-as-kill nil)
|
||||||
|
("d" delete-rectangle nil)
|
||||||
|
("r" (if (region-active-p)
|
||||||
|
(deactivate-mark)
|
||||||
|
(rectangle-mark-mode 1)) nil)
|
||||||
|
("y" yank-rectangle nil)
|
||||||
|
("u" undo nil)
|
||||||
|
("s" string-rectangle nil)
|
||||||
|
("p" kill-rectangle nil)
|
||||||
|
("o" nil nil))
|
||||||
|
|
||||||
|
;; substitute default binding
|
||||||
|
(global-set-key (kbd "C-x SPC") 'hydra-rectangle/body)
|
||||||
|
|
||||||
|
;; Zooming
|
||||||
|
(defhydra hydra-zoom (:color blue)
|
||||||
|
"zoom"
|
||||||
|
("+" text-scale-increase "in")
|
||||||
|
("=" text-scale-increase "in")
|
||||||
|
("-" text-scale-decrease "out")
|
||||||
|
("_" text-scale-decrease "out")
|
||||||
|
("0" (text-scale-adjust 0) "reset")
|
||||||
|
("q" nil "quit" :color blue))
|
||||||
|
|
||||||
|
(bind-keys ("C-x C-0" . hydra-zoom/body)
|
||||||
|
("C-x C-=" . hydra-zoom/body)
|
||||||
|
("C-x C--" . hydra-zoom/body)
|
||||||
|
("C-x C-+" . hydra-zoom/body))
|
||||||
|
|
||||||
|
;; Code folding using origami
|
||||||
|
(defhydra hydra-origami (:color blue)
|
||||||
|
"
|
||||||
|
_o_pen node _O_pen node recurse _n_ext fold _s_how node only toggle _f_orward
|
||||||
|
_c_lose node _C_lose node recurse _p_revious fold toggle _r_ecurively toggle _a_ll
|
||||||
|
"
|
||||||
|
("o" origami-open-node)
|
||||||
|
("O" origami-open-node-recursively)
|
||||||
|
("c" origami-close-node)
|
||||||
|
("C" origami-close-node-recursively)
|
||||||
|
("n" origami-next-fold)
|
||||||
|
("p" origami-previous-fold)
|
||||||
|
("f" origami-forward-toggle-node)
|
||||||
|
("a" origami-toggle-all-nodes)
|
||||||
|
("r" origami-recursively-toggle-node)
|
||||||
|
("s" origami-show-only-node))
|
||||||
|
|
||||||
|
(global-set-key (kbd "<f9> o") 'hydra-origami/body)
|
||||||
|
(bind-keys ("C-x C-o" . hydra-origami/body))
|
||||||
|
|
||||||
|
;; Code folding using hideshow
|
||||||
|
(defhydra hydra-hideshow (:color blue)
|
||||||
|
"
|
||||||
|
_o_pen node _O_pen node recurse _n_ext fold _s_how node only toggle _f_orward
|
||||||
|
_c_lose node _C_lose node recurse _p_revious fold toggle _r_ecurively toggle _a_ll
|
||||||
|
"
|
||||||
|
("o" hs-show-block)
|
||||||
|
("O" hs-show-all)
|
||||||
|
("c" hs-hide-block)
|
||||||
|
("C" hs-hide-all)
|
||||||
|
("n" hs-show-block)
|
||||||
|
("p" hs-hide-block)
|
||||||
|
("f" hs-toggle-hiding)
|
||||||
|
("a" hs-toggle-hiding)
|
||||||
|
("r" hs-hide-level)
|
||||||
|
("s" hs-show_block))
|
||||||
|
|
||||||
|
(global-set-key (kbd "<f9> #") 'hydra-hideshow/body)
|
||||||
|
(bind-keys ("C-x C-#" . hydra-hideshow/body)))
|
||||||
|
|
||||||
(provide '102-hydra)
|
(provide '102-hydra)
|
||||||
|
;; Local Variables:
|
||||||
|
;; no-byte-compile: t
|
||||||
|
;; End:
|
||||||
;;; 102-hydra.el ends here
|
;;; 102-hydra.el ends here
|
||||||
|
|||||||
Reference in New Issue
Block a user