This is the literate programming version of my Emacs config. Blocks are tangled into XDG compatible config files in init.el. See Auto-tangle.
(eval buffer-file-name)
(eval (concat (format "Emacs version: %s\n" (emacs-version))
(format "Org version: %s" (org-version))))
;; This file is generated from <<filename()>>
;; <<version_info()>>
(message "Loading %s" (or load-file-name buffer-file-name))
(setq custom-file (locate-user-emacs-file "custom.el"))
(set-face-attribute 'default nil :font "JetBrains Mono:size=14")
(set-face-attribute 'fixed-pitch nil :font (face-attribute 'default :font))
(setq-default line-spacing 0.25)
(require 'cl-lib)
(dolist (elem
'(
(width . 0.9)
(height . 0.95)
(user-position . t)
(left . 0.5)
(top . 0.5)
(ns-transparent-titlebar . t)
(left-fringe . 16)
(right-fringe . 16)
))
(cl-pushnew elem default-frame-alist))
(tool-bar-mode -1)
(scroll-bar-mode -1)
(require 'package)
(with-eval-after-load 'package
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")))
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(use-package emacs
:config
(global-visual-line-mode t))
Automatically revert buffers when file changes on disk.
(global-auto-revert-mode t)
(setq calendar-week-day-start 1)
Some more are implemented where needed, use isearch to see them all.
(use-package modus-themes
:demand
:custom
(modus-themes-to-toggle '(modus-operandi modus-vivendi))
(modus-themes-disable-other-themes t)
(modus-themes-italic-constructs t)
(modus-themes-variable-pitch-ui t)
(modus-themes-mixed-fonts t)
(modus-themes-prompts '(bold))
(modus-themes-org-blocks 'tinted-background)
(modus-themes-headings
'(
(1 . (1.215))
(2 . (1.138))
(3 . (1.076))
(4 . (1.0))
(5 . (0.937))
(agenda-date . (variable-pitch italic 1.138))
(agenda-structure . (variable-pitch light 1.215))
(t . (medium))
))
(modus-themes-common-palette-overrides
'(
(border-mode-line-active bg-mode-line-active)
(border-mode-line-inactive bg-mode-line-inactive)
))
:bind ("<f5>" . modus-themes-toggle)
:config
(let ((last (expand-file-name "selected-theme.el" user-emacs-directory)))
(if (file-exists-p last)
(load last)
(load-theme (car modus-themes-to-toggle) :no-confirm))))
(defun oe/save-selected-theme (theme)
(with-temp-file (expand-file-name "selected-theme.el" user-emacs-directory)
(insert (format "(load-theme '%s :no-confirm)\n" theme))))
(defun oe/rotate-list (list)
(when list
(append (cdr list) (list (car list)))))
(defun oe/cycle-themes (theme-list)
(load-theme (car theme-list) :no-confirm)
(oe/rotate-list theme-list))
(defun oe/cycle-themes-and-print-log-msg ()
(interactive)
(defvar modus-themes--cycle modus-themes-items)
(setq modus-themes--cycle (oe/cycle-themes modus-themes--cycle))
(let ((selected-theme (car (reverse modus-themes--cycle))))
(message "Theme: %s selected" (car (reverse modus-themes--cycle)))
(oe/save-selected-theme selected-theme)))
(global-set-key (kbd "<f4>") #'oe/cycle-themes-and-print-log-msg)
(when (memq window-system '(mac ns))
(if (executable-find "gls")
(setq insert-directory-program "gls")
(message "Please install GNU coreutils via `brew install coreutils`"))
(setq delete-by-moving-to-trash t)
(setq mac-system-move-file-to-trash-use-finder t)
(use-package reveal-in-osx-finder
:commands reveal-in-osx-finder
:bind ("C-c f" . reveal-in-osx-finder))
)
(global-set-key (kbd "A-<left>") #'windmove-left)
(global-set-key (kbd "A-<up>") #'windmove-up)
(global-set-key (kbd "A-<right>") #'windmove-right)
(global-set-key (kbd "A-<down>") #'windmove-down)
(use-package emacs
:custom
(recentf-max-menu-items 25)
(recentf-max-saved-items 25)
:config
(recentf-mode t)
:bind ("C-c r" . #'recentf-open-files))
(use-package delight
:demand)
(use-package dumb-jump
:commands dumb-jump-xref-activate
:init
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
(use-package which-key
:demand
:custom
(which-key-idle-delay 0.3)
:delight
:config
(which-key-mode)
)
(use-package emacs
:custom
(display-line-numbers 'visual)
(display-line-numbers-width 3))
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(use-package adaptive-wrap
:custom
(adaptive-wrap-extra-indent 3)
:hook (text-mode . adaptive-wrap-prefix-mode))
(use-package vertico
:init
(vertico-mode))
(use-package marginalia
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode))
(use-package org
:custom
(org-return-follows-link t)
:commands (org-mode arg-agenda)
:config
(progn
(require 'org-mouse))
)
(with-eval-after-load 'org
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("clang" . "src C :includes '(stdio.h) :flags -std=c90"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++ :includes '(iostream) :flags -std=c++20"))
(add-to-list 'org-structure-template-alist '("sw" . "src swift"))
(add-to-list 'org-structure-template-alist '("swui" . "src swiftui"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
)
(defun oe/org-babel-tangle-config ()
(let ((file-dir (file-name-directory (buffer-file-name))))
(when (or (string-prefix-p (expand-file-name user-emacs-directory) file-dir)
(string-prefix-p (expand-file-name "~/dotfiles/emacs/.config/emacs/") file-dir))
(let ((org-confirm-babel-evaluate nil))
(org-babel-tangle)))))
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'oe/org-babel-tangle-config)))
(message "Done loading: %s" (or load-file-name buffer-file-name))