Browse Source

Cleanup initialization

main
parent
commit
15b5341237
  1. 291
      README.org
  2. 161
      init.el

291
README.org

@ -40,114 +40,45 @@ Launch emacs: ~emacs -mm --debug-init~
** Options
Here's a complete list of all of the options configurable for each host, and their default values. If a host configuration does not exist, the default values will remain.
Configure the system font with a single ~font-family~ and define the size, of which variations to the font size are relative to this value.
#+begin_src emacs-lisp
(defvar dotfiles/font
"Fira Code"
"Unified system font family, used on all font faces.")
(defvar dotfiles/font-size
96
"Unified font size, of which all variations are relative to.")
#+end_src
Used by the desktop module to find the appropriate browser.
#+begin_src emacs-lisp
(defvar dotfiles/browser
(getenv "BROWSER")
"The default browser used by the system.")
#+end_src
Used by the writing module to determine the system language.
#+begin_src emacs-lisp
(defvar dotfiles/language
(getenv "LANG")
"The default system language.")
#+end_src
All of the available modules defined in the ~dotfiles/modules-available~ constant.
#+begin_src emacs-lisp
(defconst dotfiles/modules-available
'(core editor desktop writing projects interface)
"All of the available modules for hosts to load.")
#+end_src
Add the modules you want to initialize to the ~dotfiles/modules~ variable.
#+begin_src emacs-lisp
(defvar dotfiles/modules
dotfiles/modules-available
"Enabled modules, modify this in your host configuration.")
#+end_src
Specify the emacs home, and the cache directory.
#+begin_src emacs-lisp
(defvar dotfiles/home
user-emacs-directory
"Original value of `user-emacs-directory'.")
#+end_src
Used to seperate the immutable configuration from the stateful package files.
#+begin_src emacs-lisp
(defvar dotfiles/cache
(expand-file-name "~/.cache/emacs")
"Where `user-emacs-directory' redirects to.")
#+end_src
Functionality like =completion= and =hints= delayed to avoid popups for common manuevers.
#+begin_src emacs-lisp
(defvar dotfiles/idle
0.0
"Length of time to wait before offering completions.")
#+end_src
Required for the all powerful leader key.
#+begin_src emacs-lisp
(defvar dotfiles/leader-key
"SPC"
"Custom leader key for custom actions.")
#+end_src
The desktop module requires the global leader key set.
#+begin_src emacs-lisp
(defvar dotfiles/leader-key-global
(concat "C-" dotfiles/leader-key)
"Global leader key available everywhere.")
#+end_src
Define where the source repositories exist on disk, for integration with the projects module.
#+begin_src emacs-lisp
(defvar dotfiles/projects
(expand-file-name "~/.local/source/")
"Location where source code projects exist on disk.")
#+end_src
Where the password store exists on disk.
#+begin_src emacs-lisp
(defvar dotfiles/passwords
(expand-file-name "~/.password-store/")
"Directory containing the password store.")
#+end_src
Configure the public GPG key that Emacs will encrypt files to.
#+begin_src emacs-lisp
(defvar dotfiles/public-key
"37AB1CB72B741E478CA026D43025DCBD46F81C0F"
"Public PGP key that Emacs will encrypt files to.")
Here's a complete list of all of the options configurable for each host, and their default values. Override any of these configurations in a host file. All of the values are prefixed with ~dotfiles/~. If you need to make configurations to another variable, consider creating a new option. Here are a few examples to get started:
+ [[file:hosts/localhost.org][Termux]]
+ [[file:hosts/raspberry.org][Raspberry]]
+ [[file:hosts/acernitro.org][Acernitro]]
+ [[file:hosts/virtualbox.org][Virtualbox]]
| Name | Description |
|----------------------------+---------------------------------------------------|
| dotfiles/font | Unified system font family |
| dotfiles/font-size | System wide base font size |
| dotfiles/browser | Browser to open URL links |
| dotfiles/language | Dictionary language to load |
| dotfiles/modules-p | Immutable list of all available modules |
| dotfiles/modules | Enabled custom modules |
| dotfiles/home | Original value of `user-emacs-directory' |
| dotfiles/cache | Redirection target of `user-emacs-directory |
| dotfiles/idle | Delay time before offering completions |
| dotfiles/leader-key | All powerful keybinding prefix for custom actions |
| dotfiles/leader-key-global | Like the leader-key, but EVERYWHERE! |
| dotfiles/projects | Location of source code projects |
| dotfiles/passwords | Location of the system password store |
| dotfiles/public-key | Public GPG key to encrypt files for |
#+begin_src emacs-lisp
(defvar dotfiles/font "Fira Code")
(defvar dotfiles/font-size 96)
(defvar dotfiles/browser (getenv "BROWSER"))
(defvar dotfiles/language (getenv "LANG"))
(defconst dotfiles/modules-p '(core editor desktop writing projects interface))
(defvar dotfiles/modules dotfiles/modules-p)
(defvar dotfiles/home user-emacs-directory)
(defvar dotfiles/cache (expand-file-name "~/.cache/emacs"))
(defvar dotfiles/idle 0.0)
(defvar dotfiles/leader-key "SPC")
(defvar dotfiles/leader-key-global (concat "C-" dotfiles/leader-key))
(defvar dotfiles/projects (expand-file-name "~/.local/source/"))
(defvar dotfiles/passwords (expand-file-name "~/.password-store/"))
(defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F")
#+end_src
** Startup
@ -160,7 +91,7 @@ The host configuration tangles, and loads (if it exist) using the systems name.
(org-babel-load-file host-file)))
#+end_src
Build and load all of the enabled modules.
Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundamental requirement to achieve the goal of modularity.
#+begin_src emacs-lisp
(dolist (m dotfiles/modules)
@ -171,148 +102,6 @@ Build and load all of the enabled modules.
* Modules
Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundamental requirement to achieve the goal of modularity. Incorporating just the =core= module on a build server to build literate programming projects is just one example.
** Core
:PROPERTIES:
:header-args: :tangle modules/core.el
:END:
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 [[file:docs/posts/immutable-emacs.org.gpg][Immutable Emacs]].
*** Startup
Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory. How can we solve this issue? Shortly after initialization, before most packages load, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post [[https://chrishayward.xyz/posts/immutable-emacs/][Immutable Emacs]].
#+begin_src emacs-lisp
(setq user-emacs-directory dotfiles/cache)
#+end_src
Because this project uses version-control, we can disable more unwanted features:
+ Lock files
+ Backup files
#+begin_src emacs-lisp
(setq create-lockfiles nil
make-backup-files nil)
#+end_src
*** Packages
Download and install packages using [[https://github.com/raxod502/straight.el][straight.el]], a functional package manager that integrates with =use-package=, giving us more control over sourcing our packages.
+ Use the development branch
+ Integrate with ~use-package~
Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
#+begin_src emacs-lisp
(setq straight-repository-branch "develop"
straight-use-package-by-default t)
#+end_src
Bootstrap the package manager, downloading, installing, or configuring depending on the state of the configuration. All packages build from source, pinned to specific git commit hashes.
#+begin_src emacs-lisp
(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
Complete the integration with ~use-package~ by installing it with =straight=.
#+begin_src emacs-lisp
(straight-use-package 'use-package)
#+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/emacscollective/no-littering][no-littering]] to reduce the files created by Emacs.
#+begin_src emacs-lisp
(use-package no-littering)
#+end_src
Emacs' default user interface is *horrendous*, let's do something about that.
#+begin_src emacs-lisp
(setq inhibit-startup-message t
initial-scratch-message "")
(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
Emacs has a long history of running on machines without gigabytes of available memory, let it realize its full potential! Just kidding, it just smashes *CPU0*.
#+begin_src emacs-lisp
(setq gc-cons-treshold most-positive-fixnum
gnutls-min-prime-bits 4096)
#+end_src
*** Babel
*Organize your plain life in plain text*
[[https://orgmode.org][Org-mode]] is one of the hallmark features of Emacs, and provides the basis for my Literate Programming 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.
+ [[https://orgmode.org/worg/org-contrib/babel/languages/index.html][Babel languages]]
+ [[https://orgmode.org/manual/Structure-Templates.html][Structure templates]]
#+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
Build all of the =org= files within a given directory.
#+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
** Editor
:PROPERTIES:
:header-args: :tangle modules/editor.el

161
init.el

@ -1,125 +1,44 @@
;; Options
;; Here's a complete list of all of the options configurable for each host, and their default values. If a host configuration does not exist, the default values will remain.
;; Configure the system font with a single ~font-family~ and define the size, of which variations to the font size are relative to this value.
(defvar dotfiles/font
"Fira Code"
"Unified system font family, used on all font faces.")
(defvar dotfiles/font-size
96
"Unified font size, of which all variations are relative to.")
;; Used by the desktop module to find the appropriate browser.
(defvar dotfiles/browser
(getenv "BROWSER")
"The default browser used by the system.")
;; Used by the writing module to determine the system language.
(defvar dotfiles/language
(getenv "LANG")
"The default system language.")
;; All of the available modules defined in the ~dotfiles/modules-available~ constant.
(defconst dotfiles/modules-available
'(core editor desktop writing projects interface)
"All of the available modules for hosts to load.")
;; Add the modules you want to initialize to the ~dotfiles/modules~ variable.
(defvar dotfiles/modules
dotfiles/modules-available
"Enabled modules, modify this in your host configuration.")
;; Specify the emacs home, and the cache directory.
(defvar dotfiles/home
user-emacs-directory
"Original value of `user-emacs-directory'.")
;; Used to seperate the immutable configuration from the stateful package files.
(defvar dotfiles/cache
(expand-file-name "~/.cache/emacs")
"Where `user-emacs-directory' redirects to.")
;; Functionality like =completion= and =hints= delayed to avoid popups for common manuevers.
(defvar dotfiles/idle
0.0
"Length of time to wait before offering completions.")
;; Required for the all powerful leader key.
(defvar dotfiles/leader-key
"SPC"
"Custom leader key for custom actions.")
;; The desktop module requires the global leader key set.
(defvar dotfiles/leader-key-global
(concat "C-" dotfiles/leader-key)
"Global leader key available everywhere.")
;; Define where the source repositories exist on disk, for integration with the projects module.
(defvar dotfiles/projects
(expand-file-name "~/.local/source/")
"Location where source code projects exist on disk.")
;; Where the password store exists on disk.
(defvar dotfiles/passwords
(expand-file-name "~/.password-store/")
"Directory containing the password store.")
;; Configure the public GPG key that Emacs will encrypt files to.
(defvar dotfiles/public-key
"37AB1CB72B741E478CA026D43025DCBD46F81C0F"
"Public PGP key that Emacs will encrypt files to.")
;; Here's a complete list of all of the options configurable for each host, and their default values. Override any of these configurations in a host file. All of the values are prefixed with ~dotfiles/~. If you need to make configurations to another variable, consider creating a new option. Here are a few examples to get started:
;; + [[file:hosts/localhost.org][Termux]]
;; + [[file:hosts/raspberry.org][Raspberry]]
;; + [[file:hosts/acernitro.org][Acernitro]]
;; + [[file:hosts/virtualbox.org][Virtualbox]]
;; | Name | Description |
;; |----------------------------+---------------------------------------------------|
;; | dotfiles/font | Unified system font family |
;; | dotfiles/font-size | System wide base font size |
;; | dotfiles/browser | Browser to open URL links |
;; | dotfiles/language | Dictionary language to load |
;; | dotfiles/modules-p | Immutable list of all available modules |
;; | dotfiles/modules | Enabled custom modules |
;; | dotfiles/home | Original value of `user-emacs-directory' |
;; | dotfiles/cache | Redirection target of `user-emacs-directory |
;; | dotfiles/idle | Delay time before offering completions |
;; | dotfiles/leader-key | All powerful keybinding prefix for custom actions |
;; | dotfiles/leader-key-global | Like the leader-key, but EVERYWHERE! |
;; | dotfiles/projects | Location of source code projects |
;; | dotfiles/passwords | Location of the system password store |
;; | dotfiles/public-key | Public GPG key to encrypt files for |
(defvar dotfiles/font "Fira Code")
(defvar dotfiles/font-size 96)
(defvar dotfiles/browser (getenv "BROWSER"))
(defvar dotfiles/language (getenv "LANG"))
(defconst dotfiles/modules-p '(core editor desktop writing projects interface))
(defvar dotfiles/modules dotfiles/modules-p)
(defvar dotfiles/home user-emacs-directory)
(defvar dotfiles/cache (expand-file-name "~/.cache/emacs"))
(defvar dotfiles/idle 0.0)
(defvar dotfiles/leader-key "SPC")
(defvar dotfiles/leader-key-global (concat "C-" dotfiles/leader-key))
(defvar dotfiles/projects (expand-file-name "~/.local/source/"))
(defvar dotfiles/passwords (expand-file-name "~/.password-store/"))
(defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F")
;; Startup
@ -132,7 +51,7 @@
;; Build and load all of the enabled modules.
;; Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundamental requirement to achieve the goal of modularity.
(dolist (m dotfiles/modules)

Loading…
Cancel
Save