about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/init.el2
-rw-r--r--emacs/.emacs.d/wpc/keybindings.el122
-rw-r--r--emacs/.emacs.d/wpc/wpc-keybindings.el188
3 files changed, 121 insertions, 191 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index 9c7e9bdb57f3..c610ce7db7a8 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -31,8 +31,6 @@
 ;; TODO: How can I package this using Nix?
 ;; (require 'egg-timer "~/programming/egg-timer.el/egg-timer.el")
 
-;; TODO: Reconcile kbd.el, keybindings.el, wpc-keybindings.el, keyboard.el.
-(require 'wpc-keybindings)
 (require 'keybindings)
 (require 'window-manager)
 (require 'wpc-ui)
diff --git a/emacs/.emacs.d/wpc/keybindings.el b/emacs/.emacs.d/wpc/keybindings.el
index 7a1805ac5594..8f3114ccd91c 100644
--- a/emacs/.emacs.d/wpc/keybindings.el
+++ b/emacs/.emacs.d/wpc/keybindings.el
@@ -3,6 +3,14 @@
 
 ;;; Commentary:
 ;; Attempting to centralize my keybindings to simplify my configuration.
+;;
+;; I have some expectations about my keybindings. Here are some of those
+;; defined:
+;; - In insert mode:
+;;   - C-a: beginning-of-line
+;;   - C-e: end-of-line
+;;   - C-b: backwards-char
+;;   - C-f: forwards-char
 
 ;;; Code:
 
@@ -23,10 +31,106 @@
 (require 'device)
 (require 'evil-ex)
 
+(use-package evil
+  :init
+  ;; Should remove the warning messages on init.
+  (setq evil-want-integration t)
+  ;; TODO: Troubleshoot why this binding causes the following warning:
+  ;; "Warning (evil-collection): `evil-want-keybinding' was set to nil but not
+  ;; before loading evil."
+  (setq evil-want-keybinding nil)
+  (general-evil-setup)
+  :config
+  ;; Ensure that evil's command mode behaves with readline bindings.
+  (general-define-key
+   :keymaps 'evil-ex-completion-map
+   "C-a" #'move-beginning-of-line
+   "C-e" #'move-end-of-line
+   "C-k" #'kill-line
+   "C-u" #'evil-delete-whole-line
+   "C-v" #'evil-paste-after
+   "C-d" #'delete-char
+   "C-f" #'forward-char
+   "M-b" #'backward-word
+   "M-f" #'forward-word
+   "M-d" #'kill-word
+   "M-DEL" #'backward-kill-word
+   "C-b" #'backward-char)
+  ;; TODO: Ensure all of my custom keybindings end up in a single map that is
+  ;; easy to enable or disable.
+  (general-mmap
+    :keymaps 'override
+    "RET" #'evil-goto-line
+    "H"   #'evil-first-non-blank
+    "L"   #'evil-end-of-line
+    "_"   #'ranger
+    "-"   #'dired-jump
+    "sl"  #'wpc/evil-window-vsplit-right
+    "sh"  #'evil-window-vsplit
+    "sk"  #'evil-window-split
+    "sj"  #'wpc/evil-window-split-down)
+  (general-nmap
+    :keymaps 'override
+    "gd" #'xref-find-definitions
+    ;; Wrapping `xref-find-references' in the `let' binding to prevent xref from
+    ;; prompting.  There are other ways to handle this variable, such as setting
+    ;; it globally with `setq' or buffer-locally with `setq-local'.  For now, I
+    ;; prefer setting it with `let', which should bind it in the dynamic scope
+    ;; for the duration of the `xref-find-references' function call.
+    "gx" (lambda ()
+           (interactive)
+           (let ((xref-prompt-for-identifier nil))
+             (call-interactively #'xref-find-references))))
+  (general-unbind 'motion "M-." "C-p" "<SPC>")
+  (general-unbind 'normal "s"   "M-." "C-p" "C-n")
+  (general-unbind 'insert "C-v" "C-d" "C-a" "C-e" "C-n" "C-p" "C-k")
+  (setq evil-symbol-word-search t)
+  (evil-mode 1))
+
+;; Ensure the Evil search results get centered vertically.
+(progn
+  (defadvice isearch-update
+      (before advice-for-isearch-update activate)
+    (evil-scroll-line-to-center (line-number-at-pos)))
+  (defadvice evil-search-next
+      (after advice-for-evil-search-next activate)
+    (evil-scroll-line-to-center (line-number-at-pos)))
+  (defadvice evil-search-previous
+      (after advice-for-evil-search-previous activate)
+    (evil-scroll-line-to-center (line-number-at-pos))))
+
+(use-package evil-collection
+  :after (evil)
+  :config
+  (evil-collection-init))
+
+(use-package evil-magit)
+
+;; create comments easily
+(use-package evil-commentary
+  :after (evil)
+  :config
+  (evil-commentary-mode))
+
+(use-package evil-surround
+  :after (evil)
+  :config
+  (global-evil-surround-mode 1))
+
+(use-package key-chord
+  :after (evil)
+  :config
+  (key-chord-mode 1)
+  (key-chord-define evil-insert-state-map "jk" 'evil-normal-state))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Configuration
+;; General KBDs
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+;; This may be contraversial, but I never use the prefix key, and I'd prefer to
+;; have to bound to the readline function that deletes the entire line.
+(general-unbind "C-u")
+
 (defmacro keybinding/exwm (c fn)
   "Bind C to FN using `exwm-input-set-key' with `kbd' applied to C."
   `(exwm-input-set-key (kbd ,c) ,fn))
@@ -43,6 +147,22 @@
 (keybinding/exwm "<C-M-tab>" #'exwm/switch-to-exwm-buffer)
 
 (general-define-key
+ :keymaps 'override
+ "M-q" #'delete-window
+ "<s-return>" #'toggle-frame-fullscreen
+ "M-h" #'windmove-left
+ "M-l" #'windmove-right
+ "M-k" #'windmove-up
+ "M-j" #'windmove-down
+ "M-q" #'delete-window)
+
+;; Support pasting in M-:.
+(general-define-key
+ :keymaps 'read-expression-map
+ "C-v"   #'clipboard-yank
+ "C-S-v" #'clipboard-yank)
+
+(general-define-key
  :prefix "<SPC>"
  :states '(normal)
  "." #'ffap
diff --git a/emacs/.emacs.d/wpc/wpc-keybindings.el b/emacs/.emacs.d/wpc/wpc-keybindings.el
deleted file mode 100644
index fa6ba0003535..000000000000
--- a/emacs/.emacs.d/wpc/wpc-keybindings.el
+++ /dev/null
@@ -1,188 +0,0 @@
-;;; keybindings.el --- My Evil preferences -*- lexical-binding: t -*-
-;; Author: William Carroll <wpcarro@gmail.com>
-
-;;; Commentary:
-;; This module hosts my Evil preferences
-;;
-;; Wish List:
-;; - restore support for concise (n <kbd> <function>) instead of `general-mmap'
-;; - restore support for `general-unbind'
-
-;;; Code:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Dependencies
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(require 'general)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Packages
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; This may be contraversial, but I never use the prefix key, and I'd prefer to
-;; have to bound to the readline function that deletes the entire line.
-(general-unbind "C-u")
-
-(use-package evil
-  :init
-  ;; Should remove the warning messages on init.
-  (setq evil-want-integration t)
-  ;; TODO: Troubleshoot why this binding causes the following warning:
-  ;; "Warning (evil-collection): `evil-want-keybinding' was set to nil but not
-  ;; before loading evil."
-  (setq evil-want-keybinding nil)
-  (general-evil-setup)
-  :config
-  ;; Ensure that evil's command mode behaves with readline bindings.
-  (general-define-key
-   :keymaps 'evil-ex-completion-map
-   "C-a" #'move-beginning-of-line
-   "C-e" #'move-end-of-line
-   "C-k" #'kill-line
-   "C-u" #'evil-delete-whole-line
-   "C-v" #'evil-paste-after
-   "C-d" #'delete-char
-   "C-f" #'forward-char
-   "M-b" #'backward-word
-   "M-f" #'forward-word
-   "M-d" #'kill-word
-   "M-DEL" #'backward-kill-word
-   "C-b" #'backward-char)
-  ;; TODO: Ensure all of my custom keybindings end up in a single map that is
-  ;; easy to enable or disable.
-  (general-mmap
-    :keymaps 'override
-    "RET" #'evil-goto-line
-    "H"   #'evil-first-non-blank
-    "L"   #'evil-end-of-line
-    "_"   #'ranger
-    "-"   #'dired-jump
-    "sl"  #'wpc/evil-window-vsplit-right
-    "sh"  #'evil-window-vsplit
-    "sk"  #'evil-window-split
-    "sj"  #'wpc/evil-window-split-down)
-  (general-nmap
-    :keymaps 'override
-    "gd" #'xref-find-definitions
-    ;; Wrapping `xref-find-references' in the `let' binding to prevent xref from
-    ;; prompting.  There are other ways to handle this variable, such as setting
-    ;; it globally with `setq' or buffer-locally with `setq-local'.  For now, I
-    ;; prefer setting it with `let', which should bind it in the dynamic scope
-    ;; for the duration of the `xref-find-references' function call.
-    "gx" (lambda ()
-           (interactive)
-           (let ((xref-prompt-for-identifier nil))
-             (call-interactively #'xref-find-references))))
-  (general-unbind 'motion "M-." "C-p" "<SPC>")
-  (general-unbind 'normal "s"   "M-." "C-p" "C-n")
-  (general-unbind 'insert "C-v" "C-d" "C-a" "C-e" "C-n" "C-p" "C-k")
-  (setq evil-symbol-word-search t)
-  (evil-mode 1))
-
-;; TODO: Write `evil-collection' KBDs for `refine'.
-;; evil keybindings
-(use-package evil-collection
-  :after (evil)
-  :config
-  (evil-collection-init))
-
-;; `evil-collection' does not support `magit', and the preferred way to get evil
-;; kbds for magit is with `evil-magit'.
-(use-package evil-magit)
-
-;; create comments easily
-(use-package evil-commentary
-  :after (evil)
-  :config
-  (evil-commentary-mode))
-
-;; evil surround
-(use-package evil-surround
-  :after (evil)
-  :config
-  (global-evil-surround-mode 1))
-
-;; I expect in insert mode:
-;; C-a: beginning-of-line
-;; C-e: end-of-line
-;; C-b: backwards-char
-;; C-f: forwards-char
-
-;; TODO: Move these KBD constants to kbd.el.
-
-(defconst wpc/up-kbds
-  '("C-p" "C-k" "<backtab>" "<up>")
-  "The keybindings that I expect to work for moving upwards in lists.")
-
-(defconst wpc/down-kbds
-  '("C-n" "C-j" "<tab>" "<down>")
-  "The keybindings that I expect to work for moving downwards in lists.")
-
-(defconst wpc/left-kbds
-  '("C-b" "<left>")
-  "The keybindings that I expect to move leftwards in insert-like modes.")
-
-(defconst wpc/right-kbds
-  '("C-f" "<right>")
-  "The keybindings that I expect to move rightwards in insert-like modes.")
-
-(defun wpc/ensure-kbds (_ignore)
-  "Try to ensure that my keybindings retain priority over other minor modes."
-  (unless (eq (caar minor-mode-map-alist) 'wpc/kbds-minor-mode)
-    (let ((mykbds (assq 'wpc/kbds-minor-mode minor-mode-map-alist)))
-      (assq-delete-all 'wpc/kbds-minor-mode minor-mode-map-alist)
-      (add-to-list 'minor-mode-map-alist mykbds))))
-
-;; Custom minor mode that ensures that my kbds are available no matter which
-;; major or minor modes are active.
-(add-hook 'after-load-functions #'wpc/ensure-kbds)
-
-;; TODO: Prefer using general and 'override maps to implement this.
-(defvar wpc/kbds
-  (let ((map (make-sparse-keymap)))
-    (bind-keys :map map
-               ("M-q"            . delete-window)
-               ("<s-return>"     . toggle-frame-fullscreen)
-               ("M-h"            . windmove-left)
-               ("M-l"            . windmove-right)
-               ("M-k"            . windmove-up)
-               ("M-j"            . windmove-down)
-               ("M-q"            . delete-window))
-    map)
-  "William Carroll's keybindings that should have the highest precedence.")
-
-;; Support pasting in M-:.
-(general-define-key
- :keymaps 'read-expression-map
- "C-v"   #'clipboard-yank
- "C-S-v" #'clipboard-yank)
-
-(define-minor-mode wpc/kbds-minor-mode
-  "A minor mode so that my key settings override annoying major modes."
-  :init-value t
-  :lighter " wpc/kbds"
-  :keymap wpc/kbds)
-
-;; allow jk to escape
-(use-package key-chord
-  :after (evil)
-  :config
-  (key-chord-mode 1)
-  (key-chord-define evil-insert-state-map "jk" 'evil-normal-state))
-
-;; Ensure the Evil search results get centered vertically.
-;; TODO: Consider packaging this up for others.
-(progn
-  (defadvice isearch-update
-      (before advice-for-isearch-update activate)
-    (evil-scroll-line-to-center (line-number-at-pos)))
-  (defadvice evil-search-next
-      (after advice-for-evil-search-next activate)
-    (evil-scroll-line-to-center (line-number-at-pos)))
-  (defadvice evil-search-previous
-      (after advice-for-evil-search-previous activate)
-    (evil-scroll-line-to-center (line-number-at-pos))))
-
-(provide 'wpc-keybindings)
-;;; wpc-keybindings.el ends here