What follows is my personal configuration for GNU Emacs, done in the style of literate programming. Literate configurations typically rely on =org-babel= to evaluate the Lisp forms upon starting Emacs, but this configuration takes a different approach: [[./init.el][init.el]] defines a function, =eval-document=, which "tangles" all of the relevant Org source blocks into a temporary buffer and proceeds to invoke =eval-buffer=. The main implication of this is that there won't be a =jakob.el= in the Emacs configuration directory. Also worth noting is that there is no namespace (i.e. =jakob/= or =my-=) for functions defined in this file. I'm happy to use a consistent namespacing for packages I plan to publish on Melpa, but I don't see the point in a configuration file. * Bootstrapping A few of the packages I use require early initialization. ** Package Management I use [[https://github.com/raxod502/straight.el][straight.el]] insetad of =package.el=. #+BEGIN_SRC elisp (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) #+END_SRC =straight.el= does have a known issue with installing Org, and requires a workaround for it early on. The details are outlined [[https://github.com/raxod502/straight.el#installing-org-with-straightel][here]] #+BEGIN_SRC elisp (require 'subr-x) (straight-use-package 'git) (defun org-git-version () "The Git version of org-mode. Inserted by installing org-mode or when a release is made." (require 'git) (let ((git-repo (expand-file-name "straight/repos/org/" user-emacs-directory))) (string-trim (git-run "describe" "--match=release\*" "--abbrev=6" "HEAD")))) (defun org-release () "The release version of org-mode. Inserted by installing org-mode or when a release is made." (require 'git) (let ((git-repo (expand-file-name "straight/repos/org/" user-emacs-directory))) (string-trim (string-remove-prefix "release_" (git-run "describe" "--match=release\*" "--abbrev=0" "HEAD"))))) (provide 'org-version) #+END_SRC As for the actual installation and configuration of packages, I use [[https://github.com/jwiegley/use-package][use-package]]. #+BEGIN_SRC elisp (straight-use-package 'use-package) (setq straight-use-package-by-default t) #+END_SRC =bind-key= is required early on for =use-package='s =:bind= declarations. #+BEGIN_SRC elisp (use-package bind-key :defer t) #+END_SRC ** Dependency Management =use-package= provies a number of features such as =:after= to defer the loading of packages and their configurations until some other package has been loaded, but I've wrestled witth this functionality for weeks now and realized that it's not well-suited for configuring packages in a way that depends on symbols from another package. As an alternative, I've chosen to use the =with-eval-after-load= machinery provided by Vanilla Emacs, albeit wrapped in a slightly more ergnomic macro that allows for dependence on multiple packages rather than just one. #+BEGIN_SRC elisp (defmacro when-all-loaded (files &rest form) "Nests FORM in several `with-eval-after-load' for each of FILES. FILES can be either a symbol, representing dependence on a single package, or a list of symbols, representing dependence on more than one package." (let ((form `(progn ,@form)) (files (if (symbolp files) (list files) files))) (dolist (file files) (setq form `(with-eval-after-load (quote ,file) ,form))) form)) (put 'when-all-loaded 'lisp-indent-function 1) #+END_SRC ** Libraries A handful of the Elisp snippets in this file depend on third-party libraries which aren't loaded by default. #+BEGIN_SRC elisp (require 'cl-lib) (require 'cl-extra) #+END_SRC ** Configuration Bind some keys for working with this configuration file. #+BEGIN_SRC elisp (defun config-goto () "Switch to a buffer visiting the literate config file." (interactive) (find-file "~/.emacs.d/jakob.org")) (defun config-reload () "Evaluate the literate config file." (interactive) (eval-document "~/.emacs.d/jakob.org")) (bind-key "C-c e" #'config-goto) (bind-key "C-c r" #'config-reload) #+END_SRC * Vanilla Emacs Any configuration addressing the core of Emacs rather than a third-party package. ** Startup Having Emacs open to =*scratch*= feels as though it's inviting me to punch out some Lisp forms and evaluate them. I like to pretend that my computers are Lisp machines. #+BEGIN_SRC elisp (setq inhibit-startup-message t inhibit-startup-buffer-menu t initial-scratch-message nil initial-buffer-choice nil) #+END_SRC ** Filesystem A recurring theme in this configuration file is configuring where Emacs packages drop their various state files. =no-littering.el= is a package that handles this with =var/= and =etc/= directories in =~/.emacs.d/=, but it's implemented in a way that pollutes the global namespace with variables for packages that I don't use, and would require a significant amount of configuration on my part anyway. I've decided to manually set relevant variables to subdirectories of =~/.cache= and =~/.local/share=. Save backup files to one directory instead of making a mess of the filesystem. #+BEGIN_SRC elisp (setq backup-directory-alist `(("." . "~/.cache/emacs"))) #+END_SRC =auto-save=, in addition to the actual files it saves, maintains another file listing the files it's currently taking care of. #+BEGIN_SRC elisp (setq auto-save-list-file-prefix "~/.cache/emacs/auto-save-list/.saves-") #+END_SRC Disable the creation of locking symlinks in the current directory. This is a very opinionated choice, and probably isn't a good idea for most. #+BEGIN_SRC elisp (setq create-lockfiles nil) #+END_SRC I don't use =custom.el= to set variables, but a few of the packages I use do. This snippet ensures that a massacre is not made of my =init.el=. #+BEGIN_SRC elisp (setq custom-file "~/.emacs.d/custom.el") (when (file-exists-p custom-file) (load custom-file)) #+END_SRC I don't really care about persisting minibuffer history between sessions. Even if I disable =savehist-mode=, it still writes to disk, so the least I can do is move the history file to somewhere that isn't =~/.emacs.d=. #+BEGIN_SRC elisp (savehist-mode -1) (setq savehist-file "~/.cache/emacs/history") #+END_SRC ** User Interface Use a consistent confirmation dialog of "y or n". #+BEGIN_SRC elisp (fset 'yes-or-no-p 'y-or-n-p) #+END_SRC Automatically revert buffers and dired listings when something on disk changes. #+BEGIN_SRC elisp (use-package autorevert :config (global-auto-revert-mode 1) (setq global-auto-revert-non-file-buffers t auto-revert-verbose nil)) #+END_SRC "Command attempted to use minibuffer while in minibuffer" gets old fast. #+BEGIN_SRC elisp (setq enable-recursive-minibuffers t) #+END_SRC Actually select help windows when I pop them so that I can kill them with . #+BEGIN_SRC elisp (setq help-window-select t) #+END_SRC Most *NIX tools work best when files are terminated with a newline. #+BEGIN_SRC emacs-lisp (setq require-final-newline t) #+END_SRC Sentences should be separated by a single space. Treat two sentences as such when filling. #+BEGIN_SRC elisp (setq sentence-end-double-space nil) #+END_SRC I use the tab key, but I generally prefer space characters to tabstops and like a four-character width for indentation. #+BEGIN_SRC elisp (setq-default indent-tabs-mode nil tab-width 4) #+END_SRC Modern conventions state that 80 characters is the standard width. #+BEGIN_SRC elisp (setq-default fill-column 80) #+END_SRC When killing, add whatever's in the system clipboard if it isn't there already, so I can get it back with . #+BEGIN_SRC elisp (setq save-interprogram-paste-before-kill t) #+END_SRC Enable the default-disabled functions that I use. #+BEGIN_SRC elisp (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) #+END_SRC Enable useful visual queues. #+BEGIN_SRC elisp (show-paren-mode t) (column-number-mode t) #+END_SRC Unbind and so that I'm not accidentally calling =suspend-frame=. #+BEGIN_SRC elisp (global-unset-key (kbd "C-z")) (global-unset-key (kbd "C-x C-z")) #+END_SRC * Quality-of-Life ** Ivy As [[https://icosahedron.website/@zge/101330910258980695][suggested by a friend]], I tried out Ivy as a replacement for ido. It was love at first sight. It's snappy, and works even better than ido after setting =exwm-workspace-show-all-buffers= and =exwm-layout-show-all-buffers=. Configure how the =completing-read= is displayed. #+BEGIN_SRC elisp (use-package ivy :init (setq ivy-height 5 ivy-count-format "") #+END_SRC Enable Ivy globally. #+BEGIN_SRC elisp :config (ivy-mode 1)) #+END_SRC Use Counsel as a frontend to a couple of interactive commands. #+BEGIN_SRC elisp (use-package counsel :demand t :bind (("C-x b" . counsel-switch-buffer))) #+END_SRC Use Swiper instead of isearch. #+BEGIN_SRC elisp (use-package swiper :bind ("C-r" . swiper) ("C-s" . swiper)) #+END_SRC ** Yasnippet Load all snippets when =yas-minor-mode= is enabled. #+BEGIN_SRC elisp (use-package yasnippet :demand t :hook (yas-minor-mode . yas-reload-all)) #+END_SRC ** avy Set up keybindings for =avy=. #+BEGIN_SRC elisp (use-package avy :bind ("M-s" . avy-goto-char)) #+END_SRC ** Imenu Set up keybindings for =imenu=. #+BEGIN_SRC elisp (use-package imenu :bind ("C-c s" . imenu)) #+END_SRC ** pass Here's a snippet for interactively pulling a password from [[passwordstore.org][password-store]], so I'm not spawning a terminal every time I need to invoke my password manager. #+BEGIN_SRC elisp (defvar password-store-directory "~/.password-store" "Directory containing passwords managed by `pass'.") (defun pass-password-files () "Returns the paths of every password managed by `pass'." (let ((prefix-length (1+ (length (expand-file-name password-store-directory)))) (suffix-length (length ".gpg"))) (map 'list #'(lambda (path) (cl-subseq path prefix-length (- suffix-length))) (directory-files-recursively password-store-directory ".gpg$")))) (defun pass () "Prompt for a password and copy it to the clipboard. Passwords are taken from `password-store-directory'." (interactive) (let* ((account (completing-read "Account: " (pass-password-files))) (path (concat password-store-directory "/" account ".gpg"))) (with-temp-buffer (insert-file path) (clipboard-kill-ring-save 1 (1- (buffer-end 1)))) (message "Password for %s copied to clipboard." account))) #+END_SRC * Appearance This feature doesn't see frequent use, but I prefer three proportionally-sized windows to two really tiny ones over a really big one. #+BEGIN_SRC elisp (setq window-combination-resize t) #+END_SRC Don't do jerky jumps when the cursor reaches the end of the window. Instead, just scroll by one line. #+BEGIN_SRC elisp (setq scroll-conservatively most-positive-fixnum) #+END_SRC Use soft wrapping instead of "scrolling" when overflowing the width of a frame. #+BEGIN_SRC elisp (global-visual-line-mode t) #+END_SRC The menu bar can be accessed with =M-`= if I really need it, so I don't see the point in having it take up the space at the top. The rest of these rarely see use from me, and I'd prefer to disable them and have access to the extra screen real estate. #+BEGIN_SRC elisp (menu-bar-mode -1) (scroll-bar-mode -1) (tool-bar-mode -1) (fringe-mode -1) #+END_SRC Hacking is a lot more serene when visual stimulus is kept to a minimum. #+BEGIN_SRC elisp (blink-cursor-mode 0) #+END_SRC ** Theme This is my custom theme, the code for which is very loosely adapted from [[https://github.com/kuanyui/moe-theme.el][moe-theme.el]], but most of the palette has been altered to emulate the appearance of my old setup of Emacs in a terminal emulator. #+BEGIN_SRC elisp (deftheme chayote "Inspired by the appearance of Emacs in my terminal emulator.") #+END_SRC The colors have been extracted into a variable, =palette=, and a macro, =with-palette=, to provide access to the theme's color definitions without significantly polluting the global namespace. #+BEGIN_SRC elisp (defvar palette '((yellow-1 "#ffd787") (yellow-2 "#ffd700") (yellow-3 "#c4a000") (yellow-3-5 "#aaaa11") (yellow-4 "#875f00") (orange-1 "#ffaf87") (orange-2 "#ff8700") (orange-3 "#ff5d17") (orange-4 "#d75f00") (orange-5 "#af5f00") (magenta-1 "#ff7bbb") (magenta-2 "#ff4ea3") (magenta-3 "#ff1f8b") (green-1 "#87ff87") (green-2 "#a1db00") (green-3 "#5faf00") (green-4 "#008700") (green-5 "#005f00") (cyan-1 "#afd7d7") (cyan-2 "#87ffd7") (cyan-3 "#00d7af") (cyan-4 "#00ac8a") (cyan-5 "#5faf87") (cyan-6 "#005f5f") (cyan-7 "#236f73") (blue-1 "#1fb6d3") (blue-2 "#1f5bff") (blue-3 "#005f87") (blue-4 "#5f7ab1") (blue-5 "#0000af") (blue-6 "#00005f") (purple-1 "#d18aff") (purple-2 "#af5fff") (purple-3 "#9a08ff") (purple-4 "#6c0099") (red-1 "#ef2929") (red-2 "#dd0000") (red-3 "#a40000") (red-4 "#5f0000") (white-1 "#f0e9dc") (white-2 "#c6c6c6") (white-3 "#b2b2b2") (black-1 "#a8a8a8") (black-2 "#8a8a8a") (black-2-5 "#6c6c6c") (black-3 "#4e4e4e") (black-4 "#3a3a3a") (black-5 "#303539") (black-6 "#000000") (LIGHT_BG "#fdfde7") (white-0 "#eeeeee") (green-02 "#5fd700") (green-01 "#d7ff00") (green-0 "#d7ff5f") (green-00 "#d7ff87") (cyan-0 "#d7ffd7") (blue-01 "#c3c9f8") (blue-0 "#afd7ff") (blue-00 "#d7d7ff") (yellow-0 "#ffff87") (yellow-00 "#ffffaf") (purple-0 "#af87ff") (purple-00 "#e6a8df") (red-0 "#ff4b4b") (red-00 "#ffafaf") (magenta-0 "#ffafd7") (magenta-00 "#ffd7ff") (orange-0 "#ffaf87") (orange-00 "#ffd787") (orange-000 "#ffd7af") (linum-dark "#87875f") (linum-light "#d7d7af")) "The palette of colors in use with my 'chayote' theme.") (defmacro with-palette (&rest form) "Evaluate `FORM' in a lexical environment with access to the individual colors making up the theme's palette." `(let ((class '((class color) (min-colors 89))) ,@palette) ,@form)) #+END_SRC To help me in modifying the theme, I've defined a function similar to =list-colors-display=, but for showing the colors in the palette I've defined. #+BEGIN_SRC elisp (defun display-palette () "Display names of colors defined in `PALETTE', and show what they look like." (interactive) (with-help-window "*Chayote Colors*" (with-current-buffer standard-output (erase-buffer) (dolist (color palette) (let* ((name (symbol-name (first color))) (value (second color))) (put-text-property 0 (length name) 'font-lock-face `(:foreground ,value) name) (insert name) (insert (propertize " " 'display '(space :align-to (- right 9)))) (insert " ") (put-text-property 0 (length value) 'font-lock-face `(:background ,value) value) (insert value) (terpri))) (set-buffer-modified-p nil) (setq truncate-lines t)))) #+END_SRC #+BEGIN_SRC elisp (with-palette (custom-theme-set-faces 'chayote `(default ((,class (:foreground ,white-1 :background ,black-5 :family "Terminus" :height 90)))) `(cursor ((,class (:background ,white-0)))) `(link ((,class (:foreground ,blue-1 :underline t)))) ;; Highlighting faces `(highlight ((,class (:background ,black-3)))) `(hl-line ((,class (:background ,black-4)))) `(highlight-symbol-face ((,class (:background ,green-5)))) `(region ((,class (:background ,blue-4)))) `(secondary-selection ((,class (:background ,blue-3 :foreground ,white-0)))) `(isearch ((,class (:foreground ,white-1 :background ,orange-3)))) `(lazy-highlight ((,class (:background ,magenta-3 :foreground ,white-1)))) `(trailing-whitespace ((,class (:background ,red-3)))) `(show-paren-match ((,class (:background ,blue-3 :foreground nil)))) `(header-line ((,class (:background ,blue-3 :foreground ,white-0)))) `(help-argument-name ((,class (:foreground ,magenta-1 :italic t)))) `(eldoc-highlight-function-argument ((,class (:foreground ,green-01 :bold t :underline t :background ,green-5)))) ;; Mode line & frames' faces `(mode-line ((,class (:box nil :background ,white-1 :foreground ,black-5)))) `(mode-line-inactive ((,class (:background ,white-3 :foreground ,black-5)))) `(mode-line-buffer-id ((,class (:box nil :foreground ,black-5 :background nil)))) `(vertical-border ((,class (:foreground ,black-3 :background ,black-3)))) ;; Escape and prompt faces `(minibuffer-prompt ((,class (:foreground ,blue-1)))) `(escape-glyph ((,class (:foreground ,yellow-3)))) `(error ((,class (:foreground ,red-0)))) `(warning ((,class (:foreground ,orange-1)))) `(success ((,class (:foreground ,green-1)))) ;; Font lock faces `(font-lock-builtin-face ((,class (:foreground ,cyan-1)))) `(font-lock-comment-delimiter-face ((,class (:inherit font-lock-comment-face)))) `(font-lock-comment-face ((,class (:foreground ,orange-2)))) `(font-lock-constant-face ((,class (:foreground ,cyan-2)))) `(font-lock-doc-face ((,class (:inherit font-lock-string-face)))) `(font-lock-doc-string-face ((,class (:inherit font-lock-string-face)))) `(font-lock-function-name-face ((,class (:foreground ,blue-0)))) `(font-lock-keyword-face ((,class (:foreground ,blue-1)))) `(font-lock-negation-char-face ((,class (:foreground ,red-0)))) `(font-lock-preprocessor-face ((,class (:inherit font-lock-builtin-face)))) `(font-lock-regexp-grouping-backslash ((,class (:foreground ,yellow-1)))) `(font-lock-regexp-grouping-construct ((,class (:foreground ,purple-1)))) `(font-lock-string-face ((,class (:foreground ,orange-1)))) `(font-lock-type-face ((,class (:foreground ,green-1)))) `(font-lock-variable-name-face ((,class (:foreground ,yellow-1)))) `(font-lock-warning-face ((,class (:weight bold :foreground ,red-2)))) ;; company `(company-tooltip ((,class (:background ,black-4)))) `(company-scrollbar-bg ((,class (:background ,black-4)))) `(company-scrollbar-fg ((,class (:background ,orange-2)))) `(company-tooltip-selection ((,class (:background ,black-3)))) `(company-tooltip-common ((,class (:foreground ,blue-1)))) `(company-tooltip-annotation ((,class (:foreground ,cyan-1)))) ;; org-mode `(org-block ((,class (:foreground ,white-1 :background ,black-4)))) `(org-block-begin-line ((,class (:foreground ,black-3)))) `(org-verbatim ((,class (:foreground ,blue-1 :background ,black-4)))) `(org-link ((,class (:inherit link)))) `(org-warning ((,class (:foreground ,white-0 :background ,red-4)))) ;; erc `(erc-input-face ((,class (:foreground ,white-1))))) (custom-theme-set-variables 'chayote `(ansi-color-names-vector [,black-5 ,red-0 ,green-0 ,yellow-1 ,blue-1 ,purple-1 ,blue-0 ,white-1]))) #+END_SRC ** Modeline This is essentially the vanilla modeline, just without the handful of components I consider unimportant. #+BEGIN_SRC elisp (setq-default mode-line-format '("%e" mode-line-front-space mode-line-client mode-line-modified " " mode-line-directory mode-line-buffer-identification " " mode-line-position " " mode-line-modes mode-line-misc-info mode-line-end-spaces)) #+END_SRC To make things a little easier on my eyes, I've chosen to add visual separation between my additions to the modeline. #+BEGIN_SRC elisp (defconst mode-line-separator " | " "A separator to place between components of the modeline.") #+END_SRC A function to simplify the addition of new =:eval= forms to the end of =mode-line-format=. #+BEGIN_SRC elisp (defun add-to-mode-line (widget) "Appends a `MODE-LINE-SEPARATOR' and `WIDGET' onto the end of `MODE-LINE-FORMAT'." (let ((eval-form `(:eval (funcall ,widget)))) (setq-default mode-line-format (append mode-line-format (list mode-line-separator eval-form))))) #+END_SRC My implementation of a clock for the modeline. The modeline is refreshed by a timer to ensure that it doesn't go too stale, as it could theoretically go several minutes without being updated. #+BEGIN_SRC elisp (add-to-mode-line (lambda () (format-time-string "%Y-%m-%d %H:%M"))) (let ((timer (run-at-time t 60.0 #'ignore))) (timer-set-function timer (lambda () (force-mode-line-update)))) #+END_SRC My implementation of a battery monitor for the modeline. Because strings in =mode-line-format= can contain control sequences, the percent symbol has to be escaped twice -- once for =battery-format=, and once for =mode-line-format=. #+BEGIN_SRC elisp (use-package battery :straight nil :config (add-to-mode-line (lambda () (let* ((status (battery-linux-sysfs)) (fullness (string-to-number (cdr (assoc 112 status)))) (text (battery-format "%L: %t, %p%%%%" status)) (low-battery-face '(:foreground "white" :background "red"))) (when (< fullness 10.0) (put-text-property 0 (length text) 'font-lock-face low-battery-face text)) text)))) #+END_SRC ** Pretty Symbols Enable =prettify-symbols= globally. #+BEGIN_SRC elisp (global-prettify-symbols-mode t) #+END_SRC This is snippet was taken verbatim from [[https://emacs.stackexchange.com/questions/17283/is-it-possible-to-get-prettified-symbols-in-org-mode-source-blocks][Emacs StackExchange]] to enable =prettify-symbols= in Org source code blocks. Sadly, I can't think of a way to implement this as advice. #+BEGIN_SRC elisp (defun org-src-font-lock-fontify-block (lang start end) "Fontify code block. This function is called by emacs automatic fontification, as long as `org-src-fontify-natively' is non-nil." (let ((lang-mode (org-src--get-lang-mode lang))) (when (fboundp lang-mode) (let ((string (buffer-substring-no-properties start end)) (modified (buffer-modified-p)) (org-buffer (current-buffer)) pos next) (remove-text-properties start end '(face nil)) (with-current-buffer (get-buffer-create (concat " org-src-fontification:" (symbol-name lang-mode))) (delete-region (point-min) (point-max)) (insert string " ") ;; so there's a final property change (unless (eq major-mode lang-mode) (funcall lang-mode)) ;; Avoid `font-lock-ensure', which does not display fonts in ;; source block. (font-lock-fontify-buffer) (setq pos (point-min)) (while (setq next (next-single-property-change pos 'face)) (put-text-property (+ start (1- pos)) (1- (+ start next)) 'face (get-text-property pos 'face) org-buffer) (setq pos next)) ;; Addition: also copy 'composition info for prettified symbols (setq pos (point-min)) (while (setq next (next-single-property-change pos 'composition)) (put-text-property (+ start (1- pos)) (1- (+ start next)) 'composition (get-text-property pos 'composition) org-buffer) (setq pos next)) ;; End addition ) (add-text-properties start end '(font-lock-fontified t fontified t font-lock-multiline t)) (set-buffer-modified-p modified))))) #+END_SRC ** dim [[https://www.emacswiki.org/emacs/DelightedModes][Delight]] doesn't work for me, and [[https://github.com/myrjola/diminish.el][diminish]] is sadly lacking in the feature department, so I've chosen to clean up my modeline with dim. =use-package= doesn't have an equivalent of =:diminish= or =:delight=, so declarations occur here. #+BEGIN_SRC elisp (use-package dim :config (dim-minor-name 'visual-line-mode "") (eval-after-load 'ivy '(dim-minor-name 'ivy-mode "")) (eval-after-load 'projectile '(dim-minor-name 'projectile-mode ""))) #+END_SRC * Window Management Yes, I use Emacs as my window manager. You should, too! #+BEGIN_SRC elisp (use-package exwm-config :straight nil :after exwm) (use-package exwm :config (exwm-enable) #+END_SRC I find that four workspaces is enough to start out with, and I like being able to use my X windows across workspaces. #+BEGIN_SRC elisp :init (setq exwm-workspace-number 4 exwm-workspace-show-all-buffers t exwm-layout-show-all-buffers t) #+END_SRC "Global key bindings" in EXWM work essentially anywhere, including buffers that are currently in char mode. I've taken this as an opportunity to incorporate windmove to my workflow, now that I have the super key at my disposal. #+BEGIN_SRC elisp :init (setq exwm-input-global-keys `(([?\s-r] . exwm-reset) ([?\s-w] . windmove-up) ([?\s-a] . windmove-left) ([?\s-s] . windmove-down) ([?\s-d] . windmove-right) ([?\s-p] . (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) ([?\s-X] . (lambda () (interactive) (start-process "" nil "/usr/bin/slock"))) ([?\s-f] . (lambda () (interactive) (start-process "" nil "/usr/bin/firefox"))) ([?\s-m] . (lambda () (interactive) (start-process "" nil "/usr/bin/kitty" "--class" "mutt" "/usr/bin/mutt"))) (,(kbd "s-") . (lambda () (interactive) (start-process "" nil "/usr/bin/kitty"))) ;; Keys are offset such that corresponds to the 0th workspace. ,@(mapcar (lambda (i) `(,(kbd (format "s-%d" i)) . (lambda () (interactive) (exwm-workspace-switch-create ,(- i 1))))) (number-sequence 1 9)))) #+END_SRC Ah, yes. Simulation keys, the real reason I decided to install EXWM. #+BEGIN_SRC elisp :init (setq exwm-input-simulation-keys '(([?\C-b] . [left]) ([?\M-b] . [C-left]) ([?\C-f] . [right]) ([?\M-f] . [C-right]) ([?\C-p] . [up]) ([?\C-n] . [down]) ([?\C-a] . [home]) ([?\C-e] . [end]) ([?\M-v] . [prior]) ([?\C-v] . [next]) ([?\C-d] . [delete]) ([?\C-k] . [S-end delete]) ([?\C-w] . [?\C-x]) ([?\M-w] . [?\C-c]) ([?\C-y] . [?\C-v]) ([?\C-s] . [?\C-f]))) #+END_SRC The tab management functionality of Firefox's Saka Key extension is limited, so I'm using simulation keys instead. I've also disabled simulation keys for kitty because it doesn't play nicely with readline. #+BEGIN_SRC elisp :hook (exwm-manage-finish . (lambda () (when (and exwm-class-name (string= exwm-class-name "Firefox")) (exwm-input-set-local-simulation-keys (concatenate 'list exwm-input-simulation-keys '(([?\C-q] . [?\C-w]))))) (when (and exwm-class-name (or (string= exwm-class-name "kitty") (string= exwm-class-name "mutt"))) (exwm-input-set-local-simulation-keys nil)))) #+END_SRC EXWM's buffers are named =*EXWM*= upon creation, which makes switching between windows a pain. This snippet renames buffers when their class or title changes. #+BEGIN_SRC elisp :hook (exwm-update-class . (lambda () (exwm-workspace-rename-buffer exwm-class-name))) (exwm-update-title . (lambda () (when (not exwm-instance-name) (exwm-workspace-rename-buffer exwm-title)))) #+END_SRC Start the Emacs daemon so that =emacsclient= can be used from the command line to pop a new buffer for editing. #+BEGIN_SRC elisp :config (server-start)) #+END_SRC EXWM has issues popping any sort of pinentry window, so I just let Emacs do pinentry's job. #+BEGIN_SRC elisp (use-package epa :straight nil :config (setq epa-pinentry-mode 'loopback)) #+END_SRC * System ** ag Set up keybindings for calling =ag=. #+BEGIN_SRC elisp (use-package ag :bind ("C-c k" . counsel-ag)) #+END_SRC ** Dired Hide the targets of symbolic links in dired listings. This is just a visual preference of mine. #+BEGIN_SRC elisp (use-package dired :straight nil :init (setq-default dired-listing-switches "-alL")) #+END_SRC ** Tramp Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp (use-package tramp :straight nil :init (setq-default tramp-persistency-file-name "~/.cache/emacs/tramp")) (use-package nsm :straight nil :init (setq nsm-settings-file "~/.cache/emacs/network-security.data")) #+END_SRC * Documents ** Org Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp (use-package org :straight org-plus-contrib :init (setq-default org-id-locations-file "~/.cache/emacs/org-id-locations" org-latex-preview-ltxpng-directory "~/.cache/emacs/ltximg/" org-preview-latex-image-directory "~/.cache/emacs/ltximg/") #+END_SRC Only load the =org-contrib= modules that I actually use. #+BEGIN_SRC elisp :init (setq org-modules '(org-drill)) #+END_SRC General appearance and quality-of-life settings. #+BEGIN_SRC elisp :init (setq org-return-follows-link t org-startup-folded nil org-startup-with-inline-images t org-hide-emphasis-markers t org-tags-column 100) #+END_SRC Keep everything in column zero, instead of indenting according to the depth of the preceding headline. #+BEGIN_SRC elisp :init (setq org-adapt-indentation nil) #+END_SRC Have indent according to the indentation rules of the corresponding mode in an =org-src= block, and start indentation on column 0. Taken from [[https://stackoverflow.com/questions/15773354/indent-code-in-org-babel-src-blocks][this post]] and [[https://emacs.stackexchange.com/questions/9472/org-mode-source-block-doesnt-respect-parent-buffer-indentation][this post]] on StackExchange. #+BEGIN_SRC elisp :init (setq org-src-tab-acts-natively t org-edit-src-content-indentation 0) #+END_SRC Reuse the current window when I punch in =C-c '=, rather than mess up my window configuration. #+BEGIN_SRC elisp :init (setq org-src-window-setup 'current-window) #+END_SRC Scale up embedded LaTeX. The default size is unreadable. #+BEGIN_SRC elisp :config (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5)) #+END_SRC Enable [[Yasnippet]]. #+BEGIN_SRC elisp :hook (org-mode . yas-minor-mode-on) #+END_SRC Replace my [[Imenu]] binding with =org-goto=, as it allows me to select parent headings. #+BEGIN_SRC elisp :init (setq org-goto-interface 'outline-path-completionp) (setq org-outline-path-complete-in-steps nil) :bind (:map org-mode-map ("C-c s" . org-goto)) #+END_SRC Global keybindings for my Org workflow. #+BEGIN_SRC elisp :bind (("C-c a" . (lambda () (interactive) (org-agenda nil "d"))) ("C-c c" . (lambda () (interactive) (org-capture nil "c"))) ("C-c t" . (lambda () (interactive) (org-capture nil "t")))) #+END_SRC Use Counsel's functionality for adding tags. #+BEGIN_SRC elisp :bind (:map org-mode-map ("C-c C-q" . counsel-org-tag)) #+END_SRC *** Personal Wiki I maintain a personal wiki using Org and I like to link between pages. This is just a convenience link type, rooted at the base of my notes folder so that I can easily refer to other pages from subdirectories of =notes-directory=. #+BEGIN_SRC elisp :config (defvar notes-directory "~/Notes" "Where all the pages of my 'personal wiki' are stored.") (defun org-notes-follow (link) "Visits LINK, or if LINK names a subdirectory of `notes-directory', the 'Index.org' in LINK." (let ((directory-p (file-directory-p (expand-file-name link notes-directory)))) (find-file (expand-file-name (if directory-p "Index.org" (concat link ".org")) notes-directory)))) (org-link-set-parameters "note" :follow #'org-notes-follow) #+END_SRC Code for interactively navigating the personal wiki. #+BEGIN_SRC elisp :config (defvar notes-directory-ignore '("." ".." ".git" ".gitignore" "Drill" "Finance" "GTD" "Interviewing" "Mind Dumps") "Files and directories in `notes-directory' to exclude from wiki interactions.") (defun notes-file-is-page (filename) "Returns whether or not FILENAME names a page rather than a category." (string= (cl-subseq filename (- (length filename) 4)) ".org")) (defun notes-file-should-ignore (filename) "Returns whether or not a file in `notes-directory' should be ignored. Members of `notes-directory-ignore' are ignored." (member filename notes-directory-ignore)) (defun notes-hierarchy-paths (&optional category) "Returns page and category paths relative to `notes-directory'. The resultant list does not include files that satisfy the `notes-file-should-ignore' predicate." (let* ((path (if category (concat notes-directory "/" category) notes-directory)) (contents (cl-remove-if #'notes-file-should-ignore (directory-files path))) (pages (cl-remove-if-not #'notes-file-is-page contents)) (categories (cl-remove-if #'notes-file-is-page contents)) (categories (if category (map 'list #'(lambda (subcategory) (concat category "/" subcategory)) categories) categories))) (append (if category (map 'list #'(lambda (page) (concat category "/" page)) pages) pages) categories (apply #'append (map 'list #'notes-hierarchy-paths categories))))) (defun notes-hierarchy () "Returns every page and category in `notes-directory'. The result contains lists of the form (NAME PATH IS-PAGE-P), and does not include files that satisfy the `notes-file-should-ignore' predicate." (map 'list #'(lambda (path) (list (if (notes-file-is-page path) (cl-subseq path 0 -4) path) (concat notes-directory "/" path) (notes-file-is-page path))) (notes-hierarchy-paths))) (defun notes-page-goto () "Interactively find a page in `notes-directory'." (interactive) (let* ((hierarchy (notes-hierarchy)) (hierarchy (cl-remove-if-not #'third hierarchy)) (name (ivy-read "Find file: " (map 'list #'first hierarchy))) (item (cl-find-if #'(lambda (item) (string= name (first item))) hierarchy))) (if item (find-file (second item)) (let ((path (concat notes-directory "/" name ".org"))) (find-file path))))) #+END_SRC Set up a key binding for quickly querying the wiki. #+BEGIN_SRC elisp :bind ("C-c w" . notes-page-goto) #+END_SRC *** Capture Low-friction means of adding things to my GTD inbox. #+BEGIN_SRC elisp :config (setq org-capture-templates `(("t" "TODO" entry (file "~/Notes/GTD/Inbox.org") "* TODO %?\n"))) #+END_SRC *** Agenda A rather convoluted agenda setup to show me: - The tasks I've marked as needing to be done today. - The inbox items I need to process. - My daily habits (implemented as recurring Org TODO's). - A view of deadlines and scheduled items for the week ahead. #+BEGIN_SRC elisp :init (setq org-agenda-files '("~/Notes/GTD/Habits.org" "~/Notes/GTD/Inbox.org" "~/Notes/GTD/Actionable.org")) (let ((entry-done '(lambda () (org-agenda-skip-entry-if 'todo 'done))) (subtree-is-habit '(lambda () (let ((subtree-end (save-excursion (org-end-of-subtree t)))) (if (string= (org-entry-get nil "STYLE") "habit") subtree-end nil)))) (subtree-is-not-habit '(lambda () (let ((subtree-end (save-excursion (org-end-of-subtree t)))) (if (not (string= (org-entry-get nil "STYLE") "habit")) subtree-end nil)))) (subtree-is-not-inbox '(lambda () (let ((subtree-end (save-excursion (org-end-of-subtree t)))) (if (not (cl-search "Inbox.org" (buffer-name))) subtree-end nil))))) (setq org-agenda-custom-commands `(("d" "Daily" ((tags "PRIORITY=\"A\"" ((org-agenda-skip-function ,entry-done) (org-agenda-overriding-header "Tasks for Today:"))) (alltodo "" ((org-agenda-skip-function ,subtree-is-not-inbox) (org-agenda-overriding-header "Inbox:"))) (agenda "" ((org-agenda-span 'day) (org-agenda-skip-function ,subtree-is-not-habit) (org-deadline-warning-days 0) (org-agenda-overriding-header "Habits:"))) (agenda "" ((org-agenda-span 'week) (org-agenda-skip-function ,subtree-is-habit) (org-agenda-overriding-header "Week Ahead:")))) ((org-agenda-compact-blocks t)))))) #+END_SRC *** Drill Scan the directory of the current buffer's file for other items, rather than just the current buffer. This is so that I can spread my cards across multiple files and still be tested on all of them when I run =org-drill=. The idea of combining topic during review sessions is suggested in Michael Nielsen article, [[http://augmentingcognition.com/ltm.html]["Augmenting Long-term Memory"]]. #+BEGIN_SRC elisp :init (setq org-drill-scope 'directory) #+END_SRC Shut up the nagging "are you studying enough!?" message if I don't get enough items right. It's unhelpful and discourages me from being completely honest with the SRS algorithm. #+BEGIN_SRC elisp :init (setq org-drill-forgetting-index 100)) #+END_SRC **** Workaround As described [[https://bitbucket.org/eeeickythump/org-drill/issues/62/org-drill-doesnt-work-with-org-mode-92][here]], the upstream version of org-drill doesn't work with the latest version of Org. Until this is fixed, I'm using someone else's patched version of =org-drill=. #+BEGIN_SRC elisp (straight-use-package '(org-drill :type git :host github :repo "hakanserce/org-drill")) (require 'cl) (require 'org-drill) #+END_SRC *** Blog Use =ox-hugo= for exporting my blog posts. #+BEGIN_SRC elisp (use-package ox-hugo) #+END_SRC ** Markdown #+BEGIN_SRC elisp (use-package markdown-mode :mode (("\\.md\\'" . markdown-mode) ("\\.markdown\\'" . markdown-mode)) :init (setq markdown-command "markdown_py")) #+END_SRC ** PDF =doc-view= is unbearable for reading PDF's of any considerable size and =pdf-tools= brings a number of significant improvements, so I can justify not using the built-in solution. Even though I can run MuPDF in an [[EXWM]] buffer, the integration in terms of searching and viewing attachments that comes with =pdf-tools= makes for a much more pleasant experience. #+BEGIN_SRC elisp (use-package pdf-tools :config (pdf-loader-install)) #+END_SRC * IRC Functions for connecting to and authenticating with my IRC bouncer. #+BEGIN_SRC elisp (defun read-bouncer-password () "Pull the password for my bouncer from authinfo" (let ((auth (auth-source-search :host "jakob.space" :user "jakob" :port 26969))) (unless auth (error "No auth entry for bouncer.")) (let ((secretf (plist-get (car auth) :secret))) (unless secretf (error "No secret for bouncer's auth entry.")) (funcall secretf)))) (defun connect-bouncer (server) "Connect to `SERVER' on the bouncer and rename the buffer" (let ((password (format "%s/%s:%s" "jakob" server (read-bouncer-password)))) (erc-tls :server "jakob.space" :port 26969 :password password) (erc-with-buffer ((get-buffer "jakob.space:26969") (rename-buffer server))))) #+END_SRC Functions for connecting to and authenticating with an instance of Bitlbee. #+BEGIN_SRC elisp (defun bitlbee-connect () "Start bitlbee as an inferior process and connect to it." (bitlbee-start) (erc :server "localhost" :port 6667) (erc-with-buffer ((get-buffer "localhost:6667") (rename-buffer "bitlbee")))) (defun bitlbee-identify () "If we're on the bitlbee server, send the identify command to the &bitlbee channel." (when (and (string= "localhost" erc-session-server) (string= "&bitlbee" (buffer-name))) (erc-message "PRIVMSG" (format "%s identify %s" (erc-default-target) (read-bouncer-password))))) #+END_SRC Interactive function for setting everything up, which involves starting an inferior Bitlbee process, connecting to it, and then connecting to all of the networks my bouncer is connected to. #+BEGIN_SRC elisp (defvar irc-autoconnect-networks '("bitlbee" "crtnet" "freenode" "tildetown" "tildechat") "List of networks to automatically connect to when 'irc' is invoked.") (defun irc () "Connect to Bitlbee and every network in `irc-autoconnect-networks'." (interactive) (dolist (network irc-autoconnect-networks) (if (string= network "bitlbee") (bitlbee-connect) (connect-bouncer network)))) (defun irc-quit () "Disconnects from and kills all buffers associated with ERC, and ends the Bitlbee process." (interactive) (bitlbee-stop) (let ((server-buffers (remove-if-not #'erc-server-buffer-p (erc-buffer-list)))) (dolist (buffer server-buffers) (erc-with-buffer (buffer) (erc-quit-server (funcall erc-quit-reason nil)))))) #+END_SRC Only load the modules I actually use. This list deviates from the default by including =truncate= and =keep-place=, but omitting =autojoin=. #+BEGIN_SRC elisp (use-package erc :straight nil :config (setq erc-modules '(button completion fill irccontrols keep-place list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track truncate)) (erc-update-modules) #+END_SRC Configure personal details. #+BEGIN_SRC elisp :init (setq erc-nick '("jakob" "tsarfox") erc-user-full-name "Jakob " erc-quit-reason (lambda (reason) (or reason (concat "Program received signal " "SIGSEGV, Segmentation fault.")))) #+END_SRC Display the current nick in the prompt. #+BEGIN_SRC elisp :init (setq erc-prompt (lambda () (format "%s>" (erc-current-nick)))) #+END_SRC Center everything. #+BEGIN_SRC elisp :init (setq erc-fill-function 'erc-fill-static erc-fill-column 100 erc-fill-static-center 22) #+END_SRC Enable MIRC and control sequences so I can partake in figlet spam, objectively the best part of the IRC experience. #+BEGIN_SRC elisp :init (setq erc-interpret-controls-p t erc-interpret-mirc-color t) #+END_SRC Enable timestamps, and show them to the left of the messages. #+BEGIN_SRC elisp :init (setq erc-hide-timestamps nil erc-insert-timestamp-function 'erc-insert-timestamp-left) #+END_SRC Although =log= is omitted from =erc-modules=, I still explicitly disable logging. I can just save the buffer if I want to save a conversation. #+BEGIN_SRC elisp :init (setq erc-enable-logging nil erc-save-buffer-on-part nil) #+END_SRC Similarly, =autowaway= is omitted from =erc-modules=, but I'm disabling it anyway. #+BEGIN_SRC elisp :init (setq erc-auto-set-away nil erc-auto-discard-away nil) #+END_SRC Kill buffers when I disconnect. #+BEGIN_SRC elisp :init (setq erc-kill-buffer-on-part t erc-kill-queries-on-quit t erc-kill-server-buffer-on-quit t) #+END_SRC Don't get in my way by popping new windows when someone queries me, and don't assault me with windows when I connect to my bouncer. #+BEGIN_SRC elisp :init (setq erc-auto-query 'bury erc-join-buffer 'bury) #+END_SRC Show CTCP requests. Not for any reason in particular, I just like seeing when people ping me. #+BEGIN_SRC elisp :init (setq erc-paranoid t) #+END_SRC Hide JOIN/PART/QUIT messages from idlers. #+BEGIN_SRC elisp :init (setq erc-lurker-hide-list '("JOIN" "PART" "QUIT") erc-lurker-threshold-time 3600) #+END_SRC Enable =erc-track= to ignore the less interesting message types. #+BEGIN_SRC elisp :init (setq erc-track-exclude-server-buffer t erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" "324" "329" "332" "333" "353" "477")) #+END_SRC Enable channel tracking. #+BEGIN_SRC elisp :config (erc-track-minor-mode 1) (erc-track-mode 1) #+END_SRC Move to the prompt as soon as I begin typing. I've configured the buffer text preceding it to be read-only, anyway. #+BEGIN_SRC elisp :config (erc-move-to-prompt-enable) #+END_SRC Let =erc-fill= handle filling. #+BEGIN_SRC elisp :hook (erc-mode . (lambda () (auto-fill-mode 0))) #+END_SRC Enable a hook for automatically identifying with Bitlbee. #+BEGIN_SRC elisp :hook (erc-join . bitlbee-identify) #+END_SRC Configure =erc-hl-nicks= to show names using pretty colors. #+BEGIN_SRC elisp (use-package erc-hl-nicks :after erc :config (erc-hl-nicks-enable)) #+END_SRC Configure the =bitlbee= package for starting an inferior Bitlbee process. #+BEGIN_SRC elisp (use-package bitlbee :init (setq bitlbee-user-directory "~/.config/bitlbee/")) #+END_SRC * RSS Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp (use-package elfeed :init (setq elfeed-db-directory "~/.local/share/elfeed")) #+END_SRC Configure Elfeed to sync with the instance of Tiny Tiny RSS I use. #+BEGIN_SRC elisp (use-package elfeed-protocol :config (setq elfeed-feeds (list (list "ttrss+https://jakob@rss.tildeverse.org" :use-authinfo t))) (elfeed-protocol-enable)) #+END_SRC * Games ** Speed Typing Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp (use-package speed-type :init (setq speed-type-gb-dir "~/.cache/emacs/speed-type/")) #+END_SRC * Programming Tools ** dumb-jump Replace =xref= keybindings instead of using the default ones, since these will get overwritten if I'm using a proper tag indexer anyway. #+BEGIN_SRC elisp (use-package dumb-jump :config (define-key dumb-jump-mode-map (kbd "C-M-g") nil) (define-key dumb-jump-mode-map (kbd "C-M-p") nil) (define-key dumb-jump-mode-map (kbd "C-M-q") nil) (define-key dumb-jump-mode-map (kbd "M-.") #'dumb-jump-go) (define-key dumb-jump-mode-map (kbd "M-,") #'dumb-jump-back) (dumb-jump-mode)) #+END_SRC ** company Start suggesting completions as soon as possible. #+BEGIN_SRC elisp (use-package company :config (setq company-idle-delay 0 company-minimum-prefix-length 3) #+END_SRC Use standard movement keys for selecting entries from the completion popup instead of those used for minibuffer next/previous. #+BEGIN_SRC elisp :bind (:map company-active-map ("M-n" . nil) ("M-p" . nil) ("C-n" . #'company-select-next) ("C-p" . #'company-select-previous))) #+END_SRC ** compile Bind a key to calling =compile=. #+BEGIN_SRC elisp (use-package compile :straight nil :bind ("" . compile) #+END_SRC Taken from [[https://www.emacswiki.org/emacs/CompileCommand][EmacsWiki]]. The compilation command can be changed by invoking =compile= with a prefix argument, so I don't see the advantage of popping a prompt every time. #+BEGIN_SRC elisp :init (setq compilation-read-command nil) #+END_SRC Hide the compilation buffer upon successful compilation. I typically don't care about the output unless there were errors. #+BEGIN_SRC elisp :config (add-hook 'compilation-finish-functions (lambda (buf strg) (let ((win (get-buffer-window buf 'visible))) (when win (delete-window win)))))) #+END_SRC ** Flycheck #+BEGIN_SRC elisp (use-package flycheck) #+END_SRC ** Magit Set up key bindings for getting to the Magit status buffer. #+BEGIN_SRC elisp (use-package magit :bind ("C-c g" . magit-status)) #+END_SRC ** Projectile Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp (use-package projectile :demand t :init (setq projectile-known-projects-file "~/.cache/emacs/projectile-bookmarks.eld" projectile-track-known-projects-automatically nil) #+END_SRC Use [[Ivy]] for Projectile commands instead of =ido=. #+BEGIN_SRC elisp :init (setq projectile-completion-system 'ivy) #+END_SRC Set up key bindings for Projectile. #+BEGIN_SRC elisp :bind ("C-c p" . projectile-command-map) #+END_SRC Enable Projectile globally. #+BEGIN_SRC elisp :config (projectile-mode +1)) #+END_SRC * Programming Languages ** Language Server Protocol The only reason I'm using =lsp-ui= is for integration with [[Flycheck]]. The features like lenses don't interest me. #+BEGIN_SRC elisp (use-package lsp-ui :init (setq lsp-ui-sideline-enable nil lsp-ui-peek-enable nil lsp-ui-doc-enable nil)) #+END_SRC Disable =lsp-mode='s default machinery. The reason I'm using the package in the first place is for its ability to integrate with everything I've set up in [[Programming Tools]]. #+BEGIN_SRC elisp (use-package company-lsp :commands company-lsp :init (setq company-lsp-cache-candidates 'auto)) (use-package lsp-mode :init (setq lsp-prefer-flymake nil lsp-enable-xref t) #+END_SRC Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp :init (setq lsp-session-file "~/.cache/emacs/.lsp-session-v1" lsp-auto-guess-root t) #+END_SRC Replace =xref= keybindings instead of using the default ones. #+BEGIN_SRC elisp :bind (:map lsp-mode-map ("M-." . lsp-find-definition) ("M-," . pop-tag-mark))) #+END_SRC ** Rust Enable flycheck. #+BEGIN_SRC elisp (use-package flycheck-rust :after rust-mode :hook (flycheck-mode . flycheck-rust-setup) (rust-mode . flycheck-mode)) #+END_SRC Enable [[company]], ElDoc, and racer. #+BEGIN_SRC elisp (use-package racer :init (setq racer-cmd "~/.cargo/bin/racer") (setq racer-rust-src-path "~/Code/rust/src") :hook (racer-mode . eldoc-mode) (racer-mode . company-mode)) (use-package rust-mode :hook (rust-mode . racer-mode) #+END_SRC Run =rustfmt= automatically. #+BEGIN_SRC elisp :init (setq rust-format-on-save t)) #+END_SRC ** C Generally, I adhere to the [[https://www.kernel.org/doc/html/v4.10/process/coding-style.html][Linux kernel coding style]]. #+BEGIN_SRC elisp (use-package cc-mode :straight nil :hook (c-mode . (lambda () (setq indent-tabs-mode t) (c-set-style "linux"))) #+END_SRC Enable [[company]], [[Flycheck]], and ElDoc, all provided by =irony-mode=. #+BEGIN_SRC elisp :hook (c-mode . company-mode) (c-mode . flycheck-mode) (c-mode . eldoc-mode)) (use-package irony :hook (c-mode . irony-mode) (irony-mode . irony-cdb-autosetup-compile-options)) (use-package company-irony :config (add-to-list 'company-backend 'company-irony) :hook (irony-mode . company-irony)) (use-package flycheck-irony :hook (flycheck-mode . flycheck-irony-setup)) (use-package irony-eldoc :hook (irony-mode . irony-eldoc)) #+END_SRC ** Emacs Lisp Enable [[company]] for both =lisp-interaction-mode= and =emacs-lisp-mode=. #+BEGIN_SRC elisp (use-package elisp-mode :straight nil :hook (lisp-interaction-mode . company-mode) (emacs-lisp-mode . company-mode) #+END_SRC Avoid omitting information when displaying deeply-nested lists. #+BEGIN_SRC elisp :init (setq eval-expression-print-level nil)) #+END_SRC Helpful is a wonderful improvement upon the vanilla =describe-.*= functions, capable of showing source code, keybindings, symbol properties, etc.n #+BEGIN_SRC elisp (use-package helpful :bind (("C-h f" . helpful-callable) ("C-h v" . helpful-variable) ("C-h k" . helpful-key) ("C-h C" . helpful-command) ("C-c C-d" . helpful-at-point))) #+END_SRC ** Common Lisp SLIME is my preferred REPL for working with Common Lisp. Set up SLIME to use sbcl. #+BEGIN_SRC elisp (use-package slime :config (setq inferior-lisp-program "/usr/bin/sbcl" slime-contribs '(slime-fancy))) #+END_SRC ** Scheme Geiser is my preferred REPL for working with Common Lisp. Set up Geiser to use CHICKEN. #+BEGIN_SRC elisp (use-package geiser :init (setq geiser-active-implementations '(chicken)) (setenv "CHICKEN_DOC_REPOSITORY" "/home/jakob/.local/share/chicken/doc/") #+END_SRC Preference of hygene. See [[Filesystem]]. #+BEGIN_SRC elisp :init (setq geiser-repl-history-filename "~/.cache/emacs/geiser_history")) #+END_SRC ** Python Set up [[company]]. #+BEGIN_SRC elisp (use-package company-jedi :hook (python-mode . company-mode) (python-mode . jedi:setup) :init (setq jedi:complete-on-dot t) (setq jedi:tooltip-show nil) (add-to-list 'company-backends 'company-jedi)) #+END_SRC ** Javascript Set up =js-mode= to interact with a [[Language Server Protocol]] daemon. #+BEGIN_SRC elisp (use-package js :straight nil :requires lsp-mode :hook (js-mode . lsp) :config (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection "~/.bin/js-ts-stdio") :major-modes '(js-mode) :server-id 'js-ts-stdio)) #+END_SRC I have yet to find a style guide I agree with, but one thing common to most of them that I _do_ agree with is that Javascript is far more readable with an indentation width of 2. #+BEGIN_SRC elisp :init (setq-default js-indent-level 2)) #+END_SRC * Post-Initialization Automatically open a buffer named =*Mind Dump*= for quickly jotting down thoughts. They're dated and saved in a directory, so I can =ag= them. This is the closest I'll ever get to being able to grep my brain. #+BEGIN_SRC elisp (defvar mind-dump-directory "~/Notes/Mind Dumps" "Directory to store dated 'mind dump' files in.") (defun mind-dump-filename () "Path for today's 'mind dump' file." (concatenate 'string (file-name-as-directory mind-dump-directory) (format-time-string "%Y-%m-%d") ".org")) (let* ((buffer (find-file-noselect (mind-dump-filename)))) (set-buffer buffer) (rename-buffer "*Mind Dump*")) #+END_SRC