My emacs configuration written in literate style using org-mode.
Melpa is the big package repo that nearly everything can be found. It’s a must for emacs configs.
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))(use-package better-defaults
:ensure t)Remove splash screen and use scratch instead as the home buffer
(setq inhibit-startup-message t
inhibit-startup-echo-area-message t)Increase the garbage-collection threshold.
(setq gc-cons-threshold 100000000)
(setq max-specpdl-size 5000)The most useful Emacs command is execute-extended-command. It should be painless to access from the home row. (bind-key* ensures that this setting is propagated through all major modes, which saves us a bunch of unbind-key calls in use-package stanzas.) Why not something even easier, like C-;, you ask? Unfortunately, macOS Terminal.app swallows that keybinding and does nothing with it. I’m sure this is correct behavior by some sort of standard, but I have to work around it, since occasionally I do use Emacs in the terminal.
(bind-key* "C-c ;" #'execute-extended-command)
(bind-key* "C-c 4" #'execute-extended-command) ;; for a purely left-handed combo
(bind-key* "C-c C-;" #'execute-extended-command-for-buffer)With this auxiliary package for use-package, we can instruct Emacs that a given package depends on the presence of a system tool. It will even install this tool with the system’s recommended package manager.
(use-package use-package-ensure-system-package)(setq
inhibit-startup-screen t
initial-scratch-message nil
ring-bell-function 'ignore
save-interprogram-paste-before-kill t
use-dialog-box nil
kill-whole-line t
default-directory "~/code/"
load-prefer-newer t
confirm-kill-processes nil
;; unicode ellipses are better
truncate-string-ellipsis "…"
delete-by-moving-to-trash t
)UTF-8 should be the default
(set-charset-priority 'unicode)
(prefer-coding-system 'utf-8-unix)Turn off backups and autosaves.
(setq
make-backup-files nil
auto-save-default nil
create-lockfiles nil
)By default, Emacs stores any configuration you make through its UI by writing custom-set-variables invocations to your init file, or to the file specified by custom-file. Though this is convenient, it’s also an excellent way to cause aggravation when the variable you keep trying to modify is being set in some custom-set-variables invocation. We can disable this by mapping it to a temporary file. (I used to map this to /dev/null, but this started causing a bunch of inane save dialogues.)
(setq custom-file (make-temp-name "/tmp/"))Disable warning about theme safety
(setq custom-safe-themes t)Emacs looks a lot better when it has a modern monospaced font and VSCode-esque icons, as well as smooth scrolling.
(set-face-attribute 'default nil :font "Fira Code-13")
(set-face-attribute 'variable-pitch nil :font "Noto Sans-13")Occupy all the screen space you can.
(add-to-list 'default-frame-alist '(fullscreen . maximized))(use-package magit
:diminish magit-auto-revert-mode
:diminish auto-revert-mode
:bind (("C-c g" . #'magit-status))
:custom
(magit-diff-refine-hunk t)
(magit-repository-directories '(("~/src" . 1)))
(magit-list-refs-sortby "-creatordate")
:config
(defun pt/commit-hook () (set-fill-column 80))
(add-hook 'git-commit-setup-hook #'pt/commit-hook)
(add-to-list 'magit-no-confirm 'stage-all-changes))Integration with github and other code forges.
(use-package forge
:ensure t
:after magit)Use ripgrep via deadgrep.
(use-package deadgrep
:ensure t
:ensure-system-package rg
:bind (("C-c H" . #'deadgrep)))(use-package yasnippet
:ensure t
:defer 15
:config (yas-global-mode)
:custom (yas-prompt-functions '(yas-completing-prompt)))(use-package cider
:ensure t
)
(add-hook 'clojure-mode-hook #'cider-mode)(use-package markdown-mode
:ensure t
:hook (gfm-mode . visual-line-mode)
:bind (:map markdown-mode-map ("C-c C-s a" . markdown-table-align))
:mode ("\\.md$" . gfm-mode)
:init (setq markdown-command "pandoc"))just is a great replacement for make.
(use-package just-mode
:ensure t)(use-package restclient
:ensure t)