From ee826b2e1d84f35406b3885607caa13e143ec482 Mon Sep 17 00:00:00 2001
From: Blendoit <blendoit@gmail.com>
Date: Mon, 5 Oct 2020 23:01:55 -0700
Subject: Start work on early-init.el

---
 .gitignore                     |   2 +
 init-custom.el                 |   2 +-
 init.el                        |  24 +++++----
 smart-documents.org            | 118 +++++++++++++++++++++++------------------
 smart-documents.pdf            | Bin 104689 -> 107625 bytes
 themes/blendoit-light-theme.el |  11 ++--
 6 files changed, 88 insertions(+), 69 deletions(-)

diff --git a/.gitignore b/.gitignore
index 29d9590..d7dc875 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,5 @@ _minted*
 # Tangled config .el file from .org
 smart-documents.el
 
+# Misc
+.org-id-locations
diff --git a/init-custom.el b/init-custom.el
index 4aab2a2..3cbdb6e 100644
--- a/init-custom.el
+++ b/init-custom.el
@@ -15,7 +15,7 @@
  '(company-quickhelp-color-foreground "#DCDCCC")
  '(custom-enabled-themes nil)
  '(custom-safe-themes
-   '("5c32236ef318adafe4102f627f330fa8f448046dfd838eef5cc09c7f682cf71f" "e343fecfb8d681186d594002c9b44ce48c2061599d7e4ec635cf1ca2a277a47a" "302dc61dc55600c7424f945dce9e74fba7df19f4a7bfb72aefd93193fa82ede4" "58f1f85248ba913387d1e7ed02a867161b315cfb5acff0c234e013ffd2577d22" "a256abf590bbc3257cc11d91a312e9fe8487dc1b95a5b7b732dd2f96a7fe5a45" "30368d6195cae9298304e6ac0534b90c85b1655965f1206c5c624270f0f46002" "311aa5df3223b5b4a7c638aad3befb4de9c7f46360d52acd1fa2cd2232b1dcbd" default))
+   '("6495716176be0ced4142593b94a410135e0b373b686a869637824260d2f1ca11" "4467b1c8d7cc78fe98345c9c63eb62cf37844dc6868630add365494bde455715" "faeef63cb31f796b4bdf22f38e614934ab34d7deacaeb89b3e9cccf70aac5a85" "370fb305168fea1614535dc9ca30f496918eaca754b6c8969dd77fa872bec695" "e9f0c0c3397d07eb1c6c3551d67fd151e24bc6d72ec678841623ed572677c97a" "5c32236ef318adafe4102f627f330fa8f448046dfd838eef5cc09c7f682cf71f" "e343fecfb8d681186d594002c9b44ce48c2061599d7e4ec635cf1ca2a277a47a" "302dc61dc55600c7424f945dce9e74fba7df19f4a7bfb72aefd93193fa82ede4" "58f1f85248ba913387d1e7ed02a867161b315cfb5acff0c234e013ffd2577d22" "a256abf590bbc3257cc11d91a312e9fe8487dc1b95a5b7b732dd2f96a7fe5a45" "30368d6195cae9298304e6ac0534b90c85b1655965f1206c5c624270f0f46002" "311aa5df3223b5b4a7c638aad3befb4de9c7f46360d52acd1fa2cd2232b1dcbd" default))
  '(fci-rule-color "#383838")
  '(fringe-mode 0 nil (fringe))
  '(indicate-empty-lines t)
diff --git a/init.el b/init.el
index 9f56fa4..228062c 100644
--- a/init.el
+++ b/init.el
@@ -1,19 +1,23 @@
-;;; init.el --- bootstrap main Emacs config from USB drive.
+;;; init.el --- Load literate configuration file, smart-documents.org.
 
 ;;; Commentary:
-;; This package enables bootstrapping a full `.emacs.d/' configuration
-;; residing on a removable drive.  It is copied over from
-;; init-bootstrap.el to init.el, at a location the OS expects to find
-;; that file.  Then, every time Emacs is started, it will scan the top
-;; level of all typical mount points in an effort to detect an
-;; existing `.emacs.d/'.
+;; This file's sole purpose is to load our literate configuration file.
 
 ;;; Code:
 
