-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.el
62 lines (47 loc) · 1.84 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;
;; ~/.emacs.d/init.el
;;
;; This is the driver which attempts to load, parse, and evaluate the
;; content of my main Markdown init-file "init.md" from beneath ~/.emacs.d/
;;
(defun load-markdown-init (path)
"If the specified file exists then attempt to load it.
We treat the file as markdown, and we extract code-blocks from it which we
execute directly."
;; if the file exists
(if (file-exists-p (expand-file-name path))
(with-temp-buffer
;; insert into temporary buffer
(insert-file-contents (expand-file-name path))
;; Go to the start of the file.
(goto-char (point-min))
;; Until we're at the end of the file ...
(while (not (eobp))
;; Jump forward a line.
(forward-line 1)
;; Skip to the start of the code block.
(re-search-forward "^```lisp$" (point-max) t)
(let (
(start (match-end 0))
(end 0)
(line (line-number-at-pos))
)
;; Find the end of the code-block
(re-search-forward "^```$" (point-max) t)
(setq end (match-beginning 0))
;; Evaluate it, and then keep going.
(if (< start end)
(condition-case the-error
(eval-region start end)
(error
(message "ERROR Execiting processing file %s starting at line %d" path line)))))))
(message "Skipping file that doesn't exist %s" path)))
;; Record our start time
(defconst skx/startup-begin (float-time))
;; Load the global-file markdown file.
(load-markdown-init "~/.emacs.d/init.md")
;; Record the end of our startup time
(defconst skx/startup-end (float-time))
;; Show the duration
(defconst skx/startup-duration (- skx/startup-end skx/startup-begin))
(message "[Emacs startup duration %.2f seconds]" skx/startup-duration)