-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
77 lines (66 loc) · 3.06 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;;Emacs init file
(message "Emacs init.el started at %s" (current-time-string))
;; Load private.el, if it exists.
;; This file contains any user-specific information to keep outside of
;; version control
(load (expand-file-name "private.el" user-emacs-directory) 'noerror)
;; Configure package archives.
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;; Optionally, uncomment line below to also add melpa-stable to the
;; package archives. The 'append keyword allows for the archive to be
;; added to be appended to the end of the list, which effectively
;; gives it lower priority when searching for packages.
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") 'append)
(package-initialize)
;; Add the site-lisp directory to the load path.
;; This is where I usually put files which fail to be found in the
;; package archives above.
(setq site-lisp-directory (expand-file-name "site-lisp" user-emacs-directory))
(add-to-list 'load-path site-lisp-directory)
;; Bootstrap use-package which we will use for the bulk of the
;; configurations.
;; This excellent package by John Wiegley is described here:
;; https://github.com/jwiegley/use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; The following comes from the use-package README
(eval-when-compile
(require 'use-package))
(require 'diminish)
(require 'bind-key)
(setq use-package-verbose t)
;; Set use-package to always `ensure' packages. This means that
;; packages will be downloaded from the packages by default.
(setq use-package-always-ensure t)
;; Load custom.el, if it exits.
(load (expand-file-name "custom.el" user-emacs-directory) 'noerror)
;; Evaluate helper method which tangles an org file only when needed
(require 'org)
(defun jr/org-babel-tangle-file-if-needed (file)
"Tangle contents of FILE, if needed.
Specifically, FILE is tangled only if no tangled file already
exists or if FILE was modified after the last tangle.
Returns the tangled file as a string."
(let ((tangled-file (concat (file-name-sans-extension file) ".el")))
(when (or (not (file-exists-p tangled-file))
(time-less-p (nth 5 (file-attributes tangled-file))
(nth 5 (file-attributes file))))
(message "Retangling file %s" file)
(org-babel-tangle-file file tangled-file "emacs-lisp"))
tangled-file))
;; Load configuration in config.org, if file exists.
;; Note that config.org is _not_ an emacs-lisp source file, which
;; explains why we don't use `load' to load it. See the Org manual for
;; all the details.
(let ((org-config
(expand-file-name "settings/config.org" user-emacs-directory)))
(when (file-exists-p org-config)
(load-file
(jr/org-babel-tangle-file-if-needed org-config))))
;; Set custom.el as the custom file instead of using this init.el.
(setq custom-file (expand-file-name "custom.el"))
(message "Emacs ready at %s" (current-time-string))