[Hydra] Move hydras to separate package

This allows ‘db-utils’ to not be dependent on ‘hydra’
This commit is contained in:
Daniel - 2019-03-02 11:06:55 +01:00
parent 378b608c2b
commit 4fb6e3e5c1
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
3 changed files with 78 additions and 63 deletions

10
init.el
View File

@ -551,10 +551,6 @@ search commands like `db/helm-shortcuts."
db/turn-off-local-electric-pair-mode
db/export-diary
db/add-symbols-to-TeX-input-method
hydra-ispell/body
hydra-toggle/body
hydra-zoom/body
hydra-rectangle/body
db/two-monitors-xrandr
db/one-monitor-xrandr
db/pretty-print-xml
@ -565,6 +561,12 @@ search commands like `db/helm-shortcuts."
(use-package hydra
:commands (defhydra))
(use-package db-hydras
:commands (hydra-ispell/body
hydra-toggle/body
hydra-zoom/body
hydra-rectangle/body))
(use-package magit
:commands (magit-status)
:init (setq magit-diff-refine-hunk t

72
site-lisp/db-hydras.el Normal file
View File

@ -0,0 +1,72 @@
;;; db-hydras.el --- Personal hydras ' -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(require 'hydra)
;;; Hydras
(defhydra hydra-ispell (:color blue)
"ispell"
("g" (lambda ()
(interactive)
(setq ispell-dictionary "de_DE")
(ispell-change-dictionary "de_DE"))
"german")
("e" (lambda ()
(interactive)
(setq ispell-dictionary "en_US")
(ispell-change-dictionary "en_US"))
"english"))
(defhydra hydra-toggle (:color blue)
"toggle"
("c" column-number-mode "column")
("d" toggle-debug-on-error "debug-on-error")
("e" toggle-debug-on-error "debug-on-error")
("f" auto-fill-mode "auto-fill")
("l" toggle-truncate-lines "truncate lines")
("q" toggle-debug-on-quit "debug-on-quit")
("r" read-only-mode "read-only"))
;; zooming with single keystrokes (from oremacs)
(defhydra hydra-zoom (:color red)
"zoom"
("g" text-scale-increase "increase")
("l" text-scale-decrease "decrease"))
(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" backward-char nil)
("l" forward-char nil)
("k" previous-line nil)
("j" next-line 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)
("e" rectangle-exchange-point-and-mark nil)
("o" nil nil))
;; End
(provide 'db-hydras)
;; db-hydras.el ends here

View File

@ -473,65 +473,6 @@ This is done only if the value of this variable is not null."
("\\mathcalS" ?𝒮)
("\\mathfrakP" ?𝔓)))))
;;; Hydras
(defhydra hydra-ispell (:color blue)
"ispell"
("g" (lambda ()
(interactive)
(setq ispell-dictionary "de_DE")
(ispell-change-dictionary "de_DE"))
"german")
("e" (lambda ()
(interactive)
(setq ispell-dictionary "en_US")
(ispell-change-dictionary "en_US"))
"english"))
(defhydra hydra-toggle (:color blue)
"toggle"
("c" column-number-mode "column")
("d" toggle-debug-on-error "debug-on-error")
("e" toggle-debug-on-error "debug-on-error")
("f" auto-fill-mode "auto-fill")
("l" toggle-truncate-lines "truncate lines")
("q" toggle-debug-on-quit "debug-on-quit")
("r" read-only-mode "read-only"))
;; zooming with single keystrokes (from oremacs)
(defhydra hydra-zoom (:color red)
"zoom"
("g" text-scale-increase "increase")
("l" text-scale-decrease "decrease"))
(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" backward-char nil)
("l" forward-char nil)
("k" previous-line nil)
("j" next-line 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)
("e" rectangle-exchange-point-and-mark nil)
("o" nil nil))
;;; Wrappers for external applications