2019-10-14 17:38:14 +02:00
|
|
|
;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*-
|
|
|
|
|
2020-03-29 22:58:53 +02:00
|
|
|
;; Time-stamp: <2020-03-29T22:58:40+0200>
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; * Setup mouse & keyboard behaviour.
|
|
|
|
;; * Setup basic keybindings.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-03-18 15:00:17 +01:00
|
|
|
(require 'basics/package-management)
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
(use-package emacs
|
2020-03-10 14:33:47 +01:00
|
|
|
: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)
|
|
|
|
;; Reduce scroll lag. <https://emacs.stackexchange.com/a/28746>
|
|
|
|
(auto-window-vscroll nil))
|
|
|
|
:config (progn
|
|
|
|
(delete-selection-mode t) ; Delete selection when you start to write.
|
|
|
|
;; kill-region (cut) and kill-ring-save (copy) act on the current
|
|
|
|
;; line if no text is visually selected.
|
|
|
|
;; <https://www.emacswiki.org/emacs/WholeLineOrRegion>
|
|
|
|
(put 'kill-ring-save 'interactive-form
|
|
|
|
'(interactive
|
|
|
|
(if (use-region-p)
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list (line-beginning-position)
|
|
|
|
(line-beginning-position 2)))))
|
|
|
|
(put 'kill-region 'interactive-form
|
|
|
|
'(interactive
|
|
|
|
(if (use-region-p)
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list (line-beginning-position)
|
|
|
|
(line-beginning-position 2)))))))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
(use-package bind-key
|
|
|
|
:functions (my/delete-word my/backward-delete-word)
|
2020-03-10 14:33:47 +01:00
|
|
|
:config (progn
|
|
|
|
(defun my/delete-word (arg)
|
|
|
|
"Delete characters forward until encountering the end of a word.
|
|
|
|
With ARG, do it that many times."
|
|
|
|
(interactive "p")
|
|
|
|
(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)
|
2020-03-29 21:49:54 +02:00
|
|
|
("C-DEL" . my/backward-delete-word)
|
2020-03-10 14:33:47 +01:00
|
|
|
("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.
|
2020-03-29 22:58:53 +02:00
|
|
|
("C-x C-S-f" . find-file)
|
|
|
|
("C-x F" . find-file)))) ; Workaround for terminals.
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
; Multiple cursors.
|
|
|
|
(use-package multiple-cursors
|
2020-03-10 14:33:47 +01:00
|
|
|
:init (global-unset-key (kbd "M-<down-mouse-1>"))
|
2020-03-27 17:11:14 +01:00
|
|
|
:bind (("C-c m" . mc/edit-lines)
|
2020-03-10 14:33:47 +01:00
|
|
|
("M-<mouse-1>" . mc/add-cursor-on-click)))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;; Edit multiple regions in the same way simultaneously.
|
|
|
|
(use-package iedit
|
2020-03-10 14:33:47 +01:00
|
|
|
:bind ("C-;" . iedit-mode))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
2019-12-01 11:26:26 +01:00
|
|
|
;; Display available keybindings.
|
|
|
|
(use-package which-key
|
2020-02-11 17:48:50 +01:00
|
|
|
:diminish which-key-mode
|
2020-03-10 14:33:47 +01:00
|
|
|
:config (which-key-mode))
|
2019-12-01 11:26:26 +01:00
|
|
|
|
2020-01-21 01:49:47 +01:00
|
|
|
;; Navigate between windows with alt+arrows.
|
|
|
|
(use-package windmove
|
2020-03-10 14:33:47 +01:00
|
|
|
:config (windmove-default-keybindings '(meta shift))
|
|
|
|
:bind (([(meta shift left)] . windmove-left) ; Needed for Emacs-over-SSH. 🤷
|
|
|
|
([(meta shift right)] . windmove-right)
|
|
|
|
([(meta shift up)] . windmove-up)
|
|
|
|
([(meta shift down)] . windmove-down)))
|
2020-01-21 01:49:47 +01:00
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
(provide 'basics/input)
|
|
|
|
;;; input.el ends here
|