Welcome to my Emacs configuration! This file contains the code along with documentation for customizing my Emacs with all the options that I prefer to use by default.
This file was written using Emacs Org Mode. This makes navigating and modifying my Emacs configuration much simpler as I can place different elements of my configuration under separate headings. The code in this file is placed in source code blocks that are tangled to the init.el
file that Emacs will look for upon starting. When this file is saved, the source code blocks that are marked for tangling will write their contents to init.el
.
Tags are used in this document to help make navigation of the packages easier and to provide additional information about piecing together this Emacs configuration. Below are descriptions of the tags and their meanings:
- deprecated
- This package has been “deprecated” in favor of another package that better integrates with this Emacs configuration or produces a better workflow.
- disabled
- Any package marked with this tag has been disabled due to it causing issues or the package was deprecated.
- GUIX
- Packages managed by GUIX are marked with this tag. There are a number of reasons why a package might be managed by GUIX over using package managers in Emacs:
- The package requires compilation on the host system (e.g. Pdf Tools and Org-roam). Using the GUIX package manager will manage the compilation automatically. Also, packages that need to be compiled are difficult to run on portable Emacs so they will be left out when Emacs is used as a portable app.
- The package is only run on a Linux System with GUIX installed or on the GUIX System Distribution so there is no need to have Emacs manage this package.
- The package relies on another program installed on the host system (e.g. Mu4e requires Mu).
- testing
- A package or function that is added and is being tested for use is marked with this tag.
- Windows
- Customizations exclusively for the use on the Windows operating system are marked with this tag.
The following code block will add a header to the init.el
file when it is generated on saving:
;;; init.el --- Emacs initialization file -*- lexical-binding: t -*-
;; Copyright (C) 2022-2024 Thomas Freeman
;; Author: Thomas Freeman
;; Maintainer: Thomas Freeman
;; Keywords: lisp
;; Version: 0.0.1
;; Created: 09 Jan 2022
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file is an init file for Emacs.
;;
;; This file is NOT a part of Emacs.
;;
;; This file IS NOT intended to be edited! It was generated by init.org.
;;; URL: https://github.com/tfree87/.emacs.d
;; For documentation and for editing this file, see the init.org in the
;; github repository tfree87/.emacs.d
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
to slightly reduce the load time for Emacs, the whole init.el
file can be wrapped in the following let statement. See this Reddit post for more information.
(let ((file-name-handler-alist nil))
All of this Emacs configuration is in modules. The modules
directory and all of its sub-directories must be added to the Emacs load-path
.
(let ((default-directory "~/.emacs.d/modules/"))
(normal-top-level-add-subdirs-to-load-path))
I like to use Emacs at work and at home to boost my productivity, but I often find when I am at work or using another computer using Windows and I cannot always install Emacs to the host system. In this case, I run Emacs from a USB thumb drive so that I can still have access to the power of Emacs even when I am not working on my home personal computer. Running Emacs from a thumb drive has some caveats. For instance, if you are running Emacs from a thumb drive on a work computer and you do not have administrator access, then a lot of features will break. This section contains code that can be used to run Emacs.
When runemacs.bat is executed, it will set the environment variable EMACS_PORTABLE
to “Y”. By checking for this, we can tell that Emacs that it was executed to be run from a flash drive.
(defun freemacs/isportable-p ()
"A function to check whether Emacs was executed as a portable application in Windows by the runemacs.bat script."
(string= (getenv "EMACS_PORTABLE") "Y"))
Straight.el cannot operate without access to Git. Luckily, there is a portable version of Git (sheabunge/GitPortable) for Windows that can be installed on the PortableApp platform to provide access to Git without having it installed on the host system. After downloading GitPortable, we need to tell Emacs where it can find the binary executable so that Emacs programs can call Git when needed.
The following line code will check to see if Emacs is being run as a portable app and, if it is, then add the path where git.exe can be found to the exec-path
list:
(when (freemacs/isportable-p)
(add-to-list 'exec-path "~/PortableApps/GitPortable/App/Git/bin"))
Place custom variables in ./custom.el rather than ./init.el.
(setq custom-file "~/.emacs.d/custom.el")
Load the custom variables (Emacs customize interface) file. This needs to be done early in the loading process because it contains the addresses for the package repositories.
(load custom-file)
Packages in the this section need to be initializaed before all others.
Instead of the built-in package manager, use straight.el to pull all the packages straight from their repositories.
(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))
Use straight.el
to install use-package
to manage Emacs packages.
(straight-use-package 'use-package)
Set Straight to be configured the default manager for use-package~
.
(setq straight-use-package-by-default t)
Use benchmark-init to check the time that it takes to load Emacs.
(require 'freemacs-benchmark-init)
Load the No Littering module.
(require 'freemacs-no-littering)
Load the Whicher module.
(require 'freemacs-whicher)
Changes to the default settings of Emacs from the the defaults module.
(require 'freemacs-defaults)
Load the Aggressive Indent module.
(require 'freemacs-aggressive-indent)
Load the Centered Window module.
(require 'freemacs-cwm)
Load the coding module.
(require 'freemacs-project)
(require 'freemacs-coding)
(require 'freemacs-autohotkey)
Load the Embark module
(require 'freemacs-embark)
Load the Cape module.
(require 'freemacs-cape)
Load the Consult module.
(require 'freemacs-consult)
Load the Corfu module
(require 'freemacs-corfu)
Load the the docker module.
(require 'freemacs-docker)
Load the YASnippet module.
(require 'freemacs-yasnippet)
Load the Elfeed Module.
(require 'freemacs-elfeed)
; (require 'freemacs-elfeed-protocol)
Load the Dired module.
(require 'freemacs-dired)
Load the Dirvish Module.
(require 'freemacs-dirvish)
Load the Trashed Module.
(require 'freemacs-trashed)
Load the graphing module.
(require 'freemacs-graphing)
Load the Ledger module.
(require 'freemacs-ledger)
Loadt the Marginalia module.
(require 'freemacs-marginalia)
Load the Meow Mode module.
(require 'freemacs-meow)
Load the Orderless module.
(require 'freemacs-orderless)
Load the Org Mode module.
(require 'freemacs-org)
Load the Org Contacts Module.
(require 'freemacs-org-contacts)
Load the Org Mind Map module/
(require 'freemacs-org-mm)
Load the Org Ql Module.
(require 'freemacs-org-ql)
Load the Org Super Links module.
(require 'freemacs-orgsl)
ox-publish.el
makes it easy to create multi-page websites from Org Mode files by defining a publishing project. The configuration for this package can be found in the ox-publish module.
(require 'freemacs-ox-publish)
Load the Session Module.
(require 'freemacs-session)
Load the Eshell Module.
(require 'freemacs-eshell)
Load the Eat Module.
(require 'freemacs-eat)
Load the completion module
(require 'freemacs-vertico)
Load the Vterm Module.
(require 'freemacs-vterm)
Load the Theme Module.
(require 'freemacs-theme)
Load the Nerd Icons module.
(require 'freemacs-nerd-icons)
The academic writing module contains configurations to improve the environment for writing academic papers in Emacs. It contains configuration for the following packages:
- Academic Phrases
- A package that inserts common template phrases into academic papers
- Citar
- A citation tool that simplifies adding citations to documents
- Org Cite
- The built-in Org Mode citation management system
(require 'freemacs-academic-writing)
The spellchecking module configures the spell checking environment in Emacs. A few of the changes made:
- Flyspell is on be default so that you do not need to remember to call
ispell
. - Hunspell is used as the default spellchecking backend as it is more modern and works on multiple operating systems.
(require 'freemacs-spellcheck)
Configuration for working with \LaTeX documents can be found in the \LaTeX{} module.
(require 'freemacs-latex)
Load the Markdown module.
(require 'freemacs-markdown)
To improve the speed and to extend the ability to view PDF files in Emacs, the PDF module can be loaded.
(require 'freemacs-pdf)
The help module contains configuration that adds additional tools for help tools in Emacs:
(require 'freemacs-help)
Load the YouTube Module.
(require 'freemacs-youtube)
Load the server module.
(require 'freemacs-server)
Close off the let
statement at the beginning of the init file.
(setq gc-cons-threshold 800000)
)
Add a final comment to indicate the end of the file.
(provide 'init)
;;; init.el ends here