From b4e6518f7eff38d57d2ce5500fb6292d90e000f6 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 16 Jan 2023 12:46:27 -0600 Subject: KEY SMASHSHHHH --- basics.el | 132 ++++++++++++++++++++++++++++---------------------------------- 1 file changed, 59 insertions(+), 73 deletions(-) (limited to 'basics.el') diff --git a/basics.el b/basics.el index 7b4b1fd..24e5047 100644 --- a/basics.el +++ b/basics.el @@ -31,6 +31,7 @@ (setq-default no-littering-etc-directory etc/ no-littering-var-directory etc/)) + ;;; Settings ;; Async @@ -38,18 +39,17 @@ async-shell-command-display-buffer nil) ;; Scrolling -(setq-default auto-hscroll-mode t - auto-window-vscroll nil - fast-but-imprecise-scrolling t - hscroll-margin 1 - hscroll-step 1 - scroll-conservatively 25 - scroll-margin 0 - scroll-preserve-screen-position 1 - scroll-step 1) +(setq-default auto-hscroll-mode t + auto-window-vscroll nil + fast-but-imprecise-scrolling t + hscroll-margin 1 + hscroll-step 1 + scroll-conservatively 25 + scroll-margin 0 + scroll-preserve-screen-position 1 + scroll-step 1) (scroll-bar-mode -1) (horizontal-scroll-bar-mode -1) -(pixel-scroll-precision-mode) ;; Cursor (setq-default cursor-in-non-selected-windows 'hollow @@ -95,7 +95,6 @@ (add-hook 'minibuffer-setup-hook #'truncate-lines-local-mode) - (require 'savehist) (setq-default history-length 1024 history-delete-duplicates t @@ -233,8 +232,15 @@ ;; Whitespace (require 'whitespace) (setq-default whitespace-style - '(face trailing tabs space-after-tab space-before-tab tab-mark)) + '(face trailing tabs tab-mark)) (global-whitespace-mode) +(add-hook 'before-save-hook + (defun delete-trailing-whitespace-except-current-line () + (save-excursion + (delete-trailing-whitespace (point-min) + (line-beginning-position)) + (delete-trailing-whitespace (line-end-position) + (point-max))))) ;; Native compilation (setq-default native-comp-async-report-warnings-errors 'silent @@ -261,6 +267,7 @@ ;; Winner (winner-mode) + ;;; Keybindings (defun other-window|switch-buffer (arg) @@ -321,6 +328,7 @@ N spaces." (global-set-key (kbd "C-x C-b") #'ibuffer) + ;;; Hooks (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) @@ -338,6 +346,7 @@ N spaces." (when (file-remote-p (buffer-file-name)) (setq-local vc-handled-backends nil)))) + ;;; Advice (define-advice switch-to-buffer (:after (&rest _) normal-mode) @@ -352,51 +361,7 @@ N spaces." (let ((sentence-end-double-space t)) (apply orig args))) -;; With region or ... -(defun advise-region-or-buffer (&rest _) - "`:before' advice to work on the active region or whole buffer. -See also `with-region-or-buffer'." - (interactive (if mark-active - (list (region-beginning) (region-end)) - (list (point-min) (point-max))))) - -(defun advise-region-or-line (&rest _) - "`:before' advice to work on the active region or whole line. -See also `with-region-or-line'." - (interactive (if mark-active - (list (region-beginning) (region-end)) - (list (line-beginning-position) (line-end-position))))) - -(defun advise-region-or-to-eol (&rest _) - "`:before' advice to work on the active region or to end of line. -See also `with-region-or-to-eol'." - (INTERACTIVE (if mark-active - (list (region-beginning) (region-end)) - (list (point) (line-end-position))))) - -(defmacro with-region-or-buffer (&rest funcs) - "Advise FUNCS with `advise-region-or-buffer'." - `(progn - ,@(cl-loop for fn in funcs - collect - `(advice-add ',fn :before #'advise-region-or-buffer)))) - -(defmacro with-region-or-line (&rest funcs) - "Advise FUNCS with `advise-region-or-line'." - `(progn - ,@(cl-loop for fn in funcs - collect - `(advice-add ',fn :before #'advise-region-or-line)))) - -(defmacro with-region-or-to-eol (&rest funcs) - "Advise FUNCS with `advise-region-or-to-eol'." - `(progn - ,@(cl-loop for fn in funcs - collect - `(advice-add ',fn :before #'advise-region-or-to-eol)))) - -(with-region-or-buffer indent-region) - + ;;; Packages (use-package _acdw @@ -460,23 +425,23 @@ See also `with-region-or-to-eol'." ("C-c k" . consult-kmacro) ;; C-x bindings (ctl-x-map) ("C-x M-:" . consult-complex-command) - ("C-x b" . consult-buffer) + ("C-x b" . consult-buffer) ("C-x 4 b" . consult-buffer-other-window) - ("C-x 5 b" . consult-buffer-other-frame) - ("C-x r b" . consult-bookmark) - ("C-x p b" . consult-project-buffer) + ("C-x 5 b" . consult-buffer-other-frame) + ("C-x r b" . consult-bookmark) + ("C-x p b" . consult-project-buffer) ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) - ("M-'" . consult-register-store) + ("M-'" . consult-register-store) ("C-M-#" . consult-register) ;; Other custom bindings - ("M-y" . consult-yank-pop) + ("M-y" . consult-yank-pop) ;; M-g bindings (goto-map) ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) - ("M-g g" . consult-goto-line) - ("M-g M-g" . consult-goto-line) - ("M-g o" . consult-outline) + ("M-g f" . consult-flymake) + ("M-g g" . consult-goto-line) + ("M-g M-g" . consult-goto-line) + ("M-g o" . consult-outline) ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) @@ -494,14 +459,14 @@ See also `with-region-or-to-eol'." ;; Isearch integration ("M-s e" . consult-isearch-history) :map isearch-mode-map - ("M-e" . consult-isearch-history) - ("M-s e" . consult-isearch-history) - ("M-s l" . consult-line) - ("M-s L" . consult-line-multi) + ("M-e" . consult-isearch-history) + ("M-s e" . consult-isearch-history) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) ;; Minibuffer history :map minibuffer-local-map - ("M-s" . consult-history) - ("M-r" . consult-history)) + ("M-s" . consult-history) + ("M-r" . consult-history)) ;; Enable automatic preview at point in the *Completions* buffer. This is ;; relevant when you use the default completion UI. @@ -603,4 +568,25 @@ See also `with-region-or-to-eol'." "/git-rebase-todo\\'")) (global-undo-fu-session-mode)) +(use-package crux + :ensure t :demand t + :bind (("C-o" . crux-smart-open-line) + ("C-x 4 t" . crux-transpose-windows)) + :config + (crux-with-region-or-buffer indent-region) + (crux-with-region-or-buffer tabify) + (crux-with-region-or-buffer untabify) + (crux-reopen-as-root-mode)) + +(use-package pixel-scroll + :demand t + :bind (([right-margin wheel-down] . pixel-scroll-precision) + ([right-margin double-wheel-down] . pixel-scroll-precision) + ([right-margin triple-wheel-down] . pixel-scroll-precision) + ([right-margin wheel-up] . pixel-scroll-precision) + ([right-margin double-wheel-up] . pixel-scroll-precision) + ([right-margin triple-wheel-up] . pixel-scroll-precision)) + :config + (pixel-scroll-precision-mode)) + ;;; basics.el ends here -- cgit 1.4.1-21-gabe81