From 214c7ee964ebd695c62f9484b0df7aeccb5e1351 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 9 Feb 2025 13:47:12 +0100 Subject: [PATCH] Add some fairly basic initial configuration --- .gitignore | 5 +++++ early-init.el | 12 ++++++++++++ init.el | 42 ++++++++++++++++++++++++++++++++++++++++++ key-bindings.el | 14 ++++++++++++++ typography.el | 6 ++++++ 5 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100644 early-init.el create mode 100644 init.el create mode 100644 key-bindings.el create mode 100644 typography.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d41506b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +auto-save-list/ +elpa/ +transient/ + +*~ diff --git a/early-init.el b/early-init.el new file mode 100644 index 0000000..c1fecc1 --- /dev/null +++ b/early-init.el @@ -0,0 +1,12 @@ +;;; early-init.el -*- lexical-binding: t; -*- + +;; Emacs 27.1 introduced early-init.el, which is run before init.el, before +;; package and UI initialization happens, and before site files are loaded. + +;; Minimize garbage collection during startup. +(setq gc-cons-threshold most-positive-fixnum) + +;; Lower threshold back to 8 MiB (default is 800kB) +(add-hook 'emacs-startup-hook + (lambda () + (setq gc-cons-threshold (expt 2 23)))) diff --git a/init.el b/init.el new file mode 100644 index 0000000..318a987 --- /dev/null +++ b/init.el @@ -0,0 +1,42 @@ +;;; init.el --- A (reasonably) minimal initialization file for Emacs. + + +;; Manage package configuration via `use-package`. +;; https://github.com/jwiegley/use-package + +(require 'package) +(setq package-enable-at-startup nil) + +(setq package-archives + '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/") + ("stable" . "https://stable.melpa.org/packages/"))) + +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + + +;; Define a couple simple helper functions for loading user-defined +;; configuration files. + +(defconst user-init-dir "~/.emacs.d/") + +(defun load-user-file (file) + (interactive "f") + "Load a file in the current user's configuration directory" + (load-file (expand-file-name file user-init-dir))) + +(defun load-user-dir (dir) + (interactive "f") + "Recursively load all files in a given directory, relative to the user's + configuration directory" + (setq config-dir (file-name-concat user-init-dir dir)) + (dolist (file (directory-files-recursively config-dir "")) + (load-user-file file))) + + +;; Load all user-defined configuration files: + +(load-user-file "key-bindings.el") +(load-user-file "typography.el") diff --git a/key-bindings.el b/key-bindings.el new file mode 100644 index 0000000..2109d82 --- /dev/null +++ b/key-bindings.el @@ -0,0 +1,14 @@ +;; Globally un-set "C-z", which suspends Emacs by default (and is super +;; annoying!). +(global-unset-key (kbd "C-z")) + +;; Make it easier to move between windows. Windows can be navigated using +;; in combination with the arrow keys. +(setq windmove-wrap-around t) +(windmove-default-keybindings) + +;; Enable code folding in programming modes, and set some more reasonable +;; shortcuts. +(add-hook 'prog-mode-hook #'hs-minor-mode) +(global-set-key (kbd "C-c C-h") (kbd "C-c @ C-h")) ; Hide a block +(global-set-key (kbd "C-c C-s") (kbd "C-c @ C-s")) ; Show a block diff --git a/typography.el b/typography.el new file mode 100644 index 0000000..f5c127b --- /dev/null +++ b/typography.el @@ -0,0 +1,6 @@ +;; Make sure that UTF-8 is *ALWAYS* the default encoding. +(set-charset-priority 'unicode) +(prefer-coding-system 'utf-8-unix) + +;; Prettify symbols (eg. lambda -> λ). +(global-prettify-symbols-mode)