From 017ba8d79c8eab111326a636e42c3dc88230dbef Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 26 Jun 2018 01:42:35 +0200 Subject: [PATCH] Autoload defhydras & use new naming convention Phasing out the +module@name convention for plain old +module-name-hydra, which is more compatible with elisp reflection tools like describe-function and such. Also, Emacs starts up faster now. Tee hee. --- core/autoload/hydras.el | 47 +++++++++++++++++++++ core/core-keybinds.el | 50 +---------------------- modules/completion/ivy/autoload/hydras.el | 43 +++++++++++++++++++ modules/completion/ivy/config.el | 45 +------------------- modules/tools/ein/autoload.el | 45 +++++++++++++++++++- modules/tools/ein/config.el | 47 +-------------------- modules/tools/rgb/autoload.el | 13 ++++++ modules/tools/rgb/config.el | 19 --------- modules/ui/vc-gutter/autoload.el | 26 ++++++++++++ modules/ui/vc-gutter/config.el | 24 ----------- 10 files changed, 178 insertions(+), 181 deletions(-) create mode 100644 core/autoload/hydras.el create mode 100644 modules/completion/ivy/autoload/hydras.el create mode 100644 modules/tools/rgb/autoload.el delete mode 100644 modules/tools/rgb/config.el create mode 100644 modules/ui/vc-gutter/autoload.el diff --git a/core/autoload/hydras.el b/core/autoload/hydras.el new file mode 100644 index 000000000..450d5a95b --- /dev/null +++ b/core/autoload/hydras.el @@ -0,0 +1,47 @@ +;;; core/autoload/hydras.el -*- lexical-binding: t; -*- + +;;;###autoload (autoload 'doom-text-zoom-hydra/body "core/autoload/hydras" nil nil) +(defhydra doom-text-zoom-hydra (:hint t :color red) + " + Text zoom: _j_:zoom in, _k_:zoom out, _0_:reset +" + ("j" text-scale-increase "in") + ("k" text-scale-decrease "out") + ("0" (text-scale-set 0) "reset")) + +;;;###autoload (autoload 'doom-window-nav-hydra/body "core/autoload/hydras" nil nil) +(defhydra doom-window-nav-hydra (:hint nil) + " + Split: _v_ert _s_:horz + Delete: _c_lose _o_nly + Switch Window: _h_:left _j_:down _k_:up _l_:right + Buffers: _p_revious _n_ext _b_:select _f_ind-file + Resize: _H_:splitter left _J_:splitter down _K_:splitter up _L_:splitter right + Move: _a_:up _z_:down _i_menu +" + ("z" scroll-up-line) + ("a" scroll-down-line) + ("i" idomenu) + + ("h" windmove-left) + ("j" windmove-down) + ("k" windmove-up) + ("l" windmove-right) + + ("p" previous-buffer) + ("n" next-buffer) + ("b" switch-to-buffer) + ("f" find-file) + + ("s" split-window-below) + ("v" split-window-right) + + ("c" delete-window) + ("o" delete-other-windows) + + ("H" hydra-move-splitter-left) + ("J" hydra-move-splitter-down) + ("K" hydra-move-splitter-up) + ("L" hydra-move-splitter-right) + + ("q" nil)) diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 6c721ebcb..1c4aaef25 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -63,54 +63,8 @@ If any hook returns non-nil, all hooks after it are ignored.") (which-key-mode +1)) -(def-package! hydra - :defer t - :config - (setq lv-use-seperator t) - - (defhydra doom@text-zoom (:hint t :color red) - " - Text zoom: _j_:zoom in, _k_:zoom out, _0_:reset -" - ("j" text-scale-increase "in") - ("k" text-scale-decrease "out") - ("0" (text-scale-set 0) "reset")) - - (defhydra doom@window-nav (:hint nil) - " - Split: _v_ert _s_:horz - Delete: _c_lose _o_nly - Switch Window: _h_:left _j_:down _k_:up _l_:right - Buffers: _p_revious _n_ext _b_:select _f_ind-file - Resize: _H_:splitter left _J_:splitter down _K_:splitter up _L_:splitter right - Move: _a_:up _z_:down _i_menu -" - ("z" scroll-up-line) - ("a" scroll-down-line) - ("i" idomenu) - - ("h" windmove-left) - ("j" windmove-down) - ("k" windmove-up) - ("l" windmove-right) - - ("p" previous-buffer) - ("n" next-buffer) - ("b" switch-to-buffer) - ("f" find-file) - - ("s" split-window-below) - ("v" split-window-right) - - ("c" delete-window) - ("o" delete-other-windows) - - ("H" hydra-move-splitter-left) - ("J" hydra-move-splitter-down) - ("K" hydra-move-splitter-up) - ("L" hydra-move-splitter-right) - - ("q" nil))) +;; `hydra' +(setq lv-use-seperator t) ;; diff --git a/modules/completion/ivy/autoload/hydras.el b/modules/completion/ivy/autoload/hydras.el new file mode 100644 index 000000000..36c1ff9c9 --- /dev/null +++ b/modules/completion/ivy/autoload/hydras.el @@ -0,0 +1,43 @@ +;;; completion/ivy/autoload/hydras.el -*- lexical-binding: t; -*- + +;;;###autoload (autoload '+ivy-coo-hydra/body "completion/ivy/autoload/hydras" nil nil) +(defhydra +ivy-coo-hydra (: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 + ("j" ivy-next-line) + ("k" ivy-previous-line) + ("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) + ("C-g" keyboard-escape-quit :exit t) + ("" keyboard-escape-quit :exit t) + ("C-o" nil) + ("i" nil) + ("TAB" ivy-alt-done :exit nil) + ("C-j" ivy-alt-done :exit nil) + ("RET" ivy-done :exit t) + ("C-m" ivy-done :exit t) + ("C-SPC" ivy-call-and-recenter :exit nil) + ("f" ivy-call) + ("c" ivy-toggle-calling) + ("m" ivy-toggle-fuzzy) + (">" ivy-minibuffer-grow) + ("<" ivy-minibuffer-shrink) + ("w" ivy-prev-action) + ("s" ivy-next-action) + ("a" ivy-read-action) + ("t" (setq truncate-lines (not truncate-lines))) + ("C" ivy-toggle-case-fold) + ("o" ivy-occur :exit t)) diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 4a93ca110..e16ea7ed9 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -126,49 +126,8 @@ immediately runs it on the current candidate (ending the ivy session)." :init (after! ivy (define-key! ivy-minibuffer-map - "\C-o" #'+ivy@coo/body - (kbd "M-o") #'ivy-dispatching-done-hydra)) - :config - (defhydra +ivy@coo (: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 - ("j" ivy-next-line) - ("k" ivy-previous-line) - ("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) - ("C-g" keyboard-escape-quit :exit t) - ("" keyboard-escape-quit :exit t) - ("C-o" nil) - ("i" nil) - ("TAB" ivy-alt-done :exit nil) - ("C-j" ivy-alt-done :exit nil) - ("RET" ivy-done :exit t) - ("C-m" ivy-done :exit t) - ("C-SPC" ivy-call-and-recenter :exit nil) - ("f" ivy-call) - ("c" ivy-toggle-calling) - ("m" ivy-toggle-fuzzy) - (">" ivy-minibuffer-grow) - ("<" ivy-minibuffer-shrink) - ("w" ivy-prev-action) - ("s" ivy-next-action) - ("a" ivy-read-action) - ("t" (setq truncate-lines (not truncate-lines))) - ("C" ivy-toggle-case-fold) - ("o" ivy-occur :exit t))) + "\C-o" #'+ivy-coo-hydra/body + (kbd "M-o") #'ivy-dispatching-done-hydra))) (def-package! wgrep diff --git a/modules/tools/ein/autoload.el b/modules/tools/ein/autoload.el index 6a65fcf19..3796e2a22 100644 --- a/modules/tools/ein/autoload.el +++ b/modules/tools/ein/autoload.el @@ -34,4 +34,47 @@ (goto-char (1+ res)) (widget-button-press (point))))) - +;;;###autoload (autoload '+ein-hydra/body "tools/ein/autoload" nil nil) +(defhydra +ein-hydra (:hint t :color red) + " + Operations on Cells^^^^^^ Other + ----------------------------^^^^^^ ----------------------------------^^^^ + [_k_/_j_]^^ select prev/next [_t_]^^ toggle output + [_K_/_J_]^^ move up/down [_C-l_/_C-S-l_] clear/clear all output + [_C-k_/_C-j_]^^ merge above/below [_C-o_]^^ open console + [_O_/_o_]^^ insert above/below [_C-s_/_C-r_] save/rename notebook + [_y_/_p_/_d_] copy/paste [_x_]^^ close notebook + [_u_]^^^^ change type [_q_]^^ quit + [_RET_]^^^^ execute +" + ("q" nil :exit t) + ("h" ein:notebook-worksheet-open-prev-or-last) + ("j" ein:worksheet-goto-next-input) + ("k" ein:worksheet-goto-prev-input) + ("l" ein:notebook-worksheet-open-next-or-first) + ("H" ein:notebook-worksheet-move-prev) + ("J" ein:worksheet-move-cell-down) + ("K" ein:worksheet-move-cell-up) + ("L" ein:notebook-worksheet-move-next) + ("t" ein:worksheet-toggle-output) + ("d" ein:worksheet-kill-cell) + ("R" ein:worksheet-rename-sheet) + ("y" ein:worksheet-copy-cell) + ("p" ein:worksheet-yank-cell) + ("o" ein:worksheet-insert-cell-below) + ("O" ein:worksheet-insert-cell-above) + ("u" ein:worksheet-change-cell-type) + ("RET" ein:worksheet-execute-cell-and-goto-next) + ;; Output + ("C-l" ein:worksheet-clear-output) + ("C-S-l" ein:worksheet-clear-all-output) + ;;Console + ("C-o" ein:console-open :exit t) + ;; Merge and split cells + ("C-k" ein:worksheet-merge-cell) + ("C-j" spacemacs/ein:worksheet-merge-cell-next) + ("s" ein:worksheet-split-cell-at-point) + ;; Notebook + ("C-s" ein:notebook-save-notebook-command) + ("C-r" ein:notebook-rename-command) + ("x" ein:notebook-close :exit t)) diff --git a/modules/tools/ein/config.el b/modules/tools/ein/config.el index 0c92dcf59..97126600d 100644 --- a/modules/tools/ein/config.el +++ b/modules/tools/ein/config.el @@ -40,49 +40,4 @@ ;; Ace-link on notebook list buffers (after! ein-notebooklist - (define-key ein:notebooklist-mode-map "o" #'+ein/ace-link-ein)) - - ;; add hydra - (defhydra +ein/hydra (:hint t :color red) - " - Operations on Cells^^^^^^ Other - ----------------------------^^^^^^ ----------------------------------^^^^ - [_k_/_j_]^^ select prev/next [_t_]^^ toggle output - [_K_/_J_]^^ move up/down [_C-l_/_C-S-l_] clear/clear all output - [_C-k_/_C-j_]^^ merge above/below [_C-o_]^^ open console - [_O_/_o_]^^ insert above/below [_C-s_/_C-r_] save/rename notebook - [_y_/_p_/_d_] copy/paste [_x_]^^ close notebook - [_u_]^^^^ change type [_q_]^^ quit - [_RET_]^^^^ execute -" - ("q" nil :exit t) - ("h" ein:notebook-worksheet-open-prev-or-last) - ("j" ein:worksheet-goto-next-input) - ("k" ein:worksheet-goto-prev-input) - ("l" ein:notebook-worksheet-open-next-or-first) - ("H" ein:notebook-worksheet-move-prev) - ("J" ein:worksheet-move-cell-down) - ("K" ein:worksheet-move-cell-up) - ("L" ein:notebook-worksheet-move-next) - ("t" ein:worksheet-toggle-output) - ("d" ein:worksheet-kill-cell) - ("R" ein:worksheet-rename-sheet) - ("y" ein:worksheet-copy-cell) - ("p" ein:worksheet-yank-cell) - ("o" ein:worksheet-insert-cell-below) - ("O" ein:worksheet-insert-cell-above) - ("u" ein:worksheet-change-cell-type) - ("RET" ein:worksheet-execute-cell-and-goto-next) - ;; Output - ("C-l" ein:worksheet-clear-output) - ("C-S-l" ein:worksheet-clear-all-output) - ;;Console - ("C-o" ein:console-open :exit t) - ;; Merge and split cells - ("C-k" ein:worksheet-merge-cell) - ("C-j" spacemacs/ein:worksheet-merge-cell-next) - ("s" ein:worksheet-split-cell-at-point) - ;; Notebook - ("C-s" ein:notebook-save-notebook-command) - ("C-r" ein:notebook-rename-command) - ("x" ein:notebook-close :exit t))) + (define-key ein:notebooklist-mode-map "o" #'+ein/ace-link-ein))) diff --git a/modules/tools/rgb/autoload.el b/modules/tools/rgb/autoload.el new file mode 100644 index 000000000..96647de20 --- /dev/null +++ b/modules/tools/rgb/autoload.el @@ -0,0 +1,13 @@ +;;; tools/rgb/autoload.el -*- lexical-binding: t; -*- + +;;;###autoload (autoload '+rgb-kurecolor-hydra/body "tools/rgb/autoload" nil nil) +(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) + ("W" kurecolor-increase-brightness-by-step) + ("d" kurecolor-decrease-saturation-by-step) + ("D" kurecolor-increase-saturation-by-step) + ("e" kurecolor-decrease-hue-by-step) + ("E" kurecolor-increase-hue-by-step) + ("q" nil "cancel" :color blue)) diff --git a/modules/tools/rgb/config.el b/modules/tools/rgb/config.el deleted file mode 100644 index 08a93d06a..000000000 --- a/modules/tools/rgb/config.el +++ /dev/null @@ -1,19 +0,0 @@ -;;; tools/rgb/config.el -*- lexical-binding: t; -*- - -;; -;; Plugins -;; - -(def-package! kurecolor - :after rainbow-mode - :config - (defhydra +rgb@kurecolor (:color pink :hint nil) - " -Inc/Dec _w_/_W_ brightness _d_/_D_ saturation _e_/_E_ hue " - ("w" kurecolor-decrease-brightness-by-step) - ("W" kurecolor-increase-brightness-by-step) - ("d" kurecolor-decrease-saturation-by-step) - ("D" kurecolor-increase-saturation-by-step) - ("e" kurecolor-decrease-hue-by-step) - ("E" kurecolor-increase-hue-by-step) - ("q" nil "cancel" :color blue))) diff --git a/modules/ui/vc-gutter/autoload.el b/modules/ui/vc-gutter/autoload.el new file mode 100644 index 000000000..def6ed45b --- /dev/null +++ b/modules/ui/vc-gutter/autoload.el @@ -0,0 +1,26 @@ +;;; ui/vc-gutter/autoload.el -*- lexical-binding: t; -*- + +;;;###autoload (autoload '+vc-gutter-hydra/body "ui/vc-gutter/autoload" nil nil) +(defhydra +vc-gutter-hydra + (:body-pre (git-gutter-mode 1) :hint nil) + " + [git gutter] + Movement Hunk Actions Misc. +%-4s(car (git-gutter:statistic))/ -%-4s(cdr (git-gutter:statistic)) + ╭──────────────────────────────────┴────────────────╯ + ^_g_^ [_s_] stage [_R_] set start Rev + ^_k_^ [_r_] revert + ^↑ ^ [_m_] mark + ^↓ ^ [_p_] popup ╭───────────────────── + ^_j_^ │[_q_] quit + ^_G_^ │[_Q_] Quit and disable" + ("j" (progn (git-gutter:next-hunk 1) (recenter))) + ("k" (progn (git-gutter:previous-hunk 1) (recenter))) + ("g" (progn (goto-char (point-min)) (git-gutter:next-hunk 1))) + ("G" (progn (goto-char (point-min)) (git-gutter:previous-hunk 1))) + ("s" git-gutter:stage-hunk) + ("r" git-gutter:revert-hunk) + ("m" git-gutter:mark-hunk) + ("p" git-gutter:popup-hunk) + ("R" git-gutter:set-start-revision) + ("q" nil :color blue) + ("Q" (git-gutter-mode -1) :color blue)) diff --git a/modules/ui/vc-gutter/config.el b/modules/ui/vc-gutter/config.el index e13239d43..ee90b7a15 100644 --- a/modules/ui/vc-gutter/config.el +++ b/modules/ui/vc-gutter/config.el @@ -51,30 +51,6 @@ to the right fringe.") ;; update git-gutter when using these commands (add-hook 'magit-post-refresh-hook #'+version-control|update-git-gutter) - (defhydra +version-control@git-gutter - (:body-pre (git-gutter-mode 1) :hint nil) - " - [git gutter] - Movement Hunk Actions Misc. +%-4s(car (git-gutter:statistic))/ -%-4s(cdr (git-gutter:statistic)) - ╭──────────────────────────────────┴────────────────╯ - ^_g_^ [_s_] stage [_R_] set start Rev - ^_k_^ [_r_] revert - ^↑ ^ [_m_] mark - ^↓ ^ [_p_] popup ╭───────────────────── - ^_j_^ │[_q_] quit - ^_G_^ │[_Q_] Quit and disable" - ("j" (progn (git-gutter:next-hunk 1) (recenter))) - ("k" (progn (git-gutter:previous-hunk 1) (recenter))) - ("g" (progn (goto-char (point-min)) (git-gutter:next-hunk 1))) - ("G" (progn (goto-char (point-min)) (git-gutter:previous-hunk 1))) - ("s" git-gutter:stage-hunk) - ("r" git-gutter:revert-hunk) - ("m" git-gutter:mark-hunk) - ("p" git-gutter:popup-hunk) - ("R" git-gutter:set-start-revision) - ("q" nil :color blue) - ("Q" (git-gutter-mode -1) :color blue)) - ;; subtle diff indicators in the fringe (when +vc-gutter-default-style ;; places the git gutter outside the margins.