Skip to content

Instantly share code, notes, and snippets.

@higham
Created April 14, 2021 19:41
Show Gist options
  • Save higham/4c71f4a296fdcde552b0f6363e4ea1b4 to your computer and use it in GitHub Desktop.
Save higham/4c71f4a296fdcde552b0f6363e4ea1b4 to your computer and use it in GitHub Desktop.
Emacs Hydras
(use-package hydra
:config
(global-set-key (kbd "C-x m") 'hydra-major/body)
(global-set-key (kbd "<f3>") 'hydra-bib-etc/body)
(global-set-key (kbd "C-<f3>") 'hydra-dired/body)
)
(defhydra hydra-major (:color blue :columns 4)
"major-mode"
("b" bibtex-mode "bibtex")
("l" latex-mode "latex")
("o" org-mode "org")
("s" lisp-mode "lisp")
("t" text-mode "text")
("c" 'toggle-truncate-lines "tog-trunc-lines")
("f" auto-fill-mode "auto-fill")
("h" html-mode "html")
("m" message-mode "msg")
("n" narrow-or-widen-dwim "narw-wide")
("r" read-only-mode "read-only")
("u" linum-mode "lin-num")
("q" nil "cancel")
)
(defhydra hydra-bib-etc (:color blue :columns 4)
"bib"
("<f3>" helm-bibtex "helm-bibtex")
("<f4>" helm-resume "helm-resume")
;; ("b" (lambda () (interactive) (dired "~/bib")) "bib")
("b" (dired "~/bib") "bib")
("d" (dired "~/texmf/bibtex/bib") "texmf/bib")
("c" (find-file "~/texmf/bibtex/bib/cut.bib") "cut")
("l" (find-file "~/texmf/bibtex/bib/la.bib") "la")
("h" (find-file "~/texmf/bibtex/bib/njhigham.bib") "higham")
("m" (find-file "~/texmf/bibtex/bib/misc.bib") "misc")
("e" (find-file "~/texmf/bibtex/bib/ode.bib") "ode")
("o" (switch-to-buffer "*org*") "org*")
("s" (find-file "~/texmf/bibtex/bib/strings.bib") "strings")
("x" (switch-to-buffer "*scratch*") "scratch*")
("t" (switch-to-buffer "*text*") "text*")
("z" scratch)
)
(global-set-key (kbd "M-<f5>") 'hydra-zoom/body)
(defhydra hydra-zoom (:color red)
"zoom"
("g" text-scale-increase "in")
("l" text-scale-decrease "out")
("r" (text-scale-adjust 0) "reset")
("q" nil "quit"))
;; http://ericjmritz.name/2015/10/14/some-personal-hydras-for-gnu-emacs/
(defhydra hydra-move-org (:color red :columns 3)
"Org movements"
("n" outline-next-visible-heading "next heading")
("p" outline-previous-visible-heading "prev heading")
("N" org-forward-heading-same-level "next heading at same level")
("P" org-backward-heading-same-level "prev heading at same level")
("u" outline-up-heading "up heading")
("g" org-goto "goto" :exit t))
(global-set-key (kbd "M-<f9>") 'hydra-move-org/body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment