summary refs log tree commit diff stats
path: root/basics.el
diff options
context:
space:
mode:
authorCase Duckworth2023-01-16 12:46:27 -0600
committerCase Duckworth2023-01-16 12:46:27 -0600
commitb4e6518f7eff38d57d2ce5500fb6292d90e000f6 (patch)
tree7dfef6643619a1c187f0230e4f5db51d1fe5d4cb /basics.el
parentWhitespace etc. (diff)
downloademacs-b4e6518f7eff38d57d2ce5500fb6292d90e000f6.tar.gz
emacs-b4e6518f7eff38d57d2ce5500fb6292d90e000f6.zip
KEY SMASHSHHHH
Diffstat (limited to 'basics.el')
-rw-r--r--basics.el132
1 files changed, 59 insertions, 73 deletions
diff --git a/basics.el b/basics.el index 7b4b1fd..24e5047 100644 --- a/basics.el +++ b/basics.el
@@ -31,6 +31,7 @@
31 (setq-default no-littering-etc-directory etc/ 31 (setq-default no-littering-etc-directory etc/
32 no-littering-var-directory etc/)) 32 no-littering-var-directory etc/))
33 33
34
34;;; Settings 35;;; Settings
35 36
36;; Async 37;; Async
@@ -38,18 +39,17 @@
38 async-shell-command-display-buffer nil) 39 async-shell-command-display-buffer nil)
39 40
40;; Scrolling 41;; Scrolling
41(setq-default auto-hscroll-mode t 42(setq-default auto-hscroll-mode t
42 auto-window-vscroll nil 43 auto-window-vscroll nil
43 fast-but-imprecise-scrolling t 44 fast-but-imprecise-scrolling t
44 hscroll-margin 1 45 hscroll-margin 1
45 hscroll-step 1 46 hscroll-step 1
46 scroll-conservatively 25 47 scroll-conservatively 25
47 scroll-margin 0 48 scroll-margin 0
48 scroll-preserve-screen-position 1 49 scroll-preserve-screen-position 1
49 scroll-step 1) 50 scroll-step 1)
50(scroll-bar-mode -1) 51(scroll-bar-mode -1)
51(horizontal-scroll-bar-mode -1) 52(horizontal-scroll-bar-mode -1)
52(pixel-scroll-precision-mode)
53 53
54;; Cursor 54;; Cursor
55(setq-default cursor-in-non-selected-windows 'hollow 55(setq-default cursor-in-non-selected-windows 'hollow
@@ -95,7 +95,6 @@
95 95
96(add-hook 'minibuffer-setup-hook #'truncate-lines-local-mode) 96(add-hook 'minibuffer-setup-hook #'truncate-lines-local-mode)
97 97
98
99(require 'savehist) 98(require 'savehist)
100(setq-default history-length 1024 99(setq-default history-length 1024
101 history-delete-duplicates t 100 history-delete-duplicates t
@@ -233,8 +232,15 @@
233;; Whitespace 232;; Whitespace
234(require 'whitespace) 233(require 'whitespace)
235(setq-default whitespace-style 234(setq-default whitespace-style
236 '(face trailing tabs space-after-tab space-before-tab tab-mark)) 235 '(face trailing tabs tab-mark))
237(global-whitespace-mode) 236(global-whitespace-mode)
237(add-hook 'before-save-hook
238 (defun delete-trailing-whitespace-except-current-line ()
239 (save-excursion
240 (delete-trailing-whitespace (point-min)
241 (line-beginning-position))
242 (delete-trailing-whitespace (line-end-position)
243 (point-max)))))
238 244
239;; Native compilation 245;; Native compilation
240(setq-default native-comp-async-report-warnings-errors 'silent 246(setq-default native-comp-async-report-warnings-errors 'silent
@@ -261,6 +267,7 @@
261;; Winner 267;; Winner
262(winner-mode) 268(winner-mode)
263 269
270
264;;; Keybindings 271;;; Keybindings
265 272
266(defun other-window|switch-buffer (arg) 273(defun other-window|switch-buffer (arg)
@@ -321,6 +328,7 @@ N spaces."
321 328
322(global-set-key (kbd "C-x C-b") #'ibuffer) 329(global-set-key (kbd "C-x C-b") #'ibuffer)
323 330
331
324;;; Hooks 332;;; Hooks
325 333
326(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) 334(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
@@ -338,6 +346,7 @@ N spaces."
338 (when (file-remote-p (buffer-file-name)) 346 (when (file-remote-p (buffer-file-name))
339 (setq-local vc-handled-backends nil)))) 347 (setq-local vc-handled-backends nil))))
340 348
349
341;;; Advice 350;;; Advice
342 351
343(define-advice switch-to-buffer (:after (&rest _) normal-mode) 352(define-advice switch-to-buffer (:after (&rest _) normal-mode)
@@ -352,51 +361,7 @@ N spaces."
352 (let ((sentence-end-double-space t)) 361 (let ((sentence-end-double-space t))
353 (apply orig args))) 362 (apply orig args)))
354 363
355;; With region or ... 364
356(defun advise-region-or-buffer (&rest _)
357 "`:before' advice to work on the active region or whole buffer.
358See also `with-region-or-buffer'."
359 (interactive (if mark-active
360 (list (region-beginning) (region-end))
361 (list (point-min) (point-max)))))
362
363(defun advise-region-or-line (&rest _)
364 "`:before' advice to work on the active region or whole line.
365See also `with-region-or-line'."
366 (interactive (if mark-active
367 (list (region-beginning) (region-end))
368 (list (line-beginning-position) (line-end-position)))))
369
370(defun advise-region-or-to-eol (&rest _)
371 "`:before' advice to work on the active region or to end of line.
372See also `with-region-or-to-eol'."
373 (INTERACTIVE (if mark-active
374 (list (region-beginning) (region-end))
375 (list (point) (line-end-position)))))
376
377(defmacro with-region-or-buffer (&rest funcs)
378 "Advise FUNCS with `advise-region-or-buffer'."
379 `(progn
380 ,@(cl-loop for fn in funcs
381 collect
382 `(advice-add ',fn :before #'advise-region-or-buffer))))
383
384(defmacro with-region-or-line (&rest funcs)
385 "Advise FUNCS with `advise-region-or-line'."
386 `(progn
387 ,@(cl-loop for fn in funcs
388 collect
389 `(advice-add ',fn :before #'advise-region-or-line))))
390
391(defmacro with-region-or-to-eol (&rest funcs)
392 "Advise FUNCS with `advise-region-or-to-eol'."
393 `(progn
394 ,@(cl-loop for fn in funcs
395 collect
396 `(advice-add ',fn :before #'advise-region-or-to-eol))))
397
398(with-region-or-buffer indent-region)
399
400;;; Packages 365;;; Packages
401 366
402(use-package _acdw 367(use-package _acdw
@@ -460,23 +425,23 @@ See also `with-region-or-to-eol'."
460 ("C-c k" . consult-kmacro) 425 ("C-c k" . consult-kmacro)
461 ;; C-x bindings (ctl-x-map) 426 ;; C-x bindings (ctl-x-map)
462 ("C-x M-:" . consult-complex-command) 427 ("C-x M-:" . consult-complex-command)
463 ("C-x b" . consult-buffer) 428 ("C-x b" . consult-buffer)
464 ("C-x 4 b" . consult-buffer-other-window) 429 ("C-x 4 b" . consult-buffer-other-window)
465 ("C-x 5 b" . consult-buffer-other-frame) 430 ("C-x 5 b" . consult-buffer-other-frame)
466 ("C-x r b" . consult-bookmark) 431 ("C-x r b" . consult-bookmark)
467 ("C-x p b" . consult-project-buffer) 432 ("C-x p b" . consult-project-buffer)
468 ;; Custom M-# bindings for fast register access 433 ;; Custom M-# bindings for fast register access
469 ("M-#" . consult-register-load) 434 ("M-#" . consult-register-load)
470 ("M-'" . consult-register-store) 435 ("M-'" . consult-register-store)
471 ("C-M-#" . consult-register) 436 ("C-M-#" . consult-register)
472 ;; Other custom bindings 437 ;; Other custom bindings
473 ("M-y" . consult-yank-pop) 438 ("M-y" . consult-yank-pop)
474 ;; M-g bindings (goto-map) 439 ;; M-g bindings (goto-map)
475 ("M-g e" . consult-compile-error) 440 ("M-g e" . consult-compile-error)
476 ("M-g f" . consult-flymake) 441 ("M-g f" . consult-flymake)
477 ("M-g g" . consult-goto-line) 442 ("M-g g" . consult-goto-line)
478 ("M-g M-g" . consult-goto-line) 443 ("M-g M-g" . consult-goto-line)
479 ("M-g o" . consult-outline) 444 ("M-g o" . consult-outline)
480 ("M-g m" . consult-mark) 445 ("M-g m" . consult-mark)
481 ("M-g k" . consult-global-mark) 446 ("M-g k" . consult-global-mark)
482 ("M-g i" . consult-imenu) 447 ("M-g i" . consult-imenu)
@@ -494,14 +459,14 @@ See also `with-region-or-to-eol'."
494 ;; Isearch integration 459 ;; Isearch integration
495 ("M-s e" . consult-isearch-history) 460 ("M-s e" . consult-isearch-history)
496 :map isearch-mode-map 461 :map isearch-mode-map
497 ("M-e" . consult-isearch-history) 462 ("M-e" . consult-isearch-history)
498 ("M-s e" . consult-isearch-history) 463 ("M-s e" . consult-isearch-history)
499 ("M-s l" . consult-line) 464 ("M-s l" . consult-line)
500 ("M-s L" . consult-line-multi) 465 ("M-s L" . consult-line-multi)
501 ;; Minibuffer history 466 ;; Minibuffer history
502 :map minibuffer-local-map 467 :map minibuffer-local-map
503 ("M-s" . consult-history) 468 ("M-s" . consult-history)
504 ("M-r" . consult-history)) 469 ("M-r" . consult-history))
505 470
506 ;; Enable automatic preview at point in the *Completions* buffer. This is 471 ;; Enable automatic preview at point in the *Completions* buffer. This is
507 ;; relevant when you use the default completion UI. 472 ;; relevant when you use the default completion UI.
@@ -603,4 +568,25 @@ See also `with-region-or-to-eol'."
603 "/git-rebase-todo\\'")) 568 "/git-rebase-todo\\'"))
604 (global-undo-fu-session-mode)) 569 (global-undo-fu-session-mode))
605 570
571(use-package crux
572 :ensure t :demand t
573 :bind (("C-o" . crux-smart-open-line)
574 ("C-x 4 t" . crux-transpose-windows))
575 :config
576 (crux-with-region-or-buffer indent-region)
577 (crux-with-region-or-buffer tabify)
578 (crux-with-region-or-buffer untabify)
579 (crux-reopen-as-root-mode))
580
581(use-package pixel-scroll
582 :demand t
583 :bind (([right-margin wheel-down] . pixel-scroll-precision)
584 ([right-margin double-wheel-down] . pixel-scroll-precision)
585 ([right-margin triple-wheel-down] . pixel-scroll-precision)
586 ([right-margin wheel-up] . pixel-scroll-precision)
587 ([right-margin double-wheel-up] . pixel-scroll-precision)
588 ([right-margin triple-wheel-up] . pixel-scroll-precision))
589 :config
590 (pixel-scroll-precision-mode))
591
606;;; basics.el ends here 592;;; basics.el ends here