emacs.d

My emacs configuration, done in a literate programming fashion using org-mode

git clone git://git.shimmy1996.com/emacs.d.git
commit d4ed686a182a4428c396fd94b98f6cb0ff08f8b3
parent 53e9e049edb7356a65d67b9ab477eee2f9952ea2
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Mon, 25 Dec 2017 15:38:18 -0600

Write my own bootstrap function instead of relying on org-babel.

Diffstat:
MREADME.org | 46+++++++++++++++++++++++++---------------------
Minit.el | 42+++++++++++++++++++++++++++---------------
2 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/README.org b/README.org
@@ -1,34 +1,32 @@
 #+TITLE: My Emacs Config
 #+AUTHOR: Shimmy Xu
+#+TODO: DISABLED(t) | ENABLED(d)
 
-* Introduction
-This is my humble collection of Emacs config, modeled after [[https://github.com/admiralakber/simplemacs][simplemacs]], documented in an hopefully understandable manner. I went from using multiple =.org= files back to a single one because =org-mode= is just fantastic and my config is not too complicated for a single file to handle (yet).
+This is my humble collection of Emacs config, modeled after [[https://github.com/admiralakber/simplemacs][simplemacs]], documented in an hopefully understandable manner. I went from using multiple =.org= files back to a single one because =org-mode= is fantastic and my config is not too complicated for a single file to handle (yet).
 
-After installation, you may need to run =M-x list-packages= and reload =init.el=.
-
-** Module Descriptions
 Here's a short description for each module.
-| Module             | Notes                       |
-|--------------------+-----------------------------|
-| [[Packages]]           | Package management.         |
-| [[Aesthetics]]         | UI and theme.               |
-| [[Org-mode]]           | Org-mode settings.          |
-| [[Helm]]               | Minibuffer auto-completion. |
-| [[Auctex]]             | Latex settings.             |
-| [[Ox-hugo]]            | =hugo= exporter.            |
-| [[Magit]]              | Git interface.              |
-| [[CC]]                 | CC mode.                    |
-| [[Flycheck]]           | Syntax checking.            |
-| [[Yasnippet]]          | Snippet templates.          |
-| [[Company]]            | Buffer auto-completion.     |
+| Module         | Notes                       |
+|----------------+-----------------------------|
+| [[Packages]]   | Package management.         |
+| [[Aesthetics]] | UI and theme.               |
+| [[Org-mode]]   | Org-mode settings.          |
+| [[Helm]]       | Minibuffer auto-completion. |
+| [[Auctex]]     | Latex settings.             |
+| [[Ox-hugo]]    | =hugo= exporter.            |
+| [[Magit]]      | Git interface.              |
+| [[CC]]         | CC mode.                    |
+| [[Flycheck]]   | Syntax checking.            |
+| [[Yasnippet]]  | Snippet templates.          |
+| [[Company]]    | Buffer auto-completion.     |
 
 * Packages
 Manage my package settings.
 
 ** Package Repositories
-Initialize Emacs Package Manager and add repositories (only melpa for now).
+Initialize Emacs Package Manager and add repositories.
 
 #+BEGIN_SRC emacs-lisp
+  (package-initialize)
   (require 'package)
   (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                       (not (gnutls-available-p))))
@@ -266,6 +264,12 @@ Use Source Code Pro as the default font.
 
 * Org-mode
 Mostly formatting settings in =org-mode=.
+** Installation
+=org= mode comes bundled, but we still need to load it.
+#+BEGIN_SRC emacs-lisp
+  (use-package org
+    :ensure t)
+#+END_SRC
 
 ** Set Link Format
 Do not collapse the links.
@@ -464,9 +468,9 @@ Enable =ox-hugo= as an option for exporting.
     :init (with-eval-after-load 'ox (require 'ox-hugo)))
 #+END_SRC
 
-** Auto Set Export Parameters
+** DISABLED Auto Set Export Parameters
 Auto sets export parameters when using =org-capture=.
-#+BEGIN_SRC
+#+BEGIN_SRC emacs-lisp
 (with-eval-after-load 'org-capture
   (defun org-hugo-new-subtree-post-capture-template ()
     "Returns `org-capture' template string for new Hugo post.
diff --git a/init.el b/init.el
@@ -1,16 +1,28 @@
-;; Shimmy Xu's Emacs (@shimmy1996)
-;; ------------------------------------------------------------------------
+;;; init.el --- Kickstart Emacs -*- lexical-binding: t -*-
+;;; Commentary:
+;;; Bootstraps the configuration by loading specified org file.
 
-;; Added by Package.el.  This must come before configurations of
-;; installed packages.  Don't delete this line.  If you don't want it,
-;; just comment it out by adding a semicolon to the start of the line.
-;; You may delete these explanatory comments.
-(package-initialize)
-
-(require 'org)
-
-;; Load my configs
-;; ------------------------------------------------------------------------
-(org-babel-load-file (expand-file-name
-                      "~/.emacs.d/README.org"
-                      user-emacs-directory))
+;;; Code:
+(with-temp-buffer
+  (insert-file-contents (expand-file-name "README.org" user-emacs-directory))
+  (goto-char (point-min))
+  (while (not (eobp))
+    (forward-line 1)
+    (cond
+     ;; Skip DISABLED Subtrees
+     ((looking-at "^\\(\\*+\\) \\(DISABLED\\).*$")
+      (end-of-line)
+      (message "%s" (match-string 0))
+      (re-search-forward
+       (format "^\\*\\{1,%d\\} " (length (match-string 1)))
+       nil 1)
+      (beginning-of-line))
+     ;; Log ENABLED Subtrees
+     ((looking-at "^\\*+ \\(ENABLED\\|\\).*$")
+      (message "%s" (match-string 0)))
+     ;; Evaluate Code Blocks
+     ((looking-at "^#\\+BEGIN_SRC +emacs-lisp *$")
+      (let ((l (match-end 0)))
+        (search-forward "\n#+END_SRC")
+        (eval-region l (match-beginning 0)))))))
+;;; init.el ends here