summaryrefslogtreecommitdiff
path: root/modules/keybindings.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-10-12 11:47:26 -0500
committerCraig Jennings <c@cjennings.net>2025-10-12 11:47:26 -0500
commit092304d9e0ccc37cc0ddaa9b136457e56a1cac20 (patch)
treeea81999b8442246c978b364dd90e8c752af50db5 /modules/keybindings.el
changing repositories
Diffstat (limited to 'modules/keybindings.el')
-rw-r--r--modules/keybindings.el100
1 files changed, 100 insertions, 0 deletions
diff --git a/modules/keybindings.el b/modules/keybindings.el
new file mode 100644
index 00000000..3d817013
--- /dev/null
+++ b/modules/keybindings.el
@@ -0,0 +1,100 @@
+;;; keybindings --- General Keyboard Shortcuts -*- lexical-binding: t; coding: utf-8; -*-
+;; author: Craig Jennings <c@cjennings.net>
+
+;;; Commentary:
+
+
+
+;; Commonly used files should be easy to jump to. The "jump-to" keymap has the
+;; "C-c j" prefix and immediately opens files defined in user-constants.el.
+
+;; "Hostile Keybindings" are those that are close to keybindings I use commonly
+;; so they're easy to hit by accident, but they have painful results. I'd
+;; rather avoid the pain by unsetting they keybindings and view the error '<key>
+;; is undefined' message. Finally, I'm providing messages to train me to use
+;; faster keybindings and provide feedback when evaluating buffers.
+
+;;; Code:
+
+(require 'user-constants)
+
+;; make org-store-link binding global
+(global-set-key (kbd "C-c l") 'org-store-link)
+
+;; remap Shift Backspace to Delete
+(global-set-key (kbd "S-<backspace>") 'delete-forward-char)
+
+;; ------------------------------ Jump To Commands -----------------------------
+;; quick access for commonly used files
+
+(defvar jump-to-keymap (make-sparse-keymap)
+ "Jump-to commonly used files/directories/commands.")
+(global-set-key (kbd "C-c j") jump-to-keymap)
+
+(define-key jump-to-keymap (kbd "r")
+ #'(lambda () (interactive) (find-file reference-file)))
+(define-key jump-to-keymap (kbd "s")
+ #'(lambda () (interactive) (find-file schedule-file)))
+(define-key jump-to-keymap (kbd "i")
+ #'(lambda () (interactive) (find-file inbox-file)))
+(define-key jump-to-keymap (kbd "c")
+ #'(lambda () (interactive) (find-file contacts-file)))
+(define-key jump-to-keymap (kbd "m")
+ #'(lambda () (interactive) (find-file macros-file)))
+(define-key jump-to-keymap (kbd "n")
+ #'(lambda () (interactive) (find-file reading-notes-file)))
+(define-key jump-to-keymap (kbd "w")
+ #'(lambda () (interactive) (find-file webclipped-file)))
+(define-key jump-to-keymap (kbd "g")
+ #'(lambda () (interactive) (find-file gcal-file)))
+(define-key jump-to-keymap (kbd "I")
+ #'(lambda () (interactive) (find-file emacs-init-file)))
+
+
+;; ---------------------------- Keybinding Discovery ---------------------------
+
+(use-package free-keys
+ :defer 1
+ :bind ("C-h C-k" . free-keys))
+
+(use-package which-key
+ :defer 1
+ :config
+ ;; never show keybindings that have been 'cj/disabled'
+ (push '((nil . "cj/disabled") . t) which-key-replacement-alist)
+ (setq which-key-idle-delay 2.0
+ which-key-popup-type 'side-window)
+ (which-key-setup-side-window-bottom)
+ ;; (which-key-setup-side-window-right-bottom)
+ (which-key-mode 1))
+
+;; ---------------------------- General Keybindings ----------------------------
+
+;; Avoid hostile bindings
+(global-unset-key (kbd "C-x C-f")) ;; find-file-read-only
+(global-unset-key (kbd "C-z")) ;; suspend-frame is accidentally hit often
+(global-unset-key (kbd "M-o")) ;; facemenu-mode
+
+;; Add commonly-used general keybindings
+(global-set-key (kbd "C-x C-f") 'find-file)
+(global-set-key (kbd "C-c f") 'link-hint-open-link-at-point)
+(global-set-key (kbd "M-*") 'calculator)
+(global-set-key (kbd "M-Y") 'yank-media)
+
+;; Normally bound to ESC ESC ESC, hit ESC once to get out of unpleasant situations.
+(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
+
+;; remap C-x \ to sort-lines (from remap activate-transient-input-method)
+(global-unset-key (kbd "C-x \\"))
+(global-set-key (kbd "C-x \\") 'sort-lines)
+
+;; training myself to use C-/ for undo (bound internally) as it's faster.
+(global-unset-key (kbd "C-x u"))
+(define-key global-map (kbd "C-x u")
+ #'(lambda () (interactive)
+ (message (concat "Seriously, " user-name
+ "? Use 'C-/'. It's faster."))))
+
+
+(provide 'keybindings)
+;;; keybindings.el ends here