tastytea
2d576fec10
Inheriting `font-lock-comment-face` in `font-lock-comment-face` would lock up Emacs.
101 lines
2.9 KiB
EmacsLisp
101 lines
2.9 KiB
EmacsLisp
;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*-
|
|
|
|
;; Time-stamp: <2019-12-01T10:26:19+00:00>
|
|
|
|
;;; Commentary:
|
|
;; * Setup mouse & keyboard behaviour.
|
|
;; * Setup basic keybindings.
|
|
|
|
;;; Code:
|
|
|
|
(use-package emacs
|
|
:ensure nil
|
|
|
|
:custom
|
|
(mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line at a time.
|
|
;; Paste text where the cursor is, not where the mouse is.
|
|
(mouse-yank-at-point t)
|
|
|
|
:config
|
|
(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)))))
|
|
)
|
|
|
|
(use-package bind-key
|
|
:functions (my/delete-word my/backward-delete-word)
|
|
|
|
:config
|
|
(defun my/delete-word (arg)
|
|
"Delete characters forward until encountering the end of a word.
|
|
With argument, do this 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 argument, do this 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)
|
|
;; Switch buffers.
|
|
("M-<left>" . previous-buffer)
|
|
("M-<right>" . next-buffer)
|
|
;; Switch windows.
|
|
("M-S-<left>" . previous-multiframe-window)
|
|
("M-S-<right>" . next-multiframe-window)
|
|
("s-<left>" . previous-multiframe-window) ; s = Super
|
|
("s-<right>" . next-multiframe-window)
|
|
;; Switch between header and implementation.
|
|
("C-:" . ff-find-other-file)
|
|
)
|
|
)
|
|
|
|
; Multiple cursors.
|
|
(use-package multiple-cursors
|
|
:init
|
|
(global-unset-key (kbd "M-<down-mouse-1>"))
|
|
|
|
:bind
|
|
("C-x M-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
|
|
:config
|
|
(which-key-mode)
|
|
)
|
|
|
|
(provide 'basics/input)
|
|
;;; input.el ends here
|