From 43bed1f97e6f1a229553d7a25dc437741326772e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 10 May 2023 13:08:35 -0500 Subject: Bankruptcy 10 --- basics.el | 680 -------------------------------------------------------------- 1 file changed, 680 deletions(-) delete mode 100644 basics.el (limited to 'basics.el') diff --git a/basics.el b/basics.el deleted file mode 100644 index 1405c84..0000000 --- a/basics.el +++ /dev/null @@ -1,680 +0,0 @@ -;;; basics.el --- Super basic Emacs settings -*- lexical-binding: t -*- - -;;; Commentary: - -;; These are the settings that I literally cannot live without. Basic -;; settings, built-in packages, that kind of stuff. Everything else -;; goes in init.el. - -;;; Code: - -(push (locate-user-emacs-file "lisp/") load-path) -(require 'acdw) - -;;; Directories - -(defdir etc/ (locate-user-emacs-file "etc/") - "Where various Emacs files are placed." - :makedir) - -(defdir sync/ "~/sync/" - "My Syncthing directory." - :makedir) - -(defdir private/ (sync/ "emacs/private/") - "Private files and stuff." - :makedir) - -(use-package no-littering - :ensure t :demand t - :preface - (setq-default no-littering-etc-directory etc/ - no-littering-var-directory etc/)) - - -;;; Settings - -;; Async -(setq-default async-shell-command-buffer 'new-buffer - 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) -(scroll-bar-mode -1) -(horizontal-scroll-bar-mode -1) - -;; Cursor -(setq-default cursor-in-non-selected-windows 'hollow - cursor-type 'bar - blink-cursor-blinks 1 - blink-cursor-interval 0.25 - blink-cursor-delay 0.25) -(blink-cursor-mode) - -;; Mouse -(setq-default mouse-drag-copy-region t - mouse-wheel-progressive-speed nil - mouse-yank-at-point t) - -;; Dialogs -(unless (boundp 'use-short-answers) - (fset 'yes-or-no-p 'y-or-n-p)) - -(setq-default read-answer-short t - use-dialog-box nil - use-file-dialog nil - use-short-answers t) - -;; Minibuffer -(setq-default completion-ignore-case t - read-buffer-completion-ignore-case t - read-file-name-completion-ignore-case t - completions-detailed t - enable-recursive-minibuffers t - file-name-shadow-properties '(invisible t intangible t) - minibuffer-eldef-shorten-default t - minibuffer-prompt-properties '( read-only t - cursor-intangible t - face minibuffer-prompt)) -(file-name-shadow-mode) -(minibuffer-electric-default-mode) - -(define-minor-mode truncate-lines-local-mode - "Truncate lines locally in a buffer." - :lighter " ..." - :group 'display - (setq-local truncate-lines truncate-lines-local-mode)) - -(add-hook 'minibuffer-setup-hook #'truncate-lines-local-mode) - -(require 'savehist) -(setq-default history-length 1024 - history-delete-duplicates t - ;; savehist-file (etc/ "savehist.el") - savehist-save-minibuffer-history t - savehist-autosave-interval 30) -(savehist-mode) - -;; Killing and yanking -(setq-default kill-do-not-save-duplicates t - kill-read-only-ok t - ;; XXX: This setting causes an error message the first time it's - ;; called: "Selection owner couldn't convert: TIMESTAMP". I have - ;; absolutely no idea why I get this error, but it's generated in - ;; `x_get_foreign_selection'. I also can't inhibit the message or - ;; do anything else with it, so for now, I'll just live with the - ;; message. - save-interprogram-paste-before-kill t - yank-pop-change-selection t) -(delete-selection-mode) - -;; Notifying the user -(setq-default echo-keystrokes 0.01 - ring-bell-function #'ignore) - -;; Point and mark -(setq-default set-mark-command-repeat-pop t) - -;; The system -(setq-default read-process-output-max (* 10 1024 1024)) - -;; Startup -(setq-default inhibit-startup-screen t - initial-buffer-choice t - initial-scratch-message nil) - -(define-advice startup-echo-area-message (:override ()) - (if (get-buffer "*Warnings*") - ";_;" - "^_^")) - -(menu-bar-mode -1) -(tool-bar-mode -1) -(tooltip-mode -1) - -;; Text editing -(setq-default fill-column 80 - sentence-end-double-space nil - tab-width 8 - tab-always-indent 'complete) -(global-so-long-mode) - -(setq-default show-paren-delay 0.01 - show-paren-style 'parenthesis - show-paren-when-point-in-periphery t - show-paren-when-point-inside-paren t) -(show-paren-mode) -(electric-pair-mode) - -;; Encodings -(set-language-environment "UTF-8") -(setq-default buffer-file-coding-system 'utf-8-unix - coding-system-for-read 'utf-8-unix - coding-system-for-write 'utf-8-unix - default-process-coding-system '(utf-8-unix . utf-8-unix) - locale-coding-system 'utf-8-unix) -(set-charset-priority 'unicode) -(prefer-coding-system 'utf-8-unix) -(set-default-coding-systems 'utf-8-unix) -(set-terminal-coding-system 'utf-8-unix) -(set-keyboard-coding-system 'utf-8-unix) -(pcase system-type - ((or 'ms-dos 'windows-nt) - (set-clipboard-coding-system 'utf-16-le) - (set-selection-coding-system 'utf-16-le)) - (_ - (set-selection-coding-system 'utf-8) - (set-clipboard-coding-system 'utf-8))) - -;; Abbrev -(setq-default abbrev-file-name (sync/ "abbrev.el") - save-abbrevs 'silently) - -;; Files -(setq-default auto-revert-verbose nil - global-auto-revert-non-file-buffers t - create-lockfiles nil - find-file-visit-truename t - mode-require-final-newline t - view-read-only t - save-silently t) -(global-auto-revert-mode) - -(setq-default auto-save-default nil - auto-save-interval 1 - auto-save-no-message t - auto-save-timeout 1 - auto-save-visited-interval 1 - remote-file-name-inhibit-auto-save-visited t) -(add-to-list 'auto-save-file-name-transforms - `(".*" ,(etc/ "auto-save/" t) t)) -(auto-save-visited-mode) - -(setq-default backup-by-copying t - version-control t - kept-new-versions 8 - kept-old-versions 8 - delete-old-versions t - backup-directory-alist - `(("^/dev/shm" . nil) - ("^/tmp" . nil) - (,(getenv "XDG_RUNTIME_DIR") . nil) - ("." . ,(no-littering-expand-etc-file-name "backup")))) - -(require 'recentf) -(setq-default ;; recentf-save-file (etc/ "recentf" t) - recentf-max-menu-items 500 - recentf-max-saved-items nil ; Save the whole list - recentf-auto-cleanup 'mode - recentf-case-fold-search t) -(add-to-list 'recentf-exclude etc/) -(add-to-list 'recentf-exclude "-autoloads.el\\'") -(add-hook 'buffer-list-update-hook #'recentf-track-opened-file) -(add-hook 'after-save-hook #'recentf-save-list) -(recentf-mode) - -(require 'saveplace) -(setq-default ;; save-place-file (etc/ "places.el") - save-place-forget-unreadable-files (eq system-type - 'gnu/linux)) -(save-place-mode) - -(require 'uniquify) -(setq uniquify-after-kill-buffer-p t - uniquify-buffer-name-style 'forward - uniquify-ignore-buffers-re "^\\*" - uniquify-separator path-separator) - -(setq-local vc-follow-symlinks t - vc-make-backup-files t) - -;; Whitespace -(require 'whitespace) -(setq-default whitespace-style - '(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 - native-comp-deferred-compilation t - native-compile-target-directory (etc/ "eln" t)) -(when (boundp 'native-comp-eln-load-path) - (add-to-list 'native-comp-eln-load-path native-compile-target-directory)) -(when (fboundp 'startup-redirect-eln-cache) - (startup-redirect-eln-cache native-compile-target-directory)) - -;; Custom file -(setq-default custom-file (private/ "custom.el")) -(define-advice package--save-selected-packages - (:around (orig &rest args) no-custom) - "Don't save `package-selected-packages' to `custom-file'." - (let ((custom-file (expand-file-name "custom.el" - temporary-file-directory))) - (apply orig args))) - -;; Goto Address -(if (fboundp 'global-goto-address-mode) - (global-goto-address-mode) - (add-hook 'after-change-major-mode-hook #'goto-address-mode)) - -;; Winner -(winner-mode) - - -;;; Keybindings - -(defun other-window|switch-buffer (arg) - "Call `other-window' or `switch-buffer' depending on windows. -When called with prefix ARG, unconditionally switch buffer." - (interactive "P") - (if (or arg (one-window-p)) - (switch-to-buffer (other-buffer) nil t) - (other-window 1))) - -(defun delete-window|bury-buffer () - "Delete the current window, or bury the current buffer. -If the current window is the only window, bury the buffer." - (interactive) - (condition-case e - (delete-window) - (t (bury-buffer)))) - -(defun +cycle-spacing (&optional n) - ;; `cycle-spacing' is wildly different in 29.1 over 28. - "Negate N argument on `cycle-spacing'. -That is, with a positive N, deletes newlines as well, leaving -N -spaces. If N is negative, it will not delete newlines and leave -N spaces." - (interactive "*p") - (cycle-spacing (- n))) - -(defun +comment-dwim (&optional prefix) - "Comments or uncomments current line or region. -When called with PREFIX, start a comment at the end of the -current line." - (interactive "P") - (if prefix - (comment-indent) - (apply #'comment-or-uncomment-region - (if (region-active-p) - (list (region-beginning) - (region-end)) - (list (line-beginning-position) - (line-end-position)))))) - -(defun +kill-buffer (&optional buffer-or-name) - "Kill the current buffer, or BUFFER-OR-NAME. -When called interactively, prompt the user when given a prefix -argument." - (interactive "P") - (cond - ((bufferp buffer-or-name) - (kill-buffer buffer-or-name)) - ((null buffer-or-name) - (kill-current-buffer)) - (:else - (kill-buffer (read-buffer "Kill: " nil :require-match))))) - -(defun +backward-kill-word (arg) - "Kill ARG words backward unless at the beginning of a line. -When at the beginning of a line, delete blank lines before point." - (interactive "p") - (cond - ((bolp) - ;; This is the first bit of `delete-blank-lines'. -- acdw - (let (thisblank singleblank) - (save-excursion - (beginning-of-line) - (setq thisblank (looking-at "[ \t]*$")) - ;; Set singleblank if there is just one blank line here. - (setq singleblank - (and thisblank - (not (looking-at "[ \t]*\n[ \t]*$")) - (or (bobp) - (progn (forward-line -1) - (not (looking-at "[ \t]*$"))))))) - ;; Delete preceding blank lines, and this one too if it's the only one. - (if thisblank - (progn - (beginning-of-line) - (if singleblank (forward-line 1)) - (delete-region (point) - (if (re-search-backward "[^ \t\n]" nil t) - (progn (forward-line 1) (point)) - (point-min))))) - (if (or (not thisblank) - singleblank) - (progn - (beginning-of-line) - (backward-delete-char 1))))) - (:else - (backward-kill-word arg)))) - -(global-set-key [remap eval-expression] #'pp-eval-expression) -(global-set-key (kbd "M-o") #'other-window|switch-buffer) -(global-set-key [remap delete-window] #'delete-window|bury-buffer) -(global-set-key [remap cycle-spacing] #'+cycle-spacing) -(global-set-key (kbd "C-x C-k") #'+kill-buffer) -(global-set-key [remap comment-dwim] #'+comment-dwim) -(global-set-key [remap undo] #'undo-only) -(global-set-key [remap backward-kill-word] #'+backward-kill-word) - -(global-set-key [f10] #'tmm-menubar) -(advice-add 'tmm-add-prompt :after 'minibuffer-hide-completions) - -(when (fboundp '+lisp-comment-or-uncomment-sexp) - (define-key lisp-mode-map (kbd "C-M-;") #'+lisp-comment-or-uncomment-sexp) - (define-key emacs-lisp-mode-map (kbd "C-M-;") - #'+lisp-comment-or-uncomment-sexp) - (with-eval-after-load 'scheme - (define-key scheme-mode-map (kbd "C-M-;") - #'+lisp-comment-or-uncomment-sexp))) - -(define-key emacs-lisp-mode-map (kbd "C-c C-c") - #'eval-defun) -(define-key emacs-lisp-mode-map (kbd "C-c C-k") - #'elisp-eval-region-or-buffer) -(define-key lisp-interaction-mode-map (kbd "C-c C-c") - #'eval-defun) -(define-key lisp-interaction-mode-map (kbd "C-c C-k") - #'elisp-eval-region-or-buffer) -(define-advice eval-region (:around (orig start end &rest args) pulse) - (apply orig start end args) - (pulse-momentary-highlight-region start end)) - -(global-set-key (kbd "C-x C-b") #'ibuffer) - - -;;; Hooks - -(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) - -(add-hook 'find-file-not-found-functions - (defun create-missing-directories () - "Automatically create missing directories." - (let ((target-dir (file-name-directory buffer-file-name))) - (unless (file-exists-p target-dir) - (make-directory target-dir :parents))))) - -(add-hook 'find-file-hook - (defun vc-remote-off () - "Turn VC off when remote." - (when (file-remote-p (buffer-file-name)) - (setq-local vc-handled-backends nil)))) - - -;;; Advice - -(define-advice switch-to-buffer (:after (&rest _) normal-mode) - "Automatically determine the mode for non-file buffers." - (when-let ((_ (and (eq major-mode 'fundamental-mode))) - (buffer-file-name (buffer-name))) - (normal-mode))) - -(define-advice canonically-space-region - (:around (orig &rest args) double-space-sentences) - "Always double-space sentences canonically." - (let ((sentence-end-double-space t)) - (apply orig args))) - - -;;; Packages - -(use-package _acdw - :load-path private/) - -(use-package custom-allowed - :load-path "~/src/custom-allowed.el/" - :config - (add-to-list 'custom-allowed-variables 'safe-local-variable-values) - (add-to-list 'custom-allowed-variables 'ispell-buffer-session-localwords) - (add-to-list 'custom-allowed-variables 'warning-suppress-types) - (add-to-list 'custom-allowed-variables 'calendar-latitude) - (add-to-list 'custom-allowed-variables 'calendar-longitude) - (add-to-list 'custom-allowed-variables 'user-full-name) - (add-to-list 'custom-allowed-variables 'user-mail-address) - :hook - (after-init-hook . custom-allowed-load-custom-file)) - -(use-package sophomore - :load-path "~/src/sophomore.el/" - :config - (sophomore-enable-all) - (sophomore-disable 'view-hello-file - 'describe-gnu-project - 'suspend-frame) - (sophomore-mode)) - -(use-package compat - ;; This shouldn't be necessary, but sadly I believe that it is. - :ensure t) - -(use-package vertico - :ensure t :demand t - :config - (setq vertico-cycle t) - (add-hook 'vertico-mode-hook - (defun vertico-mode@fix-completions () - (setq completion-in-region-function - (if vertico-mode - #'consult-completion-in-region - #'completion--in-region)))) - (vertico-mode)) - -(use-package vertico-directory - :after vertico - :bind (:map vertico-map - ("C-" . vertico-directory-delete-word)) - :hook (rfn-shadow-update-overlay-hook . vertico-directory-tidy)) - -(use-package vertico-mouse - :after vertico - :config (vertico-mouse-mode)) - -;; Example configuration for Consult -(use-package consult - :ensure t - ;; Replace bindings. Lazily loaded due by `use-package'. - :bind (;; C-c bindings (mode-specific-map) - ("C-c h" . consult-history) - ("C-c m" . consult-mode-command) - ("C-c k" . consult-kmacro) - ;; C-x bindings (ctl-x-map) - ("C-x M-:" . consult-complex-command) - ("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) - ;; Custom M-# bindings for fast register access - ("M-#" . consult-register-load) - ("M-'" . consult-register-store) - ("C-M-#" . consult-register) - ;; Other custom bindings - ("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 m" . consult-mark) - ("M-g k" . consult-global-mark) - ("M-g i" . consult-imenu) - ("M-g I" . consult-imenu-multi) - ;; M-s bindings (search-map) - ("M-s d" . consult-find) - ("M-s D" . consult-locate) - ("M-s g" . consult-grep) - ("M-s G" . consult-git-grep) - ("M-s r" . consult-ripgrep) - ("M-s l" . consult-line) - ("M-s L" . consult-line-multi) - ("M-s k" . consult-keep-lines) - ("M-s u" . consult-focus-lines) - ;; 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) - ;; Minibuffer history - :map minibuffer-local-map - ("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. - :hook (completion-list-mode . consult-preview-at-point-mode) - - ;; The :init configuration is always executed (Not lazy) - :init - - ;; Optionally configure the register formatting. This improves the register - ;; preview for `consult-register', `consult-register-load', - ;; `consult-register-store' and the Emacs built-ins. - (setq register-preview-delay 0.5 - register-preview-function #'consult-register-format) - - ;; Optionally tweak the register preview window. - ;; This adds thin lines, sorting and hides the mode line of the window. - (advice-add #'register-preview :override #'consult-register-window) - - (define-advice completing-read-multiple (:filter-args (args) indicator) - (cons (format "[CRM%s] %s" - (replace-regexp-in-string - "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" - crm-separator) - (car args)) - (cdr args))) - - ;; Use Consult to select xref locations with preview - (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref) - - (setq completion-in-region-function #'consult-completion-in-region) - - ;; Configure other variables and modes in the :config section, - ;; after lazily loading the package. - :config - - ;; Optionally configure preview. The default value - ;; is 'any, such that any key triggers the preview. - ;; (setq consult-preview-key 'any) - ;; (setq consult-preview-key (kbd "M-.")) - ;; (setq consult-preview-key (list (kbd "") (kbd ""))) - ;; For some commands and buffer sources it is useful to configure the - ;; :preview-key on a per-command basis using the `consult-customize' macro. - (consult-customize - consult-theme :preview-key '(:debounce 0.2 any) - consult-ripgrep consult-git-grep consult-grep - consult-bookmark consult-recent-file consult-xref - consult--source-bookmark consult--source-file-register - consult--source-recent-file consult--source-project-recent-file - ;; :preview-key (kbd "M-.") - :preview-key '(:debounce 0.4 any)) - - ;; (consult-customize consult-line - ;; consult-ripgrep - ;; :initial (when (use-region-p) - ;; (buffer-substring-no-properties - ;; (region-beginning) (region-end)))) - - ;; Optionally configure the narrowing key. - ;; Both < and C-+ work reasonably well. - (setq consult-narrow-key "<") ;; (kbd "C-+") - - ;; Optionally make narrowing help available in the minibuffer. - ;; You may want to use `embark-prefix-help-command' or which-key instead. - (define-key consult-narrow-map (vconcat consult-narrow-key "?") - #'consult-narrow-help)) - -(use-package orderless - :ensure t :demand t - :init - (setq completion-styles '(orderless substring basic) - completion-category-defaults nil - completion-category-overrides - '((file (styles basic partial-completion orderless))))) - -(use-package marginalia - :ensure t :demand t - :config - (marginalia-mode)) - -(use-package embark - :ensure t - :bind - (("C-." . embark-act) - ("M-." . embark-dwim) - ("C-h B" . embark-bindings)) - :init - (setq prefix-help-command #'embark-prefix-help-command) - :config - (add-to-list 'display-buffer-alist - '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" - nil - (window-parameters (mode-line-format . none))))) - -(use-package embark-consult - :ensure t - :hook - (embark-collect-mode . consult-preview-at-point-mode)) - -(use-package undo-fu - :ensure t - :init - (setq undo-limit 67108864) ; 64mb. - (setq undo-strong-limit 100663296) ; 96mb. - (setq undo-outer-limit 1006632960) ; 960mb. - :bind (("C-/" . undo-fu-only-undo) - ("C-?" . undo-fu-only-redo))) - -(use-package undo-fu-session - :ensure t - :config - (setq undo-fu-session-compression (cond - ((executable-find "gunzip") 'gz) - ((executable-find "bzip2") 'bz2)) - undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" - "/git-rebase-todo\\'")) - (global-undo-fu-session-mode)) - -(use-package crux - :ensure t :demand t - :bind (("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 - (when (fboundp 'pixel-scroll-precision-mode) - (pixel-scroll-precision-mode))) - -;;; basics.el ends here -- cgit 1.4.1-21-gabe81