-(org-babel-load-file "~/.emacs.d/smart-documents.org")
 
-(setq my/literate-config (concat user-emacs-directory "smart-documents.org"))
-;; (setq my/literate-config-compiled (concat user-emacs-directory "blendoit-init.elc"))
+;; First of all, we indicate the path to our literate configuration file.
+(setq my/literate-config (concat user-emacs-directory "smart-documents"))
+
+;; Emacs will startup faster next time, because it will load
+;; a byte-compiled version of our literate configuration file.
+(cond ((file-exists-p (concat my/literate-config ".elc"))
+       (load (concat my/literate-config ".elc")))
+      ((file-exists-p (concat my/literate-config ".el"))
+       (load (concat my/literate-config ".el")))
+      ((file-exists-p (concat my/literate-config ".org"))
+       (org-babel-load-file (concat my/literate-config ".org")))
+      (t (message "There appears to be no literate configuration file. Reinstall?")))
 
 (provide 'init)
 
diff --git a/smart-documents.org b/smart-documents.org
index dc3cf69..843b678 100644
--- a/smart-documents.org
+++ b/smart-documents.org
@@ -12,9 +12,8 @@
 
 #+LATEX: \begin{abstract}
 The idea of /Smart Documents/ came to me as I was reflecting on how to improve
-the document production process in my workplace. So much time was wasted on
-formatting; output PDFs were awfully inconsistent, and conveyed poor brand
-awareness from a typographical standpoint.
+the document production process in my workplace. I really wanted to improve the
+way we produced documents.
 
 #+LATEX: \end{abstract}
 
@@ -26,10 +25,10 @@ source code and observe the editor's modified behaviour in real time. Since its
 inception in 1984, GNU Emacs has grown to be much more than a full-featured,
 high-productivity text editor---new /modes/ have been written to interact with
 hundreds of file formats, including =.txt=, =.pdf=, =.jpg=, =.csv=, and =.zip=
-just to name a few. This configuration file itself was written in /Org mode/, a
-collection of functions enabling the harmonious mixing of code and comments in
-view of publication: this is the endgame of /literate programming/, and the
-basis of my vision for /Smart Documents/.
+just to name a few. This paper itself was written in /Org mode/, a collection
+of functions enabling the harmonious mixing of code and comments in view of
+publication: this is the endgame of /literate programming/, and the basis of my
+vision for /Smart Documents/.
 
 The following sections were laid out very deliberately. When we start Emacs,
 the source code blocks contained in this document are evaluated
@@ -40,29 +39,16 @@ detailed steps Emacs takes upon starting, refer to
 [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html]].]
 
 Customizing Emacs goes far, far beyond this document---feel free to experiment
-and discover.
+and discover. Here are three commands that will help you understand all the
+symbols in this file, if you are browsing this paper within Emacs itself:
 
 - ~C-h f~ describe function
 - ~C-h v~ describe variable
 - ~C-h k~ describe key
 
-These three commands will attempt to describe the element currently under our
-cursor, however one can start typing to search for another symbol.
-
-** =init.el=
-
 When Emacs first starts up, it looks for the following files in order and
 attempts to load the contents of the first existing file. From the manual:
 
-#+BEGIN_QUOTE
-Traditionally, file =~/.emacs= is used as the init file, although Emacs also
-looks at =~/.emacs.el=, =~/.emacs.d/init.el=, =~/.config/emacs/init.el=, or
-other
-locations.[fn::[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html]]]
-#+END_QUOTE
-
- If no file is found, Emacs then loads in its purely vanilla state.
-
 * TODO First-time setup
 
 ** TODO User details
@@ -87,8 +73,6 @@ element.
       (append-to-file "Foobar\n" nil "~/.emacs.d/meta/foobar"))
 #+END_SRC
 
-
-
 ** File system paths
 
 In this subsection, we tell Emacs about relevant paths to resources.
@@ -103,16 +87,50 @@ https://git-scm.com/download/win]
 
 * Early setup
 
-** Garbage collection
+** The first file to load, =early-init.el=
 
-First, we increase the RAM threshold beyond which the garbage collector is
-activated.
+This is the very first user-writable file loaded by Emacs.[fn::This feature
+became available in version 27.1.] In it, we disable GUI elements that would
+otherwise be loaded and displayed once Emacs is ready to accept user input.
 
-#+NAME: garbage-collection
 #+BEGIN_SRC emacs-lisp
-(setq gc-cons-threshold 100000000)
+  (setq my/early-init-file (concat user-emacs-directory "early-init.el"))
+
+  (unless (file-exists-p my/early-init-file)
+    (write-region
+     "(menu-bar-mode -1)
+  (tool-bar-mode -1)
+  (menu-bar-bottom-and-right-window-divider)
+  (setq gc-cons-threshold 100000000)" nil my/early-init-file)
+    (menu-bar-mode -1)
+    (tool-bar-mode -1)
+    (menu-bar-bottom-and-right-window-divider)
+    (setq gc-cons-threshold 100000000))
 #+END_SRC
 
+** The second file to load, =init.el=
+
+#+BEGIN_QUOTE
+Traditionally, file =~/.emacs= is used as the init file, although Emacs also
+looks at =~/.emacs.el=, =~/.emacs.d/init.el=, =~/.config/emacs/init.el=, or
+other
+locations.[fn::[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html]]]
+#+END_QUOTE
+
+#+BEGIN_SRC emacs-lisp
+(setq my/init-file (concat user-emacs-directory "init.el"))
+
+(unless (file-exists-p my/init-file)
+  (write-region
+   "(menu-bar-mode -1)
+(tool-bar-mode -1)
+(menu-bar-bottom-and-right-window-divider)" nil my/early-init-file)
+  (menu-bar-mode -1)
+  (tool-bar-mode -1)
+  (menu-bar-bottom-and-right-window-divider))
+#+END_SRC
+
+ If no file is found, Emacs then loads in its purely vanilla state.
 ** Profiling --- start
 
 We start the profiler now , and will interrupt it in Section [[Profiling ---
@@ -142,7 +160,7 @@ possible, this facilitates debugging.
   (defun my/find-literate-config ()
     "Jump to this very file."
     (interactive)
-    (find-file my/literate-config))
+    (find-file (concat my/literate-config ".org"))
 
   (global-set-key (kbd "C-c c") 'my/find-literate-config)
 #+END_SRC
@@ -796,7 +814,6 @@ output to an automated ``smart document''.
      ("budget" "%(binary) -f %(ledger-file) budget --exchange USD")))
 #+END_SRC
 
-
 *** Plotting & charting
 
 #+BEGIN_SRC emacs-lisp
@@ -891,25 +908,6 @@ The keybinding for opening a recently visited file is described in paragraph
 
 ** Frame
 
-*** Clean up menus
-
-Originally, I wished to inhibit certain entries in the GUI menus. Not worth the
-effort at this time.
-
-#+BEGIN_SRC emacs-lisp
-(menu-bar-mode -1)
-(tool-bar-mode -1)
-#+END_SRC
-
-*** Dividers
-
-This ensures users can resize windows using the GUI. It also creates a useful
-separation between the bottom of the frame and the echo area.
-
-#+BEGIN_SRC emacs-lisp
-(menu-bar-bottom-and-right-window-divider)
-#+END_SRC
-
 *** TODO Header & mode line
 Complete mode line rewrite. Might require new package.
 
@@ -1065,8 +1063,24 @@ than 1920\times1080.
 * Late setup
 
 At this point, our editor is almost ready to run. Phew! All that's left to do
-is to interrupt our profiling activities, and smartly store the result of our
-profiling.
+is to prepare for the next startup, interrupt our profiling activities, and
+smartly store the result of our profiling.
+
+** TODO Speeding up the next startup
+
+#+BEGIN_SRC emacs-lisp
+  (defun byte-compile-if-literate-config ()
+    "Byte compile the current file if it is `my/literate-config-org'."
+(interactive)
+    (when (string-equal
+           buffer-file-name
+           "/home/blendux/.emacs.d/smart-documents.org")
+      (delete-file (concat my/literate-config ".elc"))
+      (byte-compile (concat my/literate-config ".el")))
+      (message "c'mon work fucker"))
+
+  (add-hook 'after-save-file 'byte-compile-if-literate-config)
+#+END_SRC
 
 ** Profiling --- stop
 
diff --git a/smart-documents.pdf b/smart-documents.pdf
index 22120d2..e9b8cec 100644
Binary files a/smart-documents.pdf and b/smart-documents.pdf differ
diff --git a/themes/blendoit-light-theme.el b/themes/blendoit-light-theme.el
index 0b97d46..a2e8be1 100644
--- a/themes/blendoit-light-theme.el
+++ b/themes/blendoit-light-theme.el
@@ -1,5 +1,5 @@
 (deftheme blendoit-light
-  "Created 2020-10-04.")
+  "Created 2020-10-05.")
 
 (custom-theme-set-faces
  'blendoit-light
@@ -56,10 +56,10 @@
  '(org-document-title ((t (:weight bold :height 2.0))))
  '(org-footnote ((t (:inherit link))))
  '(org-document-info-keyword ((t (:inherit org-meta-line))))
- '(org-code ((t (:background "light grey" :foreground "black" :family "Hack"))))
+ '(org-code ((t (:background "light grey" :foreground "black" :height 0.9 :family "Hack"))))
  '(org-checkbox-statistics-todo ((t (:inherit org-checkbox :foreground "tomato"))))
  '(org-checkbox-statistics-done ((t (:inherit org-checkbox :foreground "ForestGreen"))))
- '(org-verbatim ((t (:inherit fixed-pitch :foreground "DodgerBlue1" :foundry "Hack"))))
+ '(org-verbatim ((t (:inherit fixed-pitch :height 0.9 :foreground "DodgerBlue1" :foundry "Hack"))))
  '(font-lock-doc-face ((t (:inherit font-lock-string-face :Family "Liberation Sans"))))
  '(org-document-info ((t (:weight bold))))
  '(org-table ((t (:height 0.8 :family "Hack"))))
@@ -73,18 +73,17 @@
  '(org-level-6 ((t (:inherit org-level-5))))
  '(org-level-7 ((t (:inherit org-level-5))))
  '(org-level-8 ((t (:inherit org-level-5))))
- '(org-checkbox ((t (:inherit org-meta-line :weight bold))))
+ '(org-checkbox ((t (:weight bold :inherit org-meta-line))))
  '(org-todo ((t (:background "tomato" :foreground "White" :weight bold :height 1.2 :family "Hermit"))))
  '(org-done ((t (:background "ForestGreen" :foreground "White" :weight bold :height 1.2 :family "Hermit"))))
  '(org-date ((t (:inherit org-tag))))
  '(Info-quoted ((t (:inherit org-block))))
- '(org-priority ((t (:inherit org-meta-line :weight bold))))
+ '(org-priority ((t (:weight bold :inherit org-meta-line))))
  '(powerline-active1 ((t (:inherit mode-line :background "grey17" :foreground "white" :family "Hack"))))
  '(powerline-active2 ((t (:inherit (mode-line) :foreground "white" :background "grey40"))))
  '(powerline-inactive1 ((t (:inherit mode-line-inactive :background "grey11" :family "Hack"))))
  '(powerline-inactive2 ((t (:inherit (mode-line-inactive) :background "grey20"))))
  '(org-drawer ((t (:inherit org-meta-line))))
- '(org-tag ((t (:inherit org-meta-line :underline t))))
  '(default ((t (:background "white" :foreground "black" :height 140 :family "Hack")))))
 
 (provide-theme 'blendoit-light)
-- 
cgit v1.2.3