diff options
author | Case Duckworth | 2023-05-10 13:08:35 -0500 |
---|---|---|
committer | Case Duckworth | 2023-05-10 13:08:35 -0500 |
commit | 43bed1f97e6f1a229553d7a25dc437741326772e (patch) | |
tree | 690012bd1a3797c41dff9b181f2e3ec44bd942ce /basics.el | |
parent | changes (diff) | |
download | emacs-43bed1f97e6f1a229553d7a25dc437741326772e.tar.gz emacs-43bed1f97e6f1a229553d7a25dc437741326772e.zip |
Bankruptcy 10
Diffstat (limited to 'basics.el')
-rw-r--r-- | basics.el | 680 |
1 files changed, 0 insertions, 680 deletions
diff --git a/basics.el b/basics.el deleted file mode 100644 index 1405c84..0000000 --- a/basics.el +++ /dev/null | |||
@@ -1,680 +0,0 @@ | |||
1 | ;;; basics.el --- Super basic Emacs settings -*- lexical-binding: t -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;; These are the settings that I literally cannot live without. Basic | ||
6 | ;; settings, built-in packages, that kind of stuff. Everything else | ||
7 | ;; goes in init.el. | ||
8 | |||
9 | ;;; Code: | ||
10 | |||
11 | (push (locate-user-emacs-file "lisp/") load-path) | ||
12 | (require 'acdw) | ||
13 | |||
14 | ;;; Directories | ||
15 | |||
16 | (defdir etc/ (locate-user-emacs-file "etc/") | ||
17 | "Where various Emacs files are placed." | ||
18 | :makedir) | ||
19 | |||
20 | (defdir sync/ "~/sync/" | ||
21 | "My Syncthing directory." | ||
22 | :makedir) | ||
23 | |||
24 | (defdir private/ (sync/ "emacs/private/") | ||
25 | "Private files and stuff." | ||
26 | :makedir) | ||
27 | |||
28 | (use-package no-littering | ||
29 | :ensure t :demand t | ||
30 | :preface | ||
31 | (setq-default no-littering-etc-directory etc/ | ||
32 | no-littering-var-directory etc/)) | ||
33 | |||
34 | |||
35 | ;;; Settings | ||
36 | |||
37 | ;; Async | ||
38 | (setq-default async-shell-command-buffer 'new-buffer | ||
39 | async-shell-command-display-buffer nil) | ||
40 | |||
41 | ;; Scrolling | ||
42 | (setq-default auto-hscroll-mode t | ||
43 | auto-window-vscroll nil | ||
44 | fast-but-imprecise-scrolling t | ||
45 | hscroll-margin 1 | ||
46 | hscroll-step 1 | ||
47 | scroll-conservatively 25 | ||
48 | scroll-margin 0 | ||
49 | scroll-preserve-screen-position 1 | ||
50 | scroll-step 1) | ||
51 | (scroll-bar-mode -1) | ||
52 | (horizontal-scroll-bar-mode -1) | ||
53 | |||
54 | ;; Cursor | ||
55 | (setq-default cursor-in-non-selected-windows 'hollow | ||
56 | cursor-type 'bar | ||
57 | blink-cursor-blinks 1 | ||
58 | blink-cursor-interval 0.25 | ||
59 | blink-cursor-delay 0.25) | ||
60 | (blink-cursor-mode) | ||
61 | |||
62 | ;; Mouse | ||
63 | (setq-default mouse-drag-copy-region t | ||
64 | mouse-wheel-progressive-speed nil | ||
65 | mouse-yank-at-point t) | ||
66 | |||
67 | ;; Dialogs | ||
68 | (unless (boundp 'use-short-answers) | ||
69 | (fset 'yes-or-no-p 'y-or-n-p)) | ||
70 | |||
71 | (setq-default read-answer-short t | ||
72 | use-dialog-box nil | ||
73 | use-file-dialog nil | ||
74 | use-short-answers t) | ||
75 | |||
76 | ;; Minibuffer | ||
77 | (setq-default completion-ignore-case t | ||
78 | read-buffer-completion-ignore-case t | ||
79 | read-file-name-completion-ignore-case t | ||
80 | completions-detailed t | ||
81 | enable-recursive-minibuffers t | ||
82 | file-name-shadow-properties '(invisible t intangible t) | ||
83 | minibuffer-eldef-shorten-default t | ||
84 | minibuffer-prompt-properties '( read-only t | ||
85 | cursor-intangible t | ||
86 | face minibuffer-prompt)) | ||
87 | (file-name-shadow-mode) | ||
88 | (minibuffer-electric-default-mode) | ||
89 | |||
90 | (define-minor-mode truncate-lines-local-mode | ||
91 | "Truncate lines locally in a buffer." | ||
92 | :lighter " ..." | ||
93 | :group 'display | ||
94 | (setq-local truncate-lines truncate-lines-local-mode)) | ||
95 | |||
96 | (add-hook 'minibuffer-setup-hook #'truncate-lines-local-mode) | ||
97 | |||
98 | (require 'savehist) | ||
99 | (setq-default history-length 1024 | ||
100 | history-delete-duplicates t | ||
101 | ;; savehist-file (etc/ "savehist.el") | ||
102 | savehist-save-minibuffer-history t | ||
103 | savehist-autosave-interval 30) | ||
104 | (savehist-mode) | ||
105 | |||
106 | ;; Killing and yanking | ||
107 | (setq-default kill-do-not-save-duplicates t | ||
108 | kill-read-only-ok t | ||
109 | ;; XXX: This setting causes an error message the first time it's | ||
110 | ;; called: "Selection owner couldn't convert: TIMESTAMP". I have | ||
111 | ;; absolutely no idea why I get this error, but it's generated in | ||
112 | ;; `x_get_foreign_selection'. I also can't inhibit the message or | ||
113 | ;; do anything else with it, so for now, I'll just live with the | ||
114 | ;; message. | ||
115 | save-interprogram-paste-before-kill t | ||
116 | yank-pop-change-selection t) | ||
117 | (delete-selection-mode) | ||
118 | |||
119 | ;; Notifying the user | ||
120 | (setq-default echo-keystrokes 0.01 | ||
121 | ring-bell-function #'ignore) | ||
122 | |||
123 | ;; Point and mark | ||
124 | (setq-default set-mark-command-repeat-pop t) | ||
125 | |||
126 | ;; The system | ||
127 | (setq-default read-process-output-max (* 10 1024 1024)) | ||
128 | |||
129 | ;; Startup | ||
130 | (setq-default inhibit-startup-screen t | ||
131 | initial-buffer-choice t | ||
132 | initial-scratch-message nil) | ||
133 | |||
134 | (define-advice startup-echo-area-message (:override ()) | ||
135 | (if (get-buffer "*Warnings*") | ||
136 | ";_;" | ||
137 | "^_^")) | ||
138 | |||
139 | (menu-bar-mode -1) | ||
140 | (tool-bar-mode -1) | ||
141 | (tooltip-mode -1) | ||
142 | |||
143 | ;; Text editing | ||
144 | (setq-default fill-column 80 | ||
145 | sentence-end-double-space nil | ||
146 | tab-width 8 | ||
147 | tab-always-indent 'complete) | ||
148 | (global-so-long-mode) | ||
149 | |||
150 | (setq-default show-paren-delay 0.01 | ||
151 | show-paren-style 'parenthesis | ||
152 | show-paren-when-point-in-periphery t | ||
153 | show-paren-when-point-inside-paren t) | ||
154 | (show-paren-mode) | ||
155 | (electric-pair-mode) | ||
156 | |||
157 | ;; Encodings | ||
158 | (set-language-environment "UTF-8") | ||
159 | (setq-default buffer-file-coding-system 'utf-8-unix | ||
160 | coding-system-for-read 'utf-8-unix | ||
161 | coding-system-for-write 'utf-8-unix | ||
162 | default-process-coding-system '(utf-8-unix . utf-8-unix) | ||
163 | locale-coding-system 'utf-8-unix) | ||
164 | (set-charset-priority 'unicode) | ||
165 | (prefer-coding-system 'utf-8-unix) | ||
166 | (set-default-coding-systems 'utf-8-unix) | ||
167 | (set-terminal-coding-system 'utf-8-unix) | ||
168 | (set-keyboard-coding-system 'utf-8-unix) | ||
169 | (pcase system-type | ||
170 | ((or 'ms-dos 'windows-nt) | ||
171 | (set-clipboard-coding-system 'utf-16-le) | ||
172 | (set-selection-coding-system 'utf-16-le)) | ||
173 | (_ | ||
174 | (set-selection-coding-system 'utf-8) | ||
175 | (set-clipboard-coding-system 'utf-8))) | ||
176 | |||
177 | ;; Abbrev | ||
178 | (setq-default abbrev-file-name (sync/ "abbrev.el") | ||
179 | save-abbrevs 'silently) | ||
180 | |||
181 | ;; Files | ||
182 | (setq-default auto-revert-verbose nil | ||
183 | global-auto-revert-non-file-buffers t | ||
184 | create-lockfiles nil | ||
185 | find-file-visit-truename t | ||
186 | mode-require-final-newline t | ||
187 | view-read-only t | ||
188 | save-silently t) | ||
189 | (global-auto-revert-mode) | ||
190 | |||
191 | (setq-default auto-save-default nil | ||
192 | auto-save-interval 1 | ||
193 | auto-save-no-message t | ||
194 | auto-save-timeout 1 | ||
195 | auto-save-visited-interval 1 | ||
196 | remote-file-name-inhibit-auto-save-visited t) | ||
197 | (add-to-list 'auto-save-file-name-transforms | ||
198 | `(".*" ,(etc/ "auto-save/" t) t)) | ||
199 | (auto-save-visited-mode) | ||
200 | |||
201 | (setq-default backup-by-copying t | ||
202 | version-control t | ||
203 | kept-new-versions 8 | ||
204 | kept-old-versions 8 | ||
205 | delete-old-versions t | ||
206 | backup-directory-alist | ||
207 | `(("^/dev/shm" . nil) | ||
208 | ("^/tmp" . nil) | ||
209 | (,(getenv "XDG_RUNTIME_DIR") . nil) | ||
210 | ("." . ,(no-littering-expand-etc-file-name "backup")))) | ||
211 | |||
212 | (require 'recentf) | ||
213 | (setq-default ;; recentf-save-file (etc/ "recentf" t) | ||
214 | recentf-max-menu-items 500 | ||
215 | recentf-max-saved-items nil ; Save the whole list | ||
216 | recentf-auto-cleanup 'mode | ||
217 | recentf-case-fold-search t) | ||
218 | (add-to-list 'recentf-exclude etc/) | ||
219 | (add-to-list 'recentf-exclude "-autoloads.el\\'") | ||
220 | (add-hook 'buffer-list-update-hook #'recentf-track-opened-file) | ||
221 | (add-hook 'after-save-hook #'recentf-save-list) | ||
222 | (recentf-mode) | ||
223 | |||
224 | (require 'saveplace) | ||
225 | (setq-default ;; save-place-file (etc/ "places.el") | ||
226 | save-place-forget-unreadable-files (eq system-type | ||
227 | 'gnu/linux)) | ||
228 | (save-place-mode) | ||
229 | |||
230 | (require 'uniquify) | ||
231 | (setq uniquify-after-kill-buffer-p t | ||
232 | uniquify-buffer-name-style 'forward | ||
233 | uniquify-ignore-buffers-re "^\\*" | ||
234 | uniquify-separator path-separator) | ||
235 | |||
236 | (setq-local vc-follow-symlinks t | ||
237 | vc-make-backup-files t) | ||
238 | |||
239 | ;; Whitespace | ||
240 | (require 'whitespace) | ||
241 | (setq-default whitespace-style | ||
242 | '(face trailing tabs tab-mark)) | ||
243 | (global-whitespace-mode) | ||
244 | (add-hook 'before-save-hook | ||
245 | (defun delete-trailing-whitespace-except-current-line () | ||
246 | (save-excursion | ||
247 | (delete-trailing-whitespace (point-min) | ||
248 | (line-beginning-position)) | ||
249 | (delete-trailing-whitespace (line-end-position) | ||
250 | (point-max))))) | ||
251 | |||
252 | ;; Native compilation | ||
253 | (setq-default native-comp-async-report-warnings-errors 'silent | ||
254 | native-comp-deferred-compilation t | ||
255 | native-compile-target-directory (etc/ "eln" t)) | ||
256 | (when (boundp 'native-comp-eln-load-path) | ||
257 | (add-to-list 'native-comp-eln-load-path native-compile-target-directory)) | ||
258 | (when (fboundp 'startup-redirect-eln-cache) | ||
259 | (startup-redirect-eln-cache native-compile-target-directory)) | ||
260 | |||
261 | ;; Custom file | ||
262 | (setq-default custom-file (private/ "custom.el")) | ||
263 | (define-advice package--save-selected-packages | ||
264 | (:around (orig &rest args) no-custom) | ||
265 | "Don't save `package-selected-packages' to `custom-file'." | ||
266 | (let ((custom-file (expand-file-name "custom.el" | ||
267 | temporary-file-directory))) | ||
268 | (apply orig args))) | ||
269 | |||
270 | ;; Goto Address | ||
271 | (if (fboundp 'global-goto-address-mode) | ||
272 | (global-goto-address-mode) | ||
273 | (add-hook 'after-change-major-mode-hook #'goto-address-mode)) | ||
274 | |||
275 | ;; Winner | ||
276 | (winner-mode) | ||
277 | |||
278 | |||
279 | ;;; Keybindings | ||
280 | |||
281 | (defun other-window|switch-buffer (arg) | ||
282 | "Call `other-window' or `switch-buffer' depending on windows. | ||
283 | When called with prefix ARG, unconditionally switch buffer." | ||
284 | (interactive "P") | ||
285 | (if (or arg (one-window-p)) | ||
286 | (switch-to-buffer (other-buffer) nil t) | ||
287 | (other-window 1))) | ||
288 | |||
289 | (defun delete-window|bury-buffer () | ||
290 | "Delete the current window, or bury the current buffer. | ||
291 | If the current window is the only window, bury the buffer." | ||
292 | (interactive) | ||
293 | (condition-case e | ||
294 | (delete-window) | ||
295 | (t (bury-buffer)))) | ||
296 | |||
297 | (defun +cycle-spacing (&optional n) | ||
298 | ;; `cycle-spacing' is wildly different in 29.1 over 28. | ||
299 | "Negate N argument on `cycle-spacing'. | ||
300 | That is, with a positive N, deletes newlines as well, leaving -N | ||
301 | spaces. If N is negative, it will not delete newlines and leave | ||
302 | N spaces." | ||
303 | (interactive "*p") | ||
304 | (cycle-spacing (- n))) | ||
305 | |||
306 | (defun +comment-dwim (&optional prefix) | ||
307 | "Comments or uncomments current line or region. | ||
308 | When called with PREFIX, start a comment at the end of the | ||
309 | current line." | ||
310 | (interactive "P") | ||
311 | (if prefix | ||
312 | (comment-indent) | ||
313 | (apply #'comment-or-uncomment-region | ||
314 | (if (region-active-p) | ||
315 | (list (region-beginning) | ||
316 | (region-end)) | ||
317 | (list (line-beginning-position) | ||
318 | (line-end-position)))))) | ||
319 | |||
320 | (defun +kill-buffer (&optional buffer-or-name) | ||
321 | "Kill the current buffer, or BUFFER-OR-NAME. | ||
322 | When called interactively, prompt the user when given a prefix | ||
323 | argument." | ||
324 | (interactive "P") | ||
325 | (cond | ||
326 | ((bufferp buffer-or-name) | ||
327 | (kill-buffer buffer-or-name)) | ||
328 | ((null buffer-or-name) | ||
329 | (kill-current-buffer)) | ||
330 | (:else | ||
331 | (kill-buffer (read-buffer "Kill: " nil :require-match))))) | ||
332 | |||
333 | (defun +backward-kill-word (arg) | ||
334 | "Kill ARG words backward unless at the beginning of a line. | ||
335 | When at the beginning of a line, delete blank lines before point." | ||
336 | (interactive "p") | ||
337 | (cond | ||
338 | ((bolp) | ||
339 | ;; This is the first bit of `delete-blank-lines'. -- acdw | ||
340 | (let (thisblank singleblank) | ||
341 | (save-excursion | ||
342 | (beginning-of-line) | ||
343 | (setq thisblank (looking-at "[ \t]*$")) | ||
344 | ;; Set singleblank if there is just one blank line here. | ||
345 | (setq singleblank | ||
346 | (and thisblank | ||
347 | (not (looking-at "[ \t]*\n[ \t]*$")) | ||
348 | (or (bobp) | ||
349 | (progn (forward-line -1) | ||
350 | (not (looking-at "[ \t]*$"))))))) | ||
351 | ;; Delete preceding blank lines, and this one too if it's the only one. | ||
352 | (if thisblank | ||
353 | (progn | ||
354 | (beginning-of-line) | ||
355 | (if singleblank (forward-line 1)) | ||
356 | (delete-region (point) | ||
357 | (if (re-search-backward "[^ \t\n]" nil t) | ||
358 | (progn (forward-line 1) (point)) | ||
359 | (point-min))))) | ||
360 | (if (or (not thisblank) | ||
361 | singleblank) | ||
362 | (progn | ||
363 | (beginning-of-line) | ||
364 | (backward-delete-char 1))))) | ||
365 | (:else | ||
366 | (backward-kill-word arg)))) | ||
367 | |||
368 | (global-set-key [remap eval-expression] #'pp-eval-expression) | ||
369 | (global-set-key (kbd "M-o") #'other-window|switch-buffer) | ||
370 | (global-set-key [remap delete-window] #'delete-window|bury-buffer) | ||
371 | (global-set-key [remap cycle-spacing] #'+cycle-spacing) | ||
372 | (global-set-key (kbd "C-x C-k") #'+kill-buffer) | ||
373 | (global-set-key [remap comment-dwim] #'+comment-dwim) | ||
374 | (global-set-key [remap undo] #'undo-only) | ||
375 | (global-set-key [remap backward-kill-word] #'+backward-kill-word) | ||
376 | |||
377 | (global-set-key [f10] #'tmm-menubar) | ||
378 | (advice-add 'tmm-add-prompt :after 'minibuffer-hide-completions) | ||
379 | |||
380 | (when (fboundp '+lisp-comment-or-uncomment-sexp) | ||
381 | (define-key lisp-mode-map (kbd "C-M-;") #'+lisp-comment-or-uncomment-sexp) | ||
382 | (define-key emacs-lisp-mode-map (kbd "C-M-;") | ||
383 | #'+lisp-comment-or-uncomment-sexp) | ||
384 | (with-eval-after-load 'scheme | ||
385 | (define-key scheme-mode-map (kbd "C-M-;") | ||
386 | #'+lisp-comment-or-uncomment-sexp))) | ||
387 | |||
388 | (define-key emacs-lisp-mode-map (kbd "C-c C-c") | ||
389 | #'eval-defun) | ||
390 | (define-key emacs-lisp-mode-map (kbd "C-c C-k") | ||
391 | #'elisp-eval-region-or-buffer) | ||
392 | (define-key lisp-interaction-mode-map (kbd "C-c C-c") | ||
393 | #'eval-defun) | ||
394 | (define-key lisp-interaction-mode-map (kbd "C-c C-k") | ||
395 | #'elisp-eval-region-or-buffer) | ||
396 | (define-advice eval-region (:around (orig start end &rest args) pulse) | ||
397 | (apply orig start end args) | ||
398 | (pulse-momentary-highlight-region start end)) | ||
399 | |||
400 | (global-set-key (kbd "C-x C-b") #'ibuffer) | ||
401 | |||
402 | |||
403 | ;;; Hooks | ||
404 | |||
405 | (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) | ||
406 | |||
407 | (add-hook 'find-file-not-found-functions | ||
408 | (defun create-missing-directories () | ||
409 | "Automatically create missing directories." | ||
410 | (let ((target-dir (file-name-directory buffer-file-name))) | ||
411 | (unless (file-exists-p target-dir) | ||
412 | (make-directory target-dir :parents))))) | ||
413 | |||
414 | (add-hook 'find-file-hook | ||
415 | (defun vc-remote-off () | ||
416 | "Turn VC off when remote." | ||
417 | (when (file-remote-p (buffer-file-name)) | ||
418 | (setq-local vc-handled-backends nil)))) | ||
419 | |||
420 | |||
421 | ;;; Advice | ||
422 | |||
423 | (define-advice switch-to-buffer (:after (&rest _) normal-mode) | ||
424 | "Automatically determine the mode for non-file buffers." | ||
425 | (when-let ((_ (and (eq major-mode 'fundamental-mode))) | ||
426 | (buffer-file-name (buffer-name))) | ||
427 | (normal-mode))) | ||
428 | |||
429 | (define-advice canonically-space-region | ||
430 | (:around (orig &rest args) double-space-sentences) | ||
431 | "Always double-space sentences canonically." | ||
432 | (let ((sentence-end-double-space t)) | ||
433 | (apply orig args))) | ||
434 | |||
435 | |||
436 | ;;; Packages | ||
437 | |||
438 | (use-package _acdw | ||
439 | :load-path private/) | ||
440 | |||
441 | (use-package custom-allowed | ||
442 | :load-path "~/src/custom-allowed.el/" | ||
443 | :config | ||
444 | (add-to-list 'custom-allowed-variables 'safe-local-variable-values) | ||
445 | (add-to-list 'custom-allowed-variables 'ispell-buffer-session-localwords) | ||
446 | (add-to-list 'custom-allowed-variables 'warning-suppress-types) | ||
447 | (add-to-list 'custom-allowed-variables 'calendar-latitude) | ||
448 | (add-to-list 'custom-allowed-variables 'calendar-longitude) | ||
449 | (add-to-list 'custom-allowed-variables 'user-full-name) | ||
450 | (add-to-list 'custom-allowed-variables 'user-mail-address) | ||
451 | :hook | ||
452 | (after-init-hook . custom-allowed-load-custom-file)) | ||
453 | |||
454 | (use-package sophomore | ||
455 | :load-path "~/src/sophomore.el/" | ||
456 | :config | ||
457 | (sophomore-enable-all) | ||
458 | (sophomore-disable 'view-hello-file | ||
459 | 'describe-gnu-project | ||
460 | 'suspend-frame) | ||
461 | (sophomore-mode)) | ||
462 | |||
463 | (use-package compat | ||
464 | ;; This shouldn't be necessary, but sadly I believe that it is. | ||
465 | :ensure t) | ||
466 | |||
467 | (use-package vertico | ||
468 | :ensure t :demand t | ||
469 | :config | ||
470 | (setq vertico-cycle t) | ||
471 | (add-hook 'vertico-mode-hook | ||
472 | (defun vertico-mode@fix-completions () | ||
473 | (setq completion-in-region-function | ||
474 | (if vertico-mode | ||
475 | #'consult-completion-in-region | ||
476 | #'completion--in-region)))) | ||
477 | (vertico-mode)) | ||
478 | |||
479 | (use-package vertico-directory | ||
480 | :after vertico | ||
481 | :bind (:map vertico-map | ||
482 | ("C-<backspace>" . vertico-directory-delete-word)) | ||
483 | :hook (rfn-shadow-update-overlay-hook . vertico-directory-tidy)) | ||
484 | |||
485 | (use-package vertico-mouse | ||
486 | :after vertico | ||
487 | :config (vertico-mouse-mode)) | ||
488 | |||
489 | ;; Example configuration for Consult | ||
490 | (use-package consult | ||
491 | :ensure t | ||
492 | ;; Replace bindings. Lazily loaded due by `use-package'. | ||
493 | :bind (;; C-c bindings (mode-specific-map) | ||
494 | ("C-c h" . consult-history) | ||
495 | ("C-c m" . consult-mode-command) | ||
496 | ("C-c k" . consult-kmacro) | ||
497 | ;; C-x bindings (ctl-x-map) | ||
498 | ("C-x M-:" . consult-complex-command) | ||
499 | ("C-x b" . consult-buffer) | ||
500 | ("C-x 4 b" . consult-buffer-other-window) | ||
501 | ("C-x 5 b" . consult-buffer-other-frame) | ||
502 | ("C-x r b" . consult-bookmark) | ||
503 | ("C-x p b" . consult-project-buffer) | ||
504 | ;; Custom M-# bindings for fast register access | ||
505 | ("M-#" . consult-register-load) | ||
506 | ("M-'" . consult-register-store) | ||
507 | ("C-M-#" . consult-register) | ||
508 | ;; Other custom bindings | ||
509 | ("M-y" . consult-yank-pop) | ||
510 | ;; M-g bindings (goto-map) | ||
511 | ("M-g e" . consult-compile-error) | ||
512 | ("M-g f" . consult-flymake) | ||
513 | ("M-g g" . consult-goto-line) | ||
514 | ("M-g M-g" . consult-goto-line) | ||
515 | ("M-g o" . consult-outline) | ||
516 | ("M-g m" . consult-mark) | ||
517 | ("M-g k" . consult-global-mark) | ||
518 | ("M-g i" . consult-imenu) | ||
519 | ("M-g I" . consult-imenu-multi) | ||
520 | ;; M-s bindings (search-map) | ||
521 | ("M-s d" . consult-find) | ||
522 | ("M-s D" . consult-locate) | ||
523 | ("M-s g" . consult-grep) | ||
524 | ("M-s G" . consult-git-grep) | ||
525 | ("M-s r" . consult-ripgrep) | ||
526 | ("M-s l" . consult-line) | ||
527 | ("M-s L" . consult-line-multi) | ||
528 | ("M-s k" . consult-keep-lines) | ||
529 | ("M-s u" . consult-focus-lines) | ||
530 | ;; Isearch integration | ||
531 | ("M-s e" . consult-isearch-history) | ||
532 | :map isearch-mode-map | ||
533 | ("M-e" . consult-isearch-history) | ||
534 | ("M-s e" . consult-isearch-history) | ||
535 | ("M-s l" . consult-line) | ||
536 | ("M-s L" . consult-line-multi) | ||
537 | ;; Minibuffer history | ||
538 | :map minibuffer-local-map | ||
539 | ("M-s" . consult-history) | ||
540 | ("M-r" . consult-history)) | ||
541 | |||
542 | ;; Enable automatic preview at point in the *Completions* buffer. This is | ||
543 | ;; relevant when you use the default completion UI. | ||
544 | :hook (completion-list-mode . consult-preview-at-point-mode) | ||
545 | |||
546 | ;; The :init configuration is always executed (Not lazy) | ||
547 | :init | ||
548 | |||
549 | ;; Optionally configure the register formatting. This improves the register | ||
550 | ;; preview for `consult-register', `consult-register-load', | ||
551 | ;; `consult-register-store' and the Emacs built-ins. | ||
552 | (setq register-preview-delay 0.5 | ||
553 | register-preview-function #'consult-register-format) | ||
554 | |||
555 | ;; Optionally tweak the register preview window. | ||
556 | ;; This adds thin lines, sorting and hides the mode line of the window. | ||
557 | (advice-add #'register-preview :override #'consult-register-window) | ||
558 | |||
559 | (define-advice completing-read-multiple (:filter-args (args) indicator) | ||
560 | (cons (format "[CRM%s] %s" | ||
561 | (replace-regexp-in-string | ||
562 | "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" | ||
563 | crm-separator) | ||
564 | (car args)) | ||
565 | (cdr args))) | ||
566 | |||
567 | ;; Use Consult to select xref locations with preview | ||
568 | (setq xref-show-xrefs-function #'consult-xref | ||
569 | xref-show-definitions-function #'consult-xref) | ||
570 | |||
571 | (setq completion-in-region-function #'consult-completion-in-region) | ||
572 | |||
573 | ;; Configure other variables and modes in the :config section, | ||
574 | ;; after lazily loading the package. | ||
575 | :config | ||
576 | |||
577 | ;; Optionally configure preview. The default value | ||
578 | ;; is 'any, such that any key triggers the preview. | ||
579 | ;; (setq consult-preview-key 'any) | ||
580 | ;; (setq consult-preview-key (kbd "M-.")) | ||
581 | ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>"))) | ||
582 | ;; For some commands and buffer sources it is useful to configure the | ||
583 | ;; :preview-key on a per-command basis using the `consult-customize' macro. | ||
584 | (consult-customize | ||
585 | consult-theme :preview-key '(:debounce 0.2 any) | ||
586 | consult-ripgrep consult-git-grep consult-grep | ||
587 | consult-bookmark consult-recent-file consult-xref | ||
588 | consult--source-bookmark consult--source-file-register | ||
589 | consult--source-recent-file consult--source-project-recent-file | ||
590 | ;; :preview-key (kbd "M-.") | ||
591 | :preview-key '(:debounce 0.4 any)) | ||
592 | |||
593 | ;; (consult-customize consult-line | ||
594 | ;; consult-ripgrep | ||
595 | ;; :initial (when (use-region-p) | ||
596 | ;; (buffer-substring-no-properties | ||
597 | ;; (region-beginning) (region-end)))) | ||
598 | |||
599 | ;; Optionally configure the narrowing key. | ||
600 | ;; Both < and C-+ work reasonably well. | ||
601 | (setq consult-narrow-key "<") ;; (kbd "C-+") | ||
602 | |||
603 | ;; Optionally make narrowing help available in the minibuffer. | ||
604 | ;; You may want to use `embark-prefix-help-command' or which-key instead. | ||
605 | (define-key consult-narrow-map (vconcat consult-narrow-key "?") | ||
606 | #'consult-narrow-help)) | ||
607 | |||
608 | (use-package orderless | ||
609 | :ensure t :demand t | ||
610 | :init | ||
611 | (setq completion-styles '(orderless substring basic) | ||
612 | completion-category-defaults nil | ||
613 | completion-category-overrides | ||
614 | '((file (styles basic partial-completion orderless))))) | ||
615 | |||
616 | (use-package marginalia | ||
617 | :ensure t :demand t | ||
618 | :config | ||
619 | (marginalia-mode)) | ||
620 | |||
621 | (use-package embark | ||
622 | :ensure t | ||
623 | :bind | ||
624 | (("C-." . embark-act) | ||
625 | ("M-." . embark-dwim) | ||
626 | ("C-h B" . embark-bindings)) | ||
627 | :init | ||
628 | (setq prefix-help-command #'embark-prefix-help-command) | ||
629 | :config | ||
630 | (add-to-list 'display-buffer-alist | ||
631 | '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" | ||
632 | nil | ||
633 | (window-parameters (mode-line-format . none))))) | ||
634 | |||
635 | (use-package embark-consult | ||
636 | :ensure t | ||
637 | :hook | ||
638 | (embark-collect-mode . consult-preview-at-point-mode)) | ||
639 | |||
640 | (use-package undo-fu | ||
641 | :ensure t | ||
642 | :init | ||
643 | (setq undo-limit 67108864) ; 64mb. | ||
644 | (setq undo-strong-limit 100663296) ; 96mb. | ||
645 | (setq undo-outer-limit 1006632960) ; 960mb. | ||
646 | :bind (("C-/" . undo-fu-only-undo) | ||
647 | ("C-?" . undo-fu-only-redo))) | ||
648 | |||
649 | (use-package undo-fu-session | ||
650 | :ensure t | ||
651 | :config | ||
652 | (setq undo-fu-session-compression (cond | ||
653 | ((executable-find "gunzip") 'gz) | ||
654 | ((executable-find "bzip2") 'bz2)) | ||
655 | undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" | ||
656 | "/git-rebase-todo\\'")) | ||
657 | (global-undo-fu-session-mode)) | ||
658 | |||
659 | (use-package crux | ||
660 | :ensure t :demand t | ||
661 | :bind (("C-x 4 t" . crux-transpose-windows)) | ||
662 | :config | ||
663 | (crux-with-region-or-buffer indent-region) | ||
664 | (crux-with-region-or-buffer tabify) | ||
665 | (crux-with-region-or-buffer untabify) | ||
666 | (crux-reopen-as-root-mode)) | ||
667 | |||
668 | (use-package pixel-scroll | ||
669 | :demand t | ||
670 | :bind (([right-margin wheel-down] . pixel-scroll-precision) | ||
671 | ([right-margin double-wheel-down] . pixel-scroll-precision) | ||
672 | ([right-margin triple-wheel-down] . pixel-scroll-precision) | ||
673 | ([right-margin wheel-up] . pixel-scroll-precision) | ||
674 | ([right-margin double-wheel-up] . pixel-scroll-precision) | ||
675 | ([right-margin triple-wheel-up] . pixel-scroll-precision)) | ||
676 | :config | ||
677 | (when (fboundp 'pixel-scroll-precision-mode) | ||
678 | (pixel-scroll-precision-mode))) | ||
679 | |||
680 | ;;; basics.el ends here | ||