blob: 5060cc5e96f5751a7469388dc8c88f63a38e682f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
#+title: Emacs Config
#+property: header-args:elisp :mkdirp yes :results silent :padline no
#+property: header-args:elisp+ :tangle "~/.config/emacs/init.el"
* General
** Settings
Quality of life settings.
#+begin_src elisp
(setq-default
help-window-select t
delete-by-moving-to-trash t
sentence-end-double-space nil
confirm-kill-emacs 'yes-or-no-p
scroll-conservatively 101
cursor-in-non-selected-windows nil)
#+end_src
** Startup Screen
Disable default startup screen.
#+begin_src elisp
(setq-default inhibit-startup-screen t)
#+end_src
** GUI Bars
Disable GUI bars.
#+begin_src elisp
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
#+end_src
** Editor
Tab behaviour settings.
#+begin_src elisp
(setq-default
tab-width 4
tab-always-indent 'complete
backward-delete-char-untabify-method 'hungry
indent-tabs-mode nil)
#+end_src
Replace selected region when yanking text.
#+begin_src elisp
(delete-selection-mode)
#+end_src
Automatically remove trailing whitespace on file-save.
#+begin_src elisp
(add-hook 'before-save-hook #'whitespace-cleanup)
#+end_src
Increase default column width.
#+begin_src elisp
(setq-default fill-column 80)
#+end_src
Set whitespace column length and symbols.
#+begin_src elisp
(with-eval-after-load 'whitespace
(setq-default
whitespace-line-column fill-column
whitespace-display-mappings '((space-mark ?\s [?·] [?.])
(newline-mark ?\n [?↴ ?\n])
(tab-mark ?\t [?➔ ?\t] [?\\ ?\t]))))
#+end_src
** Theme
Enable theme.
#+begin_src elisp
(load-theme 'modus-vivendi)
#+end_src
** Completion
Enable completions previews.
#+begin_src elisp
(add-hook 'prog-mode-hook
#'completion-preview-mode)
#+end_src
Set completion keybindings.
#+begin_src elisp
(with-eval-after-load 'completion-preview
(let ((map completion-preview-active-mode-map))
(keymap-set map "M-n" #'completion-preview-next-candidate)
(keymap-set map "M-p" #'completion-preview-prev-candidate)))
#+end_src
** Which-key
Enable which-key that displays a pop-up window of posisble keybindings sequences.
#+begin_src elisp
(which-key-mode)
#+end_src
** History
*** Minibuffer History
Enable saving minibuffer history.
#+begin_src elisp
(savehist-mode)
#+end_src
Automatically save history on exit.
#+begin_example elisp
(add-hook 'kill-emacs-hook #'savehist-save)
#+end_example
Ensure savehist file is loaded.
#+begin_src elisp
(unless savehist-loaded
(load-file savehist-file))
#+end_src
Add addtional variable lists to save.
#+begin_src elisp
(dolist (var '(command-history
register-alist
mark-ring
kill-ring
search-ring
regexp-search-ring))
(cl-pushnew var savehist-additional-variables))
#+end_src
* Global Keybindings
Unlock previously unusable keybinding.
#+begin_src elisp
(define-key input-decode-map [?\C-\[] (kbd "<C-[>"))
#+end_src
File actions.
#+begin_src elisp
(keymap-global-set "C-x x R" #'rename-visited-file)
(keymap-global-set "C-x x D" #'delete-file)
#+end_src
Window actions.
#+begin_src elisp
(keymap-global-set "M-o" #'other-window)
(keymap-global-set "M-O" #'window-swap-states)
(keymap-global-set "M-V" #'scroll-other-window-down)
(keymap-global-set "C-S-V" #'scroll-other-window)
(keymap-global-set "C-M-<" #'beginning-of-buffer-other-window)
(keymap-global-set "C-M->" #'end-of-buffer-other-window)
(keymap-global-set "C-M-]" #'next-buffer)
(keymap-global-set "M-ESC" #'previous-buffer) ; C-M-[ translates to M-ESC
#+end_src
Set meta-key quick actions to mirror =C-x DIGIT= bindings, therefore reducing the need for additional keypresses.
These bindings override their corresponding numerical argument, however these can be can be alternatively called with =C-u DIGIT= or =C-DIGIT=.
#+begin_src elisp
(keymap-global-set "C-M-0" #'kill-buffer-and-window)
(keymap-global-set "C-M--" #'kill-this-buffer)
(keymap-global-set "M-0" #'delete-window)
(keymap-global-set "M-1" #'delete-other-windows)
(keymap-global-set "M-2" #'split-window-below)
(keymap-global-set "M-3" #'split-window-right)
(keymap-global-set "M-4" #'ctl-x-4-prefix)
(keymap-global-set "M-5" #'ctl-x-5-prefix)
(keymap-global-set "M-6" (keymap-global-lookup "C-x 6"))
;; (keymap-global-set "M-7" (keymap-global-lookup "C-x 7"))
(keymap-global-set "M-8" (keymap-global-lookup "C-x 8"))
;; (keymap-global-set "M-9" (keymap-global-lookup "C-x 9"))
#+end_src
Tab actions.
#+begin_src elisp
(keymap-global-set "C-x C-<tab>" #'tab-new)
(keymap-global-set "C-x C-<backspace>" #'tab-close)
(keymap-global-set "C-x t l" #'tab-list)
(keymap-global-set "C-x t <tab>" #'toggle-frame-tab-bar)
#+end_src
Improve region text manipulation.
#+begin_src elisp
(keymap-global-set "M-c" #'capitalize-dwim)
(keymap-global-set "M-l" #'downcase-dwim)
(keymap-global-set "M-u" #'upcase-dwim)
(keymap-global-set "M-U" #'upcase-char)
#+end_src
Help actions.
#+begin_src elisp
(keymap-global-set "C-h M" #'describe-keymap)
(keymap-global-set "C-h j" #'describe-char)
#+end_src
Display modes.
#+begin_src elisp
(keymap-global-set "C-x x c" #'display-fill-column-indicator-mode)
(keymap-global-set "C-x x l" #'display-line-numbers-mode)
(keymap-global-set "C-x x h" #'hl-line-mode)
(keymap-global-set "C-x x o" #'overwrite-mode)
(keymap-global-set "C-x x s" #'prettify-symbols-mode)
(keymap-global-set "C-x x w" #'visual-line-mode)
(keymap-global-set "C-x x SPC" #'whitespace-mode)
#+end_src
* Version Control
Rebind diff-mode's ~diff-goto-source~ keybinding due to conflict with =M-o=.
#+begin_src elisp
(with-eval-after-load 'diff-mode
(keymap-set diff-mode-map "M-o" #'other-window)
(keymap-set diff-mode-map "M-j" #'diff-goto-source))
#+end_src
|