Add ui/hydra module

And conforms all existing hydras to the naming convention for
interactive commands, e.g.

  +vc-gutter-hydra -> +vc/gutter-hydra
This commit is contained in:
Henrik Lissner 2019-07-22 22:49:27 +02:00
parent 388267d256
commit d7ed52f3c7
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395
14 changed files with 116 additions and 105 deletions

View File

@ -199,10 +199,6 @@ localleader prefix."
(which-key-mode +1))
;;;###package hydra
(setq lv-use-seperator t)
;;
;;; `map!' macro

View File

@ -38,7 +38,6 @@
;; core-keybinds.el
(package! general)
(package! which-key)
(package! hydra)
;; autoload/debug.el
(package! esup)

View File

@ -25,6 +25,7 @@
doom-quit ; DOOM quit-message prompts when you quit Emacs
;;fill-column ; a `fill-column' indicator
hl-todo ; highlight TODO/FIXME/NOTE tags
;;hydra
;;indent-guides ; highlighted indent columns
modeline ; snazzy, Atom-inspired modeline, plus API
nav-flash ; blink the current line after jumping

View File

@ -1,32 +1,33 @@
;;; completion/ivy/autoload/hydras.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui hydra)
;;;###autoload
(after! ivy-hydra
(with-no-warnings
(defhydra+ hydra-ivy (:hint nil :color pink)
"
(eval-when-compile (require 'ivy-hydra))
;;;###autoload (autoload 'hydra-ivy/body "completion/ivy/autoload/hydras" nil nil)
(defhydra+ hydra-ivy (:hint nil :color pink)
"
Move ^^^^^^^^^^ | Call ^^^^ | Cancel^^ | Options^^ | Action _w_/_s_/_a_: %s(ivy-action-name)
----------^^^^^^^^^^-+--------------^^^^-+-------^^-+--------^^-+---------------------------------
_g_ ^ ^ _k_ ^ ^ _u_ | _f_orward _o_ccur | _i_nsert | _c_alling: %-7s(if ivy-calling \"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search
^^ _h_ ^+^ _l_ ^^ | _RET_ done ^^ | _q_uit | _m_atcher: %-7s(ivy--matcher-desc) _t_runcate: %-11`truncate-lines
_G_ ^ ^ _j_ ^ ^ _d_ | _TAB_ alt-done ^^ | ^ ^ | _<_/_>_: shrink/grow
"
;; arrows
("l" ivy-alt-done)
("h" ivy-backward-delete-char)
("g" ivy-beginning-of-buffer)
("G" ivy-end-of-buffer)
("d" ivy-scroll-up-command)
("u" ivy-scroll-down-command)
("e" ivy-scroll-down-command)
;; actions
("q" keyboard-escape-quit :exit t)
("<escape>" keyboard-escape-quit :exit t)
("TAB" ivy-alt-done :exit nil)
("RET" ivy-done :exit t)
("C-SPC" ivy-call-and-recenter :exit nil)
("f" ivy-call)
("c" ivy-toggle-calling)
("m" ivy-toggle-fuzzy)
("t" (setq truncate-lines (not truncate-lines)))
("o" ivy-occur :exit t))))
;; arrows
("l" ivy-alt-done)
("h" ivy-backward-delete-char)
("g" ivy-beginning-of-buffer)
("G" ivy-end-of-buffer)
("d" ivy-scroll-up-command)
("u" ivy-scroll-down-command)
("e" ivy-scroll-down-command)
;; actions
("q" keyboard-escape-quit :exit t)
("<escape>" keyboard-escape-quit :exit t)
("TAB" ivy-alt-done :exit nil)
("RET" ivy-done :exit t)
("C-SPC" ivy-call-and-recenter :exit nil)
("f" ivy-call)
("c" ivy-toggle-calling)
("m" ivy-toggle-fuzzy)
("t" (setq truncate-lines (not truncate-lines)))
("o" ivy-occur :exit t))

View File

@ -0,0 +1,41 @@
;;; emacs/vc/autoload/hydra.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui hydra)
;;;###autoload (autoload '+vc/smerge-hydra/body "emacs/vc/autoload/hydra" nil t)
(defhydra +vc/smerge-hydra (:hint nil
:pre (if (not smerge-mode) (smerge-mode 1))
;; Disable `smerge-mode' when quitting hydra if
;; no merge conflicts remain.
:post (smerge-auto-leave))
"
[smerge]
Movement Keep Diff Other
^_g_^ [_b_] base [_<_] upper/base [_C_] Combine
^_C-k_^ [_u_] upper [_=_] upper/lower [_r_] resolve
^_k_ ^ [_l_] lower [_>_] base/lower [_R_] remove
^_j_ ^ [_a_] all [_H_] hightlight
^_C-j_^ [_RET_] current [_E_] ediff
^_G_^ [_q_] quit
"
("g" (progn (goto-char (point-min)) (smerge-next)))
("G" (progn (goto-char (point-max)) (smerge-prev)))
("C-j" smerge-next)
("C-k" smerge-prev)
("j" next-line)
("k" previous-line)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("H" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("R" smerge-kill-current)
("q" nil :color blue))

View File

@ -40,42 +40,3 @@ info in the `header-line-format' is a good indication."
(propertize author 'face 'git-timemachine-minibuffer-author-face)
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
date-full date-relative))))
;;;###autoload (autoload '+vc-smerge-hydra/body "emacs/vc/autoload/vc" nil t)
(defhydra +vc-smerge-hydra (:hint nil
:pre (if (not smerge-mode) (smerge-mode 1))
;; Disable `smerge-mode' when quitting hydra if
;; no merge conflicts remain.
:post (smerge-auto-leave))
"
[smerge]
Movement Keep Diff Other
^_g_^ [_b_] base [_<_] upper/base [_C_] Combine
^_C-k_^ [_u_] upper [_=_] upper/lower [_r_] resolve
^_k_ ^ [_l_] lower [_>_] base/lower [_R_] remove
^_j_ ^ [_a_] all [_H_] hightlight
^_C-j_^ [_RET_] current [_E_] ediff
^_G_^ [_q_] quit
"
("g" (progn (goto-char (point-min)) (smerge-next)))
("G" (progn (goto-char (point-max)) (smerge-prev)))
("C-j" smerge-next)
("C-k" smerge-prev)
("j" next-line)
("k" previous-line)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("H" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("R" smerge-kill-current)
("q" nil :color blue))

View File

@ -55,7 +55,7 @@ Change ~+ein-notebook-dir~ to tell ein where to find your Jupityr notebooks.
#+END_SRC
** Using hydra
This module provides a batteries-included hydra - ~+ein-hydra~ - to make using ein
This module provides a batteries-included hydra - ~+ein/hydra~ - to make using ein
easier. Things like navigating between cells, workbook management etc, are greatly
simplified and are easily accessible. However, by default, it's not bound to any key.
Here's an example of how to bind it:
@ -63,6 +63,6 @@ Here's an example of how to bind it:
#+BEGIN_SRC emacs-lisp
(map! :map ein:notebook-mode-map
:localleader
"," #'+ein-hydra/body)
"," #'+ein/hydra/body)
#+END_SRC

View File

@ -0,0 +1,24 @@
;;; tools/ein/autoload.el -*- lexical-binding: t; -*-
(defun +ein--collect-ein-buffer-links ()
(let ((end (window-end))
points)
(save-excursion
(goto-char (window-start))
(while (re-search-forward "~?/.+\\|\s\\[" end t)
(push (+ (match-beginning 0) 1) points))
(nreverse points))))
;;;###autoload
(defun +ein/ace-link-ein ()
"Ace jump to links in ein notebooklist."
(interactive)
(require 'avy)
(let ((res (avy-with +ein/ace-link-ein
(avy--process
(+ein--collect-ein-buffer-links)
#'avy--overlay-pre))))
;(avy--style-fn avy-style)))))
(when (numberp res)
(goto-char (1+ res))
(widget-button-press (point)))))

View File

@ -1,30 +1,8 @@
;;; tools/ein/autoload.el -*- lexical-binding: t; -*-
;;; tools/ein/autoload/hydra.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui hydra)
(defun +ein--collect-ein-buffer-links ()
(let ((end (window-end))
points)
(save-excursion
(goto-char (window-start))
(while (re-search-forward "~?/.+\\|\s\\[" end t)
(push (+ (match-beginning 0) 1) points))
(nreverse points))))
;;;###autoload
(defun +ein/ace-link-ein ()
"Ace jump to links in ein notebooklist."
(interactive)
(require 'avy)
(let ((res (avy-with +ein/ace-link-ein
(avy--process
(+ein--collect-ein-buffer-links)
#'avy--overlay-pre))))
;(avy--style-fn avy-style)))))
(when (numberp res)
(goto-char (1+ res))
(widget-button-press (point)))))
;;;###autoload (autoload '+ein-hydra/body "tools/ein/autoload" nil t)
(defhydra +ein-hydra (:hint t :color red)
;;;###autoload (autoload '+ein/hydra/body "tools/ein/autoload" nil t)
(defhydra +ein/hydra (:hint t :color red)
"
Operations on Cells^^^^^^ Other
----------------------------^^^^^^ ----------------------------------^^^^

View File

@ -1,7 +1,8 @@
;;; tools/rgb/autoload.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui hydra)
;;;###autoload (autoload '+rgb-kurecolor-hydra/body "tools/rgb/autoload" nil t)
(defhydra +rgb-kurecolor-hydra (:color pink :hint nil)
;;;###autoload (autoload '+rgb/kurecolor-hydra/body "tools/rgb/autoload" nil t)
(defhydra +rgb/kurecolor-hydra (:color pink :hint nil)
"
Inc/Dec _w_/_W_ brightness _d_/_D_ saturation _e_/_E_ hue "
("w" kurecolor-decrease-brightness-by-step)

View File

@ -1,7 +1,7 @@
;;; core/autoload/hydras.el -*- lexical-binding: t; no-byte-compile: t; -*-
;;; ui/hydra/autoload/windows.el -*- lexical-binding: t; -*-
;;;###autoload (autoload 'doom-text-zoom-hydra/body "core/autoload/hydras" nil t)
(defhydra doom-text-zoom-hydra (:hint t :color red)
;;;###autoload (autoload '+hydra/text-zoom/body "ui/hydra/autoload/windows" nil t)
(defhydra +hydra/text-zoom (:hint t :color red)
"
Text zoom: _j_:zoom in, _k_:zoom out, _0_:reset
"
@ -9,8 +9,8 @@
("k" doom/decrease-font-size "out")
("0" doom/reset-font-size "reset"))
;;;###autoload (autoload 'doom-window-nav-hydra/body "core/autoload/hydras" nil t)
(defhydra doom-window-nav-hydra (:hint nil)
;;;###autoload (autoload '+hydra/window-nav/body "ui/hydra/autoload/windows" nil t)
(defhydra +hydra/window-nav (:hint nil)
"
Split: _v_ert _s_:horz
Delete: _c_lose _o_nly

View File

@ -0,0 +1,4 @@
;;; ui/hydra/config.el -*- lexical-binding: t; -*-
;;;###package hydra
(setq lv-use-seperator t)

View File

@ -0,0 +1,4 @@
;; -*- no-byte-compile: t; -*-
;;; ui/hydra/packages.el
(package! hydra)

View File

@ -1,7 +1,8 @@
;;; ui/vc-gutter/autoload.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui hydra)
;;;###autoload (autoload '+vc-gutter-hydra/body "ui/vc-gutter/autoload" nil t)
(defhydra +vc-gutter-hydra
;;;###autoload (autoload '+vc/gutter-hydra/body "ui/vc-gutter/autoload" nil t)
(defhydra +vc/gutter-hydra
(:body-pre (git-gutter-mode 1) :hint nil)
"
[git gutter]