From cd3cc4f4e764c25dac453cf2c95a844726e7d19d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 5 Dec 2021 22:37:11 -0600 Subject: Rename +defaults to +emacs --- lisp/+defaults.el | 243 ------------------------------------------------------ lisp/+emacs.el | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 243 deletions(-) delete mode 100644 lisp/+defaults.el create mode 100644 lisp/+emacs.el (limited to 'lisp') diff --git a/lisp/+defaults.el b/lisp/+defaults.el deleted file mode 100644 index d439d82..0000000 --- a/lisp/+defaults.el +++ /dev/null @@ -1,243 +0,0 @@ -;;; +defaults.el --- measured defaults for Emacs -*- lexical-binding: t -*- - -;;; Commentary: - -;; I find myself copy-pasting a lot of "boilerplate" type code when -;; bankrupting my Emacs config and starting afresh. Instead of doing -;; that, I'm putting it here, where it'll be easier to include in my -;; config. - -;; Of course, some might say I could just ... stop bankrupting my -;; Emacs. But like, why would I want to? - -;; Other notable packages include -;; https://git.sr.ht/~technomancy/better-defaults/ - -;;; Code: - -(require 'early-init (locate-user-emacs-file "early-init.el")) - -(defun +set-major-mode-from-buffer-name (&optional buf) - "Set the major mode for BUF from the buffer's name. -Do this only if the buffer is not visiting a file." - (unless buffer-file-name - (let ((buffer-file-name (buffer-name buf))) - (set-auto-mode)))) - -;;; General settings - -(setq-default - apropos-do-all t - async-shell-command-buffer 'new-buffer - async-shell-command-display-buffer nil - auto-hscroll-mode 'current-line - auto-revert-verbose nil - auto-save-file-name-transforms `((".*" ,(.etc "auto-save/" t) t)) - auto-save-interval 60 - auto-save-list-file-prefix (.etc "auto-save/.saves-" t) - auto-save-timeout 60 - auto-save-visited-interval 60 - auto-window-vscroll nil - backup-by-copying t - backup-directory-alist `((".*" . ,(.etc "backup/" t))) - blink-cursor-blinks 1 - completion-category-defaults nil - completion-category-overrides '((file (styles . (partial-completion)))) - completion-ignore-case t - completion-styles '(substring partial-completion) - cursor-in-non-selected-windows 'hollow - cursor-type 'bar - custom-file (.etc "custom.el") - delete-old-versions t - echo-keystrokes 0.1 - ediff-window-setup-function 'ediff-setup-windows-plain - eldoc-echo-area-use-multiline-p nil - eldoc-idle-delay 0.1 - enable-recursive-minibuffers t - executable-prefix-env t - fast-but-imprecise-scrolling t - file-name-shadow-properties '(invisible t intangible t) - frame-resize-pixelwise t - global-auto-revert-non-file-buffers t - global-mark-ring-max 100 - hscroll-step 1 - imenu-auto-rescan t - indent-tabs-mode nil - inhibit-startup-screen t - initial-buffer-choice t - kill-do-not-save-duplicates t - kill-read-only-ok t - kill-ring-max 500 - kill-whole-line t - kmacro-ring-max 20 - load-prefer-newer t - major-mode '+set-major-mode-from-buffer-name - mark-ring-max 50 - minibuffer-eldef-shorten-default t - minibuffer-prompt-properties (list 'read-only t - 'cursor-intangible t - 'face 'minibuffer-prompt) - mode-require-final-newline 'visit-save - mouse-drag-copy-region t - mouse-yank-at-point t - native-comp-async-report-warnings-errors 'silent - read-answer-short t - read-buffer-completion-ignore-case t - read-extended-command-predicate (when (fboundp - 'command-completion-default-include-p) - 'command-completion-default-include-p) - recenter-positions '(top middle bottom) - regexp-search-ring-max 100 - regexp-search-ring-max 200 - save-interprogram-paste-before-kill t - scroll-conservatively 101 - scroll-preserve-screen-position 1 - scroll-step 1 - search-ring-max 200 - search-ring-max 200 - sentence-end-double-space t - set-mark-command-repeat-pop t - show-paren-delay 0 - show-paren-style 'mixed - show-paren-when-point-in-periphery t - show-paren-when-point-inside-paren t - tramp-backup-directory-alist backup-directory-alist - use-dialog-box nil - use-file-dialog nil - use-short-answers t - vc-follow-symlinks t - vc-make-backup-files t - version-control t - view-read-only t - visible-bell nil - window-resize-pixelwise t - x-select-enable-clipboard t - x-select-enable-primary t - yank-pop-change-selection t - ) - -(when (version< emacs-version "28") - (fset 'yes-or-no-p 'y-or-n-p)) - -;; Encoding -- UTF-8 everywhere -(setq-default locale-coding-system 'utf-8-unix - coding-system-for-read 'utf-8-unix - coding-system-for-write 'utf-8-unix - buffer-file-coding-system 'utf-8-unix - default-process-coding-system '(utf-8-unix . utf-8-unix) - x-select-request-type '(UTF8_STRING - COMPOUND_TEXT - TEXT - STRING)) - -(set-charset-priority 'unicode) -(set-language-environment "UTF-8") -(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))) - -;;; Modes - -(dolist (enable-mode '(global-auto-revert-mode - blink-cursor-mode - electric-pair-mode - show-paren-mode - global-so-long-mode - minibuffer-depth-indicate-mode - file-name-shadow-mode - minibuffer-electric-default-mode - delete-selection-mode - column-number-mode)) - (when (fboundp enable-mode) - (funcall enable-mode +1))) - -(dolist (disable-mode '(tooltip-mode - tool-bar-mode - menu-bar-mode - scroll-bar-mode - horizontal-scroll-bar-mode)) - (when (fboundp disable-mode) - (funcall disable-mode -1))) - -;;; Hooks - -(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) -(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) - -;;; Bindings - -(global-set-key (kbd "M-/") 'hippie-expand) -(global-set-key (kbd "M-=") 'count-words) -(global-set-key (kbd "C-x C-b") 'ibuffer) -(global-set-key (kbd "C-s") 'isearch-forward-regexp) -(global-set-key (kbd "C-r") 'isearch-backward-regexp) -(global-set-key (kbd "C-M-s") 'isearch-forward) -(global-set-key (kbd "C-M-r") 'isearch-backward) - -;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults -(global-set-key (kbd "C-h") 'delete-backward-char) -(keyboard-translate ?\C-h ?\C-?) - -;;; Required libraries - -(when (require 'uniquify nil :noerror) - (setq-default uniquify-buffer-name-style 'forward - uniquify-separator path-separator - uniquify-after-kill-buffer-p t - uniquify-ignore-buffers-re "^\\*")) - -(when (require 'goto-addr) - (if (fboundp 'global-goto-address-mode) - (global-goto-address-mode +1) - (add-hook 'after-change-major-mode-hook 'goto-address-mode))) - -(when (require 'recentf nil :noerror) - (setq-default recentf-save-file (.etc "recentf.el") - recentf-max-menu-items 100 - recentf-max-saved-items nil - recentf-auto-cleanup 'mode) - (add-to-list 'recentf-exclude .etc) - (recentf-mode +1)) - -(when (require 'repeat nil :noerror) - (setq-default repeat-exit-key "g" - repeat-exit-timeout 5) - (repeat-mode +1)) - -(when (require 'savehist nil :noerror) - (setq-default history-length t - history-delete-duplicates t - history-autosave-interval 60 - savehist-file (.etc "savehist.el")) - (dolist (var '(extended-command-history - global-mark-ring - kill-ring - regexp-search-ring - search-ring - mark-ring)) - (add-to-list 'savehist-additional-variables var)) - (savehist-mode +1)) - -(when (require 'saveplace nil :noerror) - (setq-default save-place-file (.etc "places.el") - save-place-forget-unreadable-files (eq system-type 'gnu/linux)) - (save-place-mode +1)) - -(when (require 'tramp) - ;; thanks Irreal! https://irreal.org/blog/?p=895 - (add-to-list 'tramp-default-proxies-alist - '(nil "\\`root\\'" "/ssh:%h:")) - (add-to-list 'tramp-default-proxies-alist - '((regexp-quote (system-name)) nil nil))) - -(provide '+defaults) -;;; +defaults.el ends here diff --git a/lisp/+emacs.el b/lisp/+emacs.el new file mode 100644 index 0000000..7440c92 --- /dev/null +++ b/lisp/+emacs.el @@ -0,0 +1,242 @@ +;;; +emacs.el --- measured defaults for Emacs -*- lexical-binding: t -*- + +;;; Commentary: + +;; I find myself copy-pasting a lot of "boilerplate" type code when +;; bankrupting my Emacs config and starting afresh. Instead of doing +;; that, I'm putting it here, where it'll be easier to include in my +;; config. + +;; Of course, some might say I could just ... stop bankrupting my +;; Emacs. But like, why would I want to? + +;; Other notable packages include +;; https://git.sr.ht/~technomancy/better-defaults/ + +;;; Code: + +(require 'early-init (locate-user-emacs-file "early-init.el")) + +(defun +set-major-mode-from-buffer-name (&optional buf) + "Set the major mode for BUF from the buffer's name. +Do this only if the buffer is not visiting a file." + (unless buffer-file-name + (let ((buffer-file-name (buffer-name buf))) + (set-auto-mode)))) + +;;; General settings + +(setq-default + apropos-do-all t + async-shell-command-buffer 'new-buffer + async-shell-command-display-buffer nil + auto-hscroll-mode 'current-line + auto-revert-verbose nil + auto-save-file-name-transforms `((".*" ,(.etc "auto-save/" t) t)) + auto-save-interval 60 + auto-save-list-file-prefix (.etc "auto-save/.saves-" t) + auto-save-timeout 60 + auto-save-visited-interval 60 + auto-window-vscroll nil + backup-by-copying t + backup-directory-alist `((".*" . ,(.etc "backup/" t))) + blink-cursor-blinks 1 + completion-category-defaults nil + completion-category-overrides '((file (styles . (partial-completion)))) + completion-ignore-case t + completion-styles '(substring partial-completion) + cursor-in-non-selected-windows 'hollow + cursor-type 'bar + custom-file (.etc "custom.el") + delete-old-versions t + echo-keystrokes 0.1 + ediff-window-setup-function 'ediff-setup-windows-plain + eldoc-echo-area-use-multiline-p nil + eldoc-idle-delay 0.1 + enable-recursive-minibuffers t + executable-prefix-env t + fast-but-imprecise-scrolling t + file-name-shadow-properties '(invisible t intangible t) + frame-resize-pixelwise t + global-auto-revert-non-file-buffers t + global-mark-ring-max 100 + hscroll-step 1 + imenu-auto-rescan t + indent-tabs-mode nil + inhibit-startup-screen t + initial-buffer-choice t + kill-do-not-save-duplicates t + kill-read-only-ok t + kill-ring-max 500 + kill-whole-line t + kmacro-ring-max 20 + load-prefer-newer t + major-mode '+set-major-mode-from-buffer-name + mark-ring-max 50 + minibuffer-eldef-shorten-default t + minibuffer-prompt-properties (list 'read-only t + 'cursor-intangible t + 'face 'minibuffer-prompt) + mode-require-final-newline 'visit-save + mouse-drag-copy-region t + mouse-yank-at-point t + native-comp-async-report-warnings-errors 'silent + read-answer-short t + read-buffer-completion-ignore-case t + read-extended-command-predicate (when (fboundp + 'command-completion-default-include-p) + 'command-completion-default-include-p) + recenter-positions '(top middle bottom) + regexp-search-ring-max 100 + regexp-search-ring-max 200 + save-interprogram-paste-before-kill t + scroll-conservatively 101 + scroll-preserve-screen-position 1 + scroll-step 1 + search-ring-max 200 + search-ring-max 200 + sentence-end-double-space t + set-mark-command-repeat-pop t + show-paren-delay 0 + show-paren-style 'mixed + show-paren-when-point-in-periphery t + show-paren-when-point-inside-paren t + tramp-backup-directory-alist backup-directory-alist + use-dialog-box nil + use-file-dialog nil + use-short-answers t + vc-follow-symlinks t + vc-make-backup-files t + version-control t + view-read-only t + visible-bell nil + window-resize-pixelwise t + x-select-enable-clipboard t + x-select-enable-primary t + yank-pop-change-selection t + ) + +(when (version< emacs-version "28") + (fset 'yes-or-no-p 'y-or-n-p)) + +;; Encoding -- UTF-8 everywhere +(setq-default locale-coding-system 'utf-8-unix + coding-system-for-read 'utf-8-unix + coding-system-for-write 'utf-8-unix + buffer-file-coding-system 'utf-8-unix + default-process-coding-system '(utf-8-unix . utf-8-unix) + x-select-request-type '(UTF8_STRING + COMPOUND_TEXT + TEXT + STRING)) + +(set-charset-priority 'unicode) +(set-language-environment "UTF-8") +(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))) + +;;; Modes + +(dolist (enable-mode '(global-auto-revert-mode + blink-cursor-mode + electric-pair-mode + show-paren-mode + global-so-long-mode + minibuffer-depth-indicate-mode + file-name-shadow-mode + minibuffer-electric-default-mode + delete-selection-mode + column-number-mode)) + (when (fboundp enable-mode) + (funcall enable-mode +1))) + +(dolist (disable-mode '(tooltip-mode + tool-bar-mode + menu-bar-mode + scroll-bar-mode + horizontal-scroll-bar-mode)) + (when (fboundp disable-mode) + (funcall disable-mode -1))) + +;;; Hooks + +(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) +(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) + +;;; Bindings + +(global-set-key (kbd "M-/") 'hippie-expand) +(global-set-key (kbd "M-=") 'count-words) +(global-set-key (kbd "C-x C-b") 'ibuffer) +(global-set-key (kbd "C-s") 'isearch-forward-regexp) +(global-set-key (kbd "C-r") 'isearch-backward-regexp) +(global-set-key (kbd "C-M-s") 'isearch-forward) +(global-set-key (kbd "C-M-r") 'isearch-backward) +(global-set-key (kbd "M-u") 'upcase-dwim) +(global-set-key (kbd "M-l") 'downcase-dwim) +(global-set-key (kbd "M-c") 'capitalize-dwim) + +;;; Required libraries + +(when (require 'uniquify nil :noerror) + (setq-default uniquify-buffer-name-style 'forward + uniquify-separator path-separator + uniquify-after-kill-buffer-p t + uniquify-ignore-buffers-re "^\\*")) + +(when (require 'goto-addr) + (if (fboundp 'global-goto-address-mode) + (global-goto-address-mode +1) + (add-hook 'after-change-major-mode-hook 'goto-address-mode))) + +(when (require 'recentf nil :noerror) + (setq-default recentf-save-file (.etc "recentf.el") + recentf-max-menu-items 100 + recentf-max-saved-items nil + recentf-auto-cleanup 'mode) + (add-to-list 'recentf-exclude .etc) + (recentf-mode +1)) + +(when (require 'repeat nil :noerror) + (setq-default repeat-exit-key "g" + repeat-exit-timeout 5) + (repeat-mode +1)) + +(when (require 'savehist nil :noerror) + (setq-default history-length t + history-delete-duplicates t + history-autosave-interval 60 + savehist-file (.etc "savehist.el")) + (dolist (var '(extended-command-history + global-mark-ring + kill-ring + regexp-search-ring + search-ring + mark-ring)) + (add-to-list 'savehist-additional-variables var)) + (savehist-mode +1)) + +(when (require 'saveplace nil :noerror) + (setq-default save-place-file (.etc "places.el") + save-place-forget-unreadable-files (eq system-type 'gnu/linux)) + (save-place-mode +1)) + +(when (require 'tramp) + ;; thanks Irreal! https://irreal.org/blog/?p=895 + (add-to-list 'tramp-default-proxies-alist + '(nil "\\`root\\'" "/ssh:%h:")) + (add-to-list 'tramp-default-proxies-alist + '((regexp-quote (system-name)) nil nil))) + +(provide '+emacs) +;;; +emacs.el ends here -- cgit 1.4.1-21-gabe81