Emacs: Refactor keybindings.

This commit is contained in:
tastytea 2020-03-31 03:47:58 +02:00
parent 38f201a68c
commit 53520e3aed
2 changed files with 22 additions and 26 deletions

View File

@ -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

View File

@ -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-<delete>" . fixup-whitespace)
;; Scroll without moving the cursor.
("M-<down>" . scroll-up-line)
("M-<up>" . scroll-down-line)
;; Delete words without storing them in the kill buffer.
("C-<delete>" . my/delete-word)
("C-<backspace>" . 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-<delete>" . fixup-whitespace) ; Reduce whitespace around cursor.
("M-<down>" . scroll-up-line) ; Scroll without moving the cursor.
("M-<up>" . scroll-down-line)
;; Delete words without storing them in the kill buffer.
("C-<delete>" . my/delete-word)
("C-<backspace>" . 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