emacs/init.el

52 lines
1.9 KiB
EmacsLisp
Raw Normal View History

2021-02-23 18:17:33 +00:00
;;; init.el -*- lexical-binding: t; coding: utf-8 -*-
;; Copyright (C) 2020 Case Duckworth
;; Author: Case Duckworth <acdw@acdw.net>
;; Created: Sometime during the Covid-19 lockdown, 2019
;; Keywords: configuration
;; URL: https://tildegit.org/acdw/emacs
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This file is automatically tangled from config.org.
;; Hand edits will be overwritten!
;;; Code:
(setq-default load-prefer-newer t)
(message "%s..." "Loading init.el")
2021-02-23 18:17:33 +00:00
(let* (;; Speed up init
(gc-cons-threshold most-positive-fixnum)
;; (gc-cons-percentage 0.6)
(file-name-handler-alist nil)
;; Config file names
(config (expand-file-name "config"
2021-02-25 23:53:46 +00:00
user-emacs-directory))
2021-02-23 18:17:33 +00:00
(config.el (concat config ".el"))
(config.org (concat config ".org"))
(straight-org-dir (locate-user-emacs-file "straight/build/org")))
;; Okay, let's figure this out.
;; `and' evaluates each form, and returns nil on the first that
;; returns nil. `unless' only executes its body if the test
;; returns nil. So.
;; 1. Test if config.org is newer than config.el. If it is (t), we
;; *want* to evaluate the body, so we need to negate that test.
;; 2. Try to load the config. If it errors (nil), it'll bubble that
;; to the `and' and the body will be evaluated.
(unless (and (not (file-newer-than-file-p config.org config.el))
2021-02-25 23:53:46 +00:00
(load config :noerror))
2021-02-23 18:17:33 +00:00
;; A plain require here just loads the older `org'
;; in Emacs' install dir. We need to add the newer
;; one to the `load-path', hopefully that's all.
(when (file-exists-p straight-org-dir)
(add-to-list 'load-path straight-org-dir))
;; Load config.org
(message "%s..." "Loading config.org")
(require 'org)
(org-babel-load-file config.org)
(message "%s... Done" "Loading config.org")))
(message "%s... Done." "Loading init.el")
2021-02-23 18:17:33 +00:00
;;; init.el ends here