My emacs config

I recently switched my emacs config back to Org mode, because Org is absolutely amazing for literal programming no matter what language you're using.

It's still a work in progress, because I'm not really using use-package all that much at the minute, but it gets the job done.

My objective with this configuration, especially with the release of Emacs 29, is to rely on built-in functionality as much as possible. To that extent, I use eglot in favour of lsp-mode, and I use project.el in favour of projectile. Tree-sitter functionality is baked in now too although I haven't fully switched over to the tree-sitter enabled modes.

Finally, a big one on my todo list is to flesh out eshell with a selection of custom functions. Even though I have vterm installed, the experience of using eshell for my usual day to day is much nicer.

Notably, I barely touch custom keybindings and I don't use evil-mode. I'm just happy with the defaults for the most part but I'm tempted to give hydra another shot.

Emacs config

Configuration grouped roughly by purpose.

Bootstrapping is done in init.el and early-init.el, and then this configuration is included with org-babel-load-file.

Global settings

(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
(setq initial-major-mode 'org-mode)
(setq popup-windows nil)
(setq ring-bell-function 'ignore)
(setq load-prefer-newer t)
(setq site-run-file nil)
(setq x-underline-at-descent-line t)
(setq widget-image-enable nil)
(setq browse-url-browser-function 'browse-url-xdg-open)
(setq window-divider-default-right-width 24)
(setq window-divider-default-places 'right-only)
(setq backup-by-copying t)
(setq confirm-kill-emacs 'yes-or-no-p)
(setq native-comp-speed -1)
(setq native-comp-async-report-warnings-errors nil)
(setq compilation-scroll-output 'first-error)

(setq-default indent-tabs-mode nil)
(setq-default line-spacing 0)

(global-auto-revert-mode t)

(defalias 'yes-or-no-p 'y-or-n-p)

(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse
      uniquify-separator " • "
      uniquify-after-kill-buffer-p t
      uniquify-ignore-buffers-re "^\\*")

(save-place-mode t)


(defvar user-temporary-file-directory
  (concat temporary-file-directory user-login-name "/"))

(make-directory user-temporary-file-directory t)

(setq backup-directory-alist `(("." . ,user-temporary-file-directory)
                               (tramp-file-name-regexp nil)))

(setq auto-save-file-name-transforms `((".*" ,user-temporary-file-directory t)))

(setq auto-save-list-file-prefix
      (concat user-temporary-file-directory ".auto-saves-"))

(setq create-lockfiles nil)

File encoding

(prefer-coding-system       'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment   'utf-8)


(use-package modus-themes)

(setq modus-themes-bold-constructs t)
(setq modus-themes-italic-constructs t)
(setq modus-themes-subtle-line-numbers t)
(setq modus-themes-fringes 'subtle)
(setq modus-themes-variable-pitch-ui t)

(modus-themes-load-theme 'modus-vivendi)

(set-face-font 'default "Rec Mono SemiCasual-16")

(setq default-frame-alist
      (append (list
               '(font . "Rec Mono Casual-14"))))

(set-fontset-font t 'symbol "Noto Color Emoji" nil 'append)

(set-default 'cursor-type '(bar . 1))

(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(show-paren-mode t)
(window-divider-mode 1)


(use-package exec-path-from-shell)

(when (or (memq window-system '(mac ns x))

(when (memq window-system '(mac ns))
  (setq ns-right-alternate-modifier 'none))

(when (not (display-graphic-p))
  (xterm-mouse-mode t))


(use-package selectrum)
(use-package selectrum-prescient)
(use-package marginalia)

(selectrum-mode t)
(selectrum-prescient-mode t)
(prescient-persist-mode t)

(autoload 'ffap-guesser "ffap")
(autoload 'ffap-file-at-point "ffap")

(defun minibuffer-default-add-function+ ()
  (with-selected-window (minibuffer-selected-window)
     (delq nil
           (list (thing-at-point 'symbol)
                 (thing-at-point 'list)

(defun complete-path-at-point+ ()
  (let ((fn (ffap-file-at-point))
        (fap (thing-at-point 'filename)))
    (when (and (or fn
                   (equal "/" fap))
                 (search-backward fap (line-beginning-position) t)))
      (list (match-beginning 0)
            (match-end 0)

(setq minibuffer-default-add-function #'minibuffer-default-add-function+)
(add-hook 'completion-at-point-functions #'complete-path-at-point+ 'append)


(use-package corfu)


(setq completion-cycle-threshold 3)
(setq read-extended-command-predicate #'command-completion-default-include-p)
(setq corfu-auto t)
(setq corfu-quit-no-match 'separator)

Code formatting

(use-package editorconfig)
(editorconfig-mode t)

(use-package apheleia)
(apheleia-global-mode t)


(use-package project)
(use-package tabspaces)
(use-package ripgrep)

(setq project-vc-extra-root-markers '(".prj"))

(setq tabspaces-use-filtered-buffers-as-default t)
(setq tabspaces-remove-to-default nil)
(setq tabspaces-include-buffers '("*scratch*"))

(setq tab-bar-close-button-show nil)
(setq tab-bar-tab-hints t)

(setq xref-search-program 'ripgrep)

(add-to-list 'project-switch-commands '(magit-project-status "Magit" ?m))


Org mode

(setq org-startup-indented nil)
(setq org-image-actual-width (truncate (window-pixel-width)))
(setq org-todo-keywords '((sequence "TODO" "DOING" "|" "DONE")))

(defun enable-visual-line-mode ()
  (visual-line-mode t))

(add-hook 'org-mode-hook #'enable-visual-line-mode)

(use-package outshine)
(add-hook 'emacs-lisp-mode-hook 'outshine-mode)

Version control stuff

(use-package magit)

(setq magit-completing-read-function #'selectrum-completing-read)

(use-package git-link)

;;; Terminal Emulation

(use-package vterm)

Programming languages

Tree Sitter

(require 'treesit)

(setq treesit-language-source-alist
      '((bash . (""))
        (c . (""))
        (cpp . (""))
        (css . (""))
        (elixir . (""))
        (heex . (""))
        (go . (""))
        (html . (""))
        (javascript . (""))
        (json . (""))
        (lua . (""))
        (make . (""))
        (ocaml . ("" "ocaml/src" "ocaml"))
        (python . (""))
        (php . (""))
        (typescript . ("" "typescript/src" "typescript"))
        (ruby . (""))
        (rust . (""))
        (sql . (""))
        (toml . (""))
        (zig . (""))))

(require 'ansi-color)

(defun colorize-compilation-buffer ()
  (ansi-color-apply-on-region compilation-filter-start (point-max)))

(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

Language servers

(require 'eglot)

(fset #'jsonrpc--log-event #'ignore)

Language management

(use-package asdf
  :straight (:type git :host github :repo "tabfugnic/asdf.el"))

(require 'asdf)


Language specific packages

  • Ruby
    (use-package enh-ruby-mode)
    (add-to-list 'auto-mode-alist
                 '("\\(?:\\.rb\\|ru\\|rake\\|thor\\|jbuilder\\|gemspec\\|podspec\\|/\\(?:Gem\\|Rake\\|Cap\\|Thor\\|Vagrant\\|Guard\\|Pod\\)file\\)\\'" . enh-ruby-mode))
    (use-package rubocop)
    (add-hook 'enh-ruby-mode-hook #'rubocop-mode)
    (add-hook 'enh-ruby-mode-hook 'eglot-ensure)
    (use-package bundler)
  • Elixir
    (use-package elixir-mode)
    (use-package exunit)
    (use-package mix)
    (add-to-list 'auto-mode-alist '("\\(?:\\.ex\\|\\.exs\\)" . elixir-mode))
    (add-to-list 'eglot-server-programs '(elixir-mode "~/.local/bin/elixir-ls-0.15.0/"))
    (add-hook 'elixir-mode-hook 'eglot-ensure)
    (add-hook 'elixir-mode-hook 'mix-minor-mode)
  • Markdown
    (use-package markdown-toc)
  • YAML
    (use-package yaml-mode)
  • Web Dev
    (use-package typescript-mode)
    (use-package web-mode)
    (use-package json-mode)
    (add-to-list 'auto-mode-alist '("\\.tsx?\\'" . typescript-mode))
    (add-hook 'typescript-mode-hook 'eglot-ensure)
  • Zig
    (use-package zig-mode)
  • Haskell
    (use-package haskell-mode)
  • Nix
    (use-package nix-mode)
    (add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
  • Rust
    (use-package rustic)
    (setq rustic-format-on-save t)
    (setq rustic-format-trigger 'on-save)
  • Go
    (use-package go-mode)
  • Protobuf
    (use-package protobuf-mode)
    (add-to-list 'auto-mode-alist '("\\.proto?\\'" . protobuf-mode))
  • Smalltalk
    (use-package smalltalk-mode)
  • Devops
    (use-package kubernetes)
    (use-package terraform-mode)
    (use-package dockerfile-mode)
    (add-to-list 'auto-mode-alist '("\\.tf\\'" . terraform-mode))
    (add-to-list 'auto-mode-alist '("\\Dockerfile" . dockerfile-mode))

Reading / Browsing

  • Pocket
    (use-package pocket-reader)

Direnv (always load last)

(use-package envrc)


Custom overrides

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(safe-local-variable-values '((require . "publish.el"))))
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)