diff options
| -rw-r--r-- | .emacs.d/rul-emacs.org | 82 | ||||
| -rw-r--r-- | .emacs.d/rul-lisp/packages/rul-bindings.el | 3 | 
2 files changed, 83 insertions, 2 deletions
diff --git a/.emacs.d/rul-emacs.org b/.emacs.d/rul-emacs.org index b2edae7..4cb505c 100644 --- a/.emacs.d/rul-emacs.org +++ b/.emacs.d/rul-emacs.org @@ -268,3 +268,85 @@ to detect what color theme is preferred, and set our Emacs theme accordingly.  (provide 'rul-themes)  #+end_src + +** The =bindings= module +This module contains code pertaining to keybindings. It starts by +defining a set global keys. + +#+begin_src emacs-lisp :tangle "rul-lisp/packages/rul-bindings.el" +;; Global keybindings +(global-set-key (kbd "C-c R") 'revert-buffer) +(global-set-key (kbd "C-c w") 'whitespace-cleanup) + +(defun help/insert-em-dash () +  "Inserts an EM-DASH (not a HYPEN, not an N-DASH)" +  (interactive) +  (insert "—")) + +(global-set-key (kbd "C--") #'help/insert-em-dash) +#+end_src + +Next, we define a few /hydras/. /Hydras/ are a way of grouping keybindings +together, offering a menu on the way. + +#+begin_src emacs-lisp :tangle "rul-lisp/packages/rul-bindings.el" +(use-package hydra +  :ensure t +  :defer 1) + +;; tab-bar +(defhydra hydra-tab-bar (:color amaranth) +  "Tab Bar Operations" +  ("t" tab-new "Create a new tab" :column "Creation" :exit t) +  ("d" dired-other-tab "Open Dired in another tab") +  ("f" find-file-other-tab "Find file in another tab") +  ("x" tab-close "Close current tab") +  ("m" tab-move "Move current tab" :column "Management") +  ("r" tab-rename "Rename Tab") +  ("<return>" tab-bar-select-tab-by-name "Select tab by name" :column "Navigation") +  ("l" tab-next "Next Tab") +  ("j" tab-previous "Previous Tab") +  ("q" nil "Exit" :exit t)) + +(global-set-key (kbd "C-x t") 'hydra-tab-bar/body) + +;; Zoom +(defhydra hydra-zoom () +  "zoom" +  ("g" text-scale-increase "in") +  ("l" text-scale-decrease "out")) + +(global-set-key (kbd "C-c z") 'hydra-zoom/body) + +;; Go +(defhydra hydra-go () +  "zoom" +  ("=" gofmt :exit t) +  ("c" go-coverage :exit t)) + +;; vterm +(defhydra hydra-vterm () +  "zoom" +  ("t" multi-vterm "Open a terminal" :exit t) +  ("d" multi-vterm-dedicated-open "Dedicated" :exit t) +  ("p" multi-vterm-prev "Previous terminal") +  ("n" multi-vterm-next "Next terminal") +  ("r" multi-vterm-rename-buffer "Rename buffer" :exit t) +  ) + +(global-set-key (kbd "C-c t") 'hydra-vterm/body) +(global-set-key (kbd "C-c m") 'hydra-go/body) +#+end_src + +Finally, we make use of =which-key=, which will show a menu with all +keybinding options after a prefix is pressed. I think this package has +the potential to obsolete =hydra=, so I'll have to revisit that code. + +#+begin_src emacs-lisp :tangle "rul-lisp/packages/rul-bindings.el" +(use-package which-key +  :ensure t +  :config +  (which-key-mode)) + +(provide 'rul-bindings) +#+end_src diff --git a/.emacs.d/rul-lisp/packages/rul-bindings.el b/.emacs.d/rul-lisp/packages/rul-bindings.el index 48426b5..96d14b0 100644 --- a/.emacs.d/rul-lisp/packages/rul-bindings.el +++ b/.emacs.d/rul-lisp/packages/rul-bindings.el @@ -59,7 +59,6 @@  (use-package which-key    :ensure t    :config -  (which-key-mode) -) +  (which-key-mode))  (provide 'rul-bindings)  | 
