94 lines
3.8 KiB
EmacsLisp
94 lines
3.8 KiB
EmacsLisp
;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*-
|
|
|
|
;; Time-stamp: <2020-05-17T19:43:47+0200>
|
|
|
|
;;; Commentary:
|
|
;; * Setup mouse & keyboard behaviour.
|
|
;; * Setup basic keybindings.
|
|
|
|
;;; Code:
|
|
|
|
(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)
|
|
;; 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)))))
|
|
(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)))
|
|
;; Enable keybindings.
|
|
(put 'set-goal-column 'disabled nil)
|
|
(put 'upcase-region 'disabled nil)
|
|
(put 'downcase-region 'disabled nil))
|
|
: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)
|
|
("M-<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
|
|
:init (global-unset-key (kbd "M-<down-mouse-1>"))
|
|
:bind (("C-c m" . mc/edit-lines)
|
|
("M-<mouse-1>" . mc/add-cursor-on-click)))
|
|
|
|
;; Edit multiple regions in the same way simultaneously.
|
|
(use-package iedit
|
|
:bind ("C-;" . iedit-mode))
|
|
|
|
;; Display available keybindings.
|
|
(use-package which-key
|
|
:diminish which-key-mode
|
|
:defines (which-key-mode)
|
|
:config (which-key-mode))
|
|
|
|
;; Navigate between windows with alt+arrows.
|
|
(use-package windmove
|
|
: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)))
|
|
|
|
(provide 'basics/input)
|
|
;;; input.el ends here
|