Skip to content

Latest commit

 

History

History
445 lines (369 loc) · 17.5 KB

init.org

File metadata and controls

445 lines (369 loc) · 17.5 KB

Emacs Configuration


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.

About this Document

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

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:
  1. 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.
  2. 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.
  3. 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.

Header for init.el

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:

Performance Optimization Start

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))

Load Path

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))

Running Emacs as a Portable App

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.

Check for Portable Emacs Instance

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"))

Set Location of Portable Git

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"))

Custom Set Variables

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)

Startup Packags

Packages in the this section need to be initializaed before all others.

Straight.el

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))

Install use-package

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)

Benchmark Init

Use benchmark-init to check the time that it takes to load Emacs.

(require 'freemacs-benchmark-init)

No-littering

Load the No Littering module.

(require 'freemacs-no-littering)

Whicher

Load the Whicher module.

(require 'freemacs-whicher)

Emacs Defaults

Changes to the default settings of Emacs from the the defaults module.

(require 'freemacs-defaults)

Other Packages

Aggressive Indent

Load the Aggressive Indent module.

(require 'freemacs-aggressive-indent)

Centered-Window Mode

Load the Centered Window module.

(require 'freemacs-cwm)

Coding

Load the coding module.

(require 'freemacs-project)

(require 'freemacs-coding)

(require 'freemacs-autohotkey)

Embark

Load the Embark module

(require 'freemacs-embark)

Cape

Load the Cape module.

(require 'freemacs-cape)

Consult

Load the Consult module.

(require 'freemacs-consult)

Corfu

Load the Corfu module

(require 'freemacs-corfu)

Docker

Load the the docker module.

(require 'freemacs-docker)

YASnippet

Load the YASnippet module.

(require 'freemacs-yasnippet)

Elfeed

Load the Elfeed Module.

(require 'freemacs-elfeed)
;  (require 'freemacs-elfeed-protocol)

Dired

Load the Dired module.

(require 'freemacs-dired)

Dirvish

Load the Dirvish Module.

(require 'freemacs-dirvish)

Trashed

Load the Trashed Module.

(require 'freemacs-trashed)

Graphing

Load the graphing module.

(require 'freemacs-graphing)

Ledger

Load the Ledger module.

(require 'freemacs-ledger)

Marginalia

Loadt the Marginalia module.

(require 'freemacs-marginalia)

Meow Mode

Load the Meow Mode module.

(require 'freemacs-meow)

Orderless

Load the Orderless module.

(require 'freemacs-orderless)

Org

Load the Org Mode module.

(require 'freemacs-org)

Org Contacts

Load the Org Contacts Module.

(require 'freemacs-org-contacts)

Org Mind Map

Load the Org Mind Map module/

(require 'freemacs-org-mm)

Org-QL

Load the Org Ql Module.

(require 'freemacs-org-ql)

Org Super Links

Load the Org Super Links module.

(require 'freemacs-orgsl)

Ox-publish

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)

Session

Load the Session Module.

(require 'freemacs-session)

Eshell

Load the Eshell Module.

(require 'freemacs-eshell)

Eat

Load the Eat Module.

(require 'freemacs-eat)

Vertico

Load the completion module

(require 'freemacs-vertico)

VTerm

Load the Vterm Module.

(require 'freemacs-vterm)

Theme style

Load the Theme Module.

(require 'freemacs-theme)

Nerd Icons

Load the Nerd Icons module.

(require 'freemacs-nerd-icons)

Academic Writing

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)

Spellchecking

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)

\LaTeX{}

Configuration for working with \LaTeX documents can be found in the \LaTeX{} module.

(require 'freemacs-latex)

Markdown

Load the Markdown module.

(require 'freemacs-markdown)

PDF

To improve the speed and to extend the ability to view PDF files in Emacs, the PDF module can be loaded.

(require 'freemacs-pdf)

Help

The help module contains configuration that adds additional tools for help tools in Emacs:

(require 'freemacs-help)

YouTube

Load the YouTube Module.

(require 'freemacs-youtube)

Emacs Server

Load the server module.

(require 'freemacs-server)

Custom Functions

Performance Optimization End

Close off the let statement at the beginning of the init file.

(setq gc-cons-threshold 800000)
)

End

Add a final comment to indicate the end of the file.

(provide 'init)

;;; init.el ends here