From 53520e3aed6939d8bd9b45f5cfec18f84cef1424 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 31 Mar 2020 03:47:58 +0200 Subject: [PATCH] Emacs: Refactor keybindings. --- init.d/basics/early-packages.el | 7 ++++-- init.d/basics/input.el | 41 ++++++++++++++------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/init.d/basics/early-packages.el b/init.d/basics/early-packages.el index b9c3bb7..949d977 100644 --- a/init.d/basics/early-packages.el +++ b/init.d/basics/early-packages.el @@ -1,6 +1,6 @@ ;;; early-packages.el --- Packages that need to be loaded early -*- lexical-binding: t; -*- -;; Time-stamp: <2020-03-18T14:51:22+0100> +;; Time-stamp: <2020-03-31T02:02:59+0200> ;;; Commentary: @@ -8,8 +8,11 @@ (require 'basics/package-management) -;; Hide minor-mode from modeline. +;; Hide minor-mode from modeline, make :diminish work. (use-package diminish) +;; Bind keys, make :bind work. +(use-package bind-key) + (provide 'basics/early-packages) ;;; early-packages.el ends here diff --git a/init.d/basics/input.el b/init.d/basics/input.el index ea33d82..0b2f748 100644 --- a/init.d/basics/input.el +++ b/init.d/basics/input.el @@ -1,6 +1,6 @@ ;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*- -;; Time-stamp: <2020-03-29T22:58:40+0200> +;; Time-stamp: <2020-03-31T03:47:07+0200> ;;; Commentary: ;; * Setup mouse & keyboard behaviour. @@ -11,6 +11,7 @@ (require 'basics/package-management) (use-package emacs + :demand t :custom ((mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line. ;; Paste text where the cursor is, not where the mouse is. (mouse-yank-at-point t) @@ -32,11 +33,7 @@ (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) - (line-beginning-position 2))))))) - -(use-package bind-key - :functions (my/delete-word my/backward-delete-word) - :config (progn + (line-beginning-position 2))))) (defun my/delete-word (arg) "Delete characters forward until encountering the end of a word. With ARG, do it that many times." @@ -44,28 +41,24 @@ With ARG, do it that many times." (if (use-region-p) (delete-region (region-beginning) (region-end)) (delete-region (point) (progn (forward-word arg) (point))))) - (defun my/backward-delete-word (arg) "Delete characters backward until encountering the end of a word. With ARG, do it that many times." (interactive "p") - (my/delete-word (- arg))) - (bind-keys - ;; Reduce whitespace around cursor to 0 or 1, according to context. - ("C-S-" . fixup-whitespace) - ;; Scroll without moving the cursor. - ("M-" . scroll-up-line) - ("M-" . scroll-down-line) - ;; Delete words without storing them in the kill buffer. - ("C-" . my/delete-word) - ("C-" . my/backward-delete-word) - ("C-DEL" . my/backward-delete-word) - ("C-q" . delete-frame) - ;; Insert next character with control characters. - ("C-S-v" . quoted-insert) - ;; C-x C-f will be replaced with projectile-find-file. - ("C-x C-S-f" . find-file) - ("C-x F" . find-file)))) ; Workaround for terminals. + (my/delete-word (- arg)))) + :bind (("C-S-" . fixup-whitespace) ; Reduce whitespace around cursor. + ("M-" . scroll-up-line) ; Scroll without moving the cursor. + ("M-" . scroll-down-line) + ;; Delete words without storing them in the kill buffer. + ("C-" . my/delete-word) + ("C-" . my/backward-delete-word) + ("C-DEL" . my/backward-delete-word) + ("C-q" . delete-frame) + ;; Insert next character with control characters. + ("C-S-v" . quoted-insert) + ;; C-x C-f will be replaced with projectile-find-file. + ("C-x C-S-f" . find-file) + ("C-x F" . find-file))) ; Workaround for terminals. ; Multiple cursors. (use-package multiple-cursors