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:
2020-06-24 01:30:02 +02:00
parent e1ce2787ad
commit c83fca4cad

View File

@@ -1,17 +1,105 @@
;;; 102-hydra.el --- tie related commands into a family of short bindings
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Author: Oleh Krehel
;;; Commentary:
;; Hydra enables you to tie related commands into a family of short bindings
;; with a common prefix - a Hydra.
;; reference: https://github.com/abo-abo/hydra
;; examples: https://github.com/abo-abo/hydra/blob/05871dd6c8af7b2268bd1a10eb9f8a3e423209cd/hydra-examples.el#L337
;;; Code:
(use-package hydra
:config
(setq hydra-lv nil))
;;(setq hydra-lv nil)
(defun hydra-move-splitter-left (arg)
"Move window splitter left."
(interactive "p")
(if (let ((windmove-wrap-around))
(windmove-find-other-window 'right))
(shrink-window-horizontally arg)
(enlarge-window-horizontally arg)))
(defun hydra-move-splitter-right (arg)
"Move window splitter right."
(interactive "p")
(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 ()
(defhydra hydra-zoom (:color blue)
"zoom"
("+" text-scale-increase "in")
("=" text-scale-increase "in")
@@ -25,5 +113,48 @@
("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)
;; Local Variables:
;; no-byte-compile: t
;; End:
;;; 102-hydra.el ends here