#+TITLE: Core #+AUTHOR: Christopher James Hayward #+EMAIL: chris@chrishayward.xyz #+PROPERTY: header-args:emacs-lisp :tangle core.el :comments org #+PROPERTY: header-args :results silent :eval no-export :comments org #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil Minimal configuration to make Emacs usable for my own personal workflow. This does little in the ways of improving the visuals, only removing what's included by default and not required. Read more about my technique in my post [[https://chrishayward.xyz/posts/immutabe-emacs/][Immutable Emacs]][fn:1] + Packages are managed with [[https://github.com/raxod502/straight.el][straight.el]][fn:2] + Packages are installed with [[https://github.com/jwiegley/use-package][use-package]][fn:3] * Babel *Organize your plain life in plain text* [[https://orgmode.org][Org-mode]][fn:4] is one of the hallmark features of Emacs, and provides the basis for my [[https://chrishayward.xyz/notes/literate-programming/][Literate Programming]][fn:5] platform. It's essentially a markdown language with rich features for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities. + Force *straight.el*[fn:2] to ignore the local version of *Org-mode*[fn:4] #+begin_src emacs-lisp (straight-use-package '(org :local-repo nil)) #+end_src + Setup ~shell~ and ~emacs-lisp~ as *Babel Languages*[fn:4] + Configure *Structure Templates*[fn:4] for both languages #+begin_src emacs-lisp (use-package org :hook (org-mode . (lambda () (org-indent-mode) (visual-line-mode 1) (variable-pitch-mode 1))) :custom (org-ellipsis " ▾") (org-log-done 'time) (org-log-into-drawer t) (org-return-follows-link t) (org-image-actual-width nil) (org-directory dotfiles/home) (org-src-fontify-natively t) (org-src-tab-acts-natively t) (org-src-preserve-indentation t) (org-confirm-babel-evaluate nil) (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE"))) :config (require 'org-tempo) (add-to-list 'org-structure-template-alist '("s" . "src")) (add-to-list 'org-structure-template-alist '("q" . "quote")) (add-to-list 'org-structure-template-alist '("e" . "example")) (add-to-list 'org-structure-template-alist '("sh" . "src shell")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (emacs-lisp . t)))) #+end_src * Cleanup Despite having our *stateful* and *immutable* configurations seperate, it's good practice to make efforts to reduce the trash created by Emacs. Install [[https://github.com/emacs-collective/no-littering][no-littering]][fn:6] to reduce the files created by Emacs. Now that we've taken care of how it acts, we can work on how it looks. Emacs' default user interface is *horrendous*, let's do something about that. Emacs has a long history of running on machines without gigabytes of available memory, let it realize its full potential by increasing the garbage collection threshold. #+begin_src emacs-lisp (use-package no-littering :custom (inhibit-startup-message t) (initial-scratch-message "") (comp-deferred-compilation t) (custom gc-cons-threshold most-positive-fixnum) :config (global-prettify-symbols-mode) (when (fboundp 'tooltip-mode) (tooltip-mode -1)) (when (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (when (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))) #+end_src * Methods Define some helper methods to use throughout the configuration. ** Tangle directory Build all of the *Org*[fn:4] files within a given directory, recursively. #+begin_src emacs-lisp (defun dotfiles/tangle (dir) "Recursively tangle the Org files within a directory." (let ((org-files (directory-files-recursively dir "org"))) (dolist (f org-files) (org-babel-tangle-file f)))) #+end_src ** Force symbolic links Function that takes in a system and configuration file path, checks to see if the system file doesn't exist, or doesn't point to the configuration file, deleting it for the latter, then creating a symbolic link to the configuration file in place. #+begin_src emacs-lisp (defun dotfiles/symlink (src tgt) "Forces a symlink from `src' to `tgt'." (let ((sys-file (expand-file-name tgt)) (dot-file (expand-file-name src))) (when (or (not (file-exists-p sys-file)) (not (equal (file-symlink-p sys-file) dot-file))) (delete-file sys-file) (make-symbolic-link dot-file sys-file)))) #+end_src * Resources [fn:1] https://chrishayward.xyz/posts/immutable-emacs/ [fn:2] https://github.com/raxod502/straight.el [fn:3] https://github.com/jwiegley/use-package [fn:4] https://orgmode.org [fn:5] https://chrishayward.xyz/notes/literate-programming/ [fn:6] https://github.com/emacs-collective/no-littering