diff options
author | Ashley Duckworth | 2021-01-22 13:07:59 -0600 |
---|---|---|
committer | Ashley Duckworth | 2021-01-22 13:07:59 -0600 |
commit | 679b0c30dc13a813762bae505bef9ac6911e87c4 (patch) | |
tree | 24e92c3cbfea10b4d4768d47c0276e0f492748a5 | |
parent | Reorganize early-init and init and add comments (diff) | |
download | emacs-679b0c30dc13a813762bae505bef9ac6911e87c4.tar.gz emacs-679b0c30dc13a813762bae505bef9ac6911e87c4.zip |
Finally sort out the config.org/el loading thing
-rw-r--r-- | config.org | 35 | ||||
-rw-r--r-- | early-init.el | 22 | ||||
-rw-r--r-- | init.el | 68 |
3 files changed, 75 insertions, 50 deletions
diff --git a/config.org b/config.org index d99c918..8945ab1 100644 --- a/config.org +++ b/config.org | |||
@@ -1559,18 +1559,29 @@ the needed boolean expression to tangle config.org. Booleans, yall! | |||
1559 | (config.org (concat config ".org")) | 1559 | (config.org (concat config ".org")) |
1560 | (straight-org-dir (expand-file-name "straight/build/org" | 1560 | (straight-org-dir (expand-file-name "straight/build/org" |
1561 | user-emacs-directory))) | 1561 | user-emacs-directory))) |
1562 | (unless (load config 'no-error)) | 1562 | ;; Okay, let's figure this out. |
1563 | ;; A plain require here just loads the older `org' | 1563 | ;; `and' evaluates each form, and returns nil on the first that |
1564 | ;; in Emacs' install dir. We need to add the newer | 1564 | ;; returns nil. `unless' only executes its body if the test |
1565 | ;; one to the `load-path', hopefully that's all. | 1565 | ;; returns nil. So. |
1566 | (when (file-exists-p straight-org-dir) | 1566 | ;; 1. Test if config.org is newer than config.el. If it is (t), we |
1567 | (add-to-list 'load-path straight-org-dir)) | 1567 | ;; *want* to evaluate the body, so we need to negate that test. |
1568 | ;; Load config.org | 1568 | ;; 2. Try to load the config. If it errors (nil), it'll bubble that |
1569 | (require 'org) | 1569 | ;; to the `and' and the body will be evaluated. |
1570 | (org-babel-load-file config.org :compile)) | 1570 | (unless (and (not (file-newer-than-file-p config.org config.el)) |
1571 | #+end_src | 1571 | (load config :noerror)) |
1572 | 1572 | ;; A plain require here just loads the older `org' | |
1573 | *** early-init.el | 1573 | ;; in Emacs' install dir. We need to add the newer |
1574 | ;; one to the `load-path', hopefully that's all. | ||
1575 | (when (file-exists-p straight-org-dir) | ||
1576 | (add-to-list 'load-path straight-org-dir)) | ||
1577 | ;; Load config.org | ||
1578 | (require 'org) | ||
1579 | (org-babel-load-file config.org))) | ||
1580 | |||
1581 | ;;; init.el ends here | ||
1582 | #+end_src | ||
1583 | |||
1584 | ** early-init.el | ||
1574 | :PROPERTIES: | 1585 | :PROPERTIES: |
1575 | :header-args: :tangle early-init.el :noweb yes | 1586 | :header-args: :tangle early-init.el :noweb yes |
1576 | :END: | 1587 | :END: |
diff --git a/early-init.el b/early-init.el index 5ebc544..f9486ff 100644 --- a/early-init.el +++ b/early-init.el | |||
@@ -1,16 +1,30 @@ | |||
1 | ;; early-init.el -*- no-byte-compile: t; -*- | 1 | ;;; early-init.el -*- no-byte-compile: t; -*- |
2 | ;; Copyright (C) 2020 Case Duckworth | ||
3 | |||
4 | ;; Author: Case Duckworth <acdw@acdw.net> | ||
5 | ;; Created: Sometime during the Covid-19 lockdown, 2019 | ||
6 | ;; Keywords: configuration | ||
7 | ;; URL: https://tildegit.org/acdw/emacs | ||
8 | |||
9 | ;; This file is not part of GNU Emacs. | ||
10 | |||
11 | ;;; Commentary: | ||
2 | ;; This file is automatically tangled from config.org. | 12 | ;; This file is automatically tangled from config.org. |
3 | ;; Hand edits will be overwritten! | 13 | ;; Hand edits will be overwritten! |
14 | |||
15 | ;;; Code: | ||
16 | |||
4 | ;; BOOTSTRAP PACKAGE MANAGEMENT | 17 | ;; BOOTSTRAP PACKAGE MANAGEMENT |
5 | (let ((win-app-dir "~/Applications")) | 18 | (let ((win-app-dir "~/Applications")) |
6 | (dolist (path (list | 19 | (dolist (path (list |
7 | ;; Windows | 20 | ;; Windows |
21 | (expand-file-name "exe" win-app-dir) | ||
8 | (expand-file-name "Git/bin" win-app-dir) | 22 | (expand-file-name "Git/bin" win-app-dir) |
9 | (expand-file-name "Git/usr/bin" win-app-dir) | 23 | (expand-file-name "Git/usr/bin" win-app-dir) |
10 | (expand-file-name "Git/mingw64/bin" win-app-dir) | 24 | (expand-file-name "Git/mingw64/bin" win-app-dir) |
25 | (expand-file-name "Everything" win-app-dir) | ||
11 | ;; Linux | 26 | ;; Linux |
12 | (expand-file-name "bin" | 27 | (expand-file-name "bin" user-emacs-directory) |
13 | user-emacs-directory) | ||
14 | (expand-file-name "~/bin") | 28 | (expand-file-name "~/bin") |
15 | (expand-file-name "~/.local/bin") | 29 | (expand-file-name "~/.local/bin") |
16 | (expand-file-name "~/Scripts") | 30 | (expand-file-name "~/Scripts") |
@@ -68,3 +82,5 @@ | |||
68 | (horizontal-scroll-bar-mode -1) | 82 | (horizontal-scroll-bar-mode -1) |
69 | (setq-default frame-inhibit-implied-resize t | 83 | (setq-default frame-inhibit-implied-resize t |
70 | frame-resize-pixelwise t) | 84 | frame-resize-pixelwise t) |
85 | |||
86 | ;;; early-init.el ends here | ||
diff --git a/init.el b/init.el index 332468c..1ddb5f9 100644 --- a/init.el +++ b/init.el | |||
@@ -1,33 +1,20 @@ | |||
1 | ;; init.el -*- lexical-binding: t -*- | 1 | ;;; init.el -*- lexical-binding: t -*- |
2 | ;; This file is automatically tangled from config.org. | 2 | ;; Copyright (C) 2020 Case Duckworth |
3 | ;; Hand edits will be overwritten! | ||
4 | 3 | ||
5 | (setq-default load-prefer-newer t) | 4 | ;; Author: Case Duckworth <acdw@acdw.net> |
5 | ;; Created: Sometime during the Covid-19 lockdown, 2019 | ||
6 | ;; Keywords: configuration | ||
7 | ;; URL: https://tildegit.org/acdw/emacs | ||
8 | |||
9 | ;; This file is not part of GNU Emacs. | ||
6 | 10 | ||
7 | (defmacro when-at (conditions &rest commands) | 11 | ;;; Commentary: |
8 | "Run COMMANDS, or let the user know, when at a specific place. | 12 | ;; This file is automatically tangled from config.org. |
13 | ;; Hand edits will be overwritten! | ||
9 | 14 | ||
10 | CONDITIONS are one of `:work', `:home', or a list beginning with | 15 | ;;; Code: |
11 | those and other conditions to check. COMMANDS are only run if | ||
12 | all CONDITIONS are met. | ||
13 | 16 | ||
14 | If COMMANDS is empty or nil, simply return the result of CONDITIONS." | 17 | (setq-default load-prefer-newer t) |
15 | (declare (indent 1)) | ||
16 | (let ((at-work '(memq system-type '(ms-dos windows-nt))) | ||
17 | (at-home '(memq system-type '(gnu gnu/linux gnu/kfreebsd)))) | ||
18 | (pcase conditions | ||
19 | (:work (if commands `(when ,at-work ,@commands) at-work)) | ||
20 | (:home (if commands `(when ,at-home ,@commands) at-home)) | ||
21 | ((guard (eq (car conditions) :work)) | ||
22 | (if commands | ||
23 | `(when (and ,at-work ,@(cdr conditions)) | ||
24 | ,@commands) | ||
25 | `(and ,at-work ,@(cdr conditions)))) | ||
26 | ((guard (eq (car conditions) :home)) | ||
27 | (if commands | ||
28 | `(when (and ,at-home ,@(cdr conditions)) | ||
29 | ,@commands) | ||
30 | `(and ,at-work ,@(cdr conditions))))))) | ||
31 | 18 | ||
32 | (let* (;; Speed up init | 19 | (let* (;; Speed up init |
33 | (gc-cons-threshold most-positive-fixnum) | 20 | (gc-cons-threshold most-positive-fixnum) |
@@ -39,12 +26,23 @@ If COMMANDS is empty or nil, simply return the result of CONDITIONS." | |||
39 | (config.org (concat config ".org")) | 26 | (config.org (concat config ".org")) |
40 | (straight-org-dir (expand-file-name "straight/build/org" | 27 | (straight-org-dir (expand-file-name "straight/build/org" |
41 | user-emacs-directory))) | 28 | user-emacs-directory))) |
42 | (unless (load config 'no-error)) | 29 | ;; Okay, let's figure this out. |
43 | ;; A plain require here just loads the older `org' | 30 | ;; `and' evaluates each form, and returns nil on the first that |
44 | ;; in Emacs' install dir. We need to add the newer | 31 | ;; returns nil. `unless' only executes its body if the test |
45 | ;; one to the `load-path', hopefully that's all. | 32 | ;; returns nil. So. |
46 | (when (file-exists-p straight-org-dir) | 33 | ;; 1. Test if config.org is newer than config.el. If it is (t), we |
47 | (add-to-list 'load-path straight-org-dir)) | 34 | ;; *want* to evaluate the body, so we need to negate that test. |
48 | ;; Load config.org | 35 | ;; 2. Try to load the config. If it errors (nil), it'll bubble that |
49 | (require 'org) | 36 | ;; to the `and' and the body will be evaluated. |
50 | (org-babel-load-file config.org :compile)) | 37 | (unless (and (not (file-newer-than-file-p config.org config.el)) |
38 | (load config :noerror)) | ||
39 | ;; A plain require here just loads the older `org' | ||
40 | ;; in Emacs' install dir. We need to add the newer | ||
41 | ;; one to the `load-path', hopefully that's all. | ||
42 | (when (file-exists-p straight-org-dir) | ||
43 | (add-to-list 'load-path straight-org-dir)) | ||
44 | ;; Load config.org | ||
45 | (require 'org) | ||
46 | (org-babel-load-file config.org))) | ||
47 | |||
48 | ;;; init.el ends here | ||