summaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
authorJakob L. Kreuze2018-12-27 18:49:54 -0500
committerJakob L. Kreuze2018-12-27 18:49:54 -0500
commitdcf35e8352e72926fb0867a42aefda6de7915694 (patch)
treeab1c44cfad5f5d5226886e91d13160d8e11642d3 /init.el
Initial commit.
Diffstat (limited to 'init.el')
-rw-r--r--init.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/init.el b/init.el
new file mode 100644
index 0000000..adbc988
--- /dev/null
+++ b/init.el
@@ -0,0 +1,33 @@
+;; This file is but bootstrapping. My real configuration file is
+;; located at "jakob.org".
+
+(defun eval-document (path)
+ "Tangles and evaluates all Emacs lisp code in the org file
+located at PATH."
+ (let* ((body-list ())
+ (src-block-regexp (concat
+ ;; (1) indentation (2) lang
+ "^\\([ \t]*\\)#\\+begin_src[ \t]+\\([^ \f\t\n\r\v]+\\)[ \t]*"
+ ;; (3) switches
+ "\\([^\":\n]*\"[^\"\n*]*\"[^\":\n]*\\|[^\":\n]*\\)"
+ ;; (4) header arguments
+ "\\([^\n]*\\)\n"
+ ;; (5) body
+ "\\([^\000]*?\n\\)??[ \t]*#\\+end_src")))
+ (with-temp-buffer
+ (insert-file-contents path)
+ (goto-char (point-min))
+ (while (re-search-forward src-block-regexp nil t)
+ (let ((lang (match-string 2))
+ (args (match-string 4))
+ (body (match-string 5)))
+ (when (and (or (string= lang "emacs-lisp") (string= lang "elisp"))
+ (not (string-match-p ":tangle\\s-+no" args)))
+ (add-to-list 'body-list body)))))
+ (let ((buffer (generate-new-buffer "*jakob-tangle-temporary*")))
+ (set-buffer buffer)
+ (apply 'insert (reverse body-list))
+ (eval-buffer)
+ (kill-buffer))))
+
+(eval-document "~/.emacs.d/jakob.org")

© 2015 - 2026 Jakob L. Kreuze