-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdotemacs.el
98 lines (74 loc) · 3.64 KB
/
dotemacs.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
;;; dreamacs.el --- Make using emacs a dream!
;; Copyright (C) 2014 Michael Steger
;; Author: Michael Steger <[email protected]>
;; Maintainer: Michael Steger <[email protected]>
;; Created: 20 Feb 2014
;; Version: 0.01
;; Keywords: package
(require 'cl)
(defun require-all (requirelist)
(mapc #'require requirelist))
(defvar current-user
(getenv
(if (equal system-type 'windows-nt) "USERNAME" "USER")))
(when (version< emacs-version "24.1")
(error "Dreamacs requires at least GNU Emacs 24.1"))
(defvar dreamacs-base-dir (expand-file-name (or (getenv "DREAMACS_PATH") (file-name-directory (file-truename (or load-file-name (buffer-file-name))))))
"The root directory of dreamacs")
(defvar dreamacs-core-dir (expand-file-name "core" dreamacs-base-dir)
"The home of Dreamacs's core functionality.")
(defvar dreamacs-savefile-dir (expand-file-name "savefile" dreamacs-base-dir)
"This folder stores all the automatically generated save/history-files.")
(defvar dreamacs-modules-dir (expand-file-name "modules" dreamacs-base-dir)
"This directory houses all of the built-in Dreamacs modules.")
(defvar dreamacs-modules-file (expand-file-name "dreamacs-modules.el" dreamacs-base-dir)
"This files contains a list of modules that will be loaded by Dreamacs.")
(defvar dreamacs-elpa-base (expand-file-name (concat dreamacs-base-dir "/elpa"))
"This directory houses all the elpa files")
(defvar dreamacs-personal-modules '()
"List of personal modules that will be required(that is, a file of the form dreamacs-$X is expected for every $X in this list) in during the loading of dreamacs. See dreamacs-modules.el for more info. It is expected that users will set this variable in their own config before dreamacs loads.")
(defvar dreamacs-personal-configurationless-modules '()
"List of personal modules that are to be directly installed/required without any assosciated file expected for them. See dreamacs-modules.el for more info. It is expected that users will set this variable in their own config before dreamacs loads.")
(unless (file-exists-p dreamacs-savefile-dir)
(make-directory dreamacs-savefile-dir))
(setq default-directory dreamacs-base-dir)
(normal-top-level-add-subdirs-to-load-path)
(require-all '(
dreamacs-packages
dreamacs-core
dreamacs-ui
dreamacs-editor
))
(defun load-file-if-exists (file-name)
(let ((string-file-name (if (symbolp file-name) (symbol-name file-name) file-name)))
(when (locate-library string-file-name)
(if (symbolp file-name)
(require file-name)
(load file-name)))))
(load-file-if-exists dreamacs-modules-file)
(defun dreamacs-add-subfolders-to-load-path (parent-dir)
"Add all level PARENT-DIR subdirs to the `load-path'."
(dolist (f (directory-files parent-dir))
(let ((name (expand-file-name f parent-dir)))
(when (and (file-directory-p name)
(not (equal f ".."))
(not (equal f ".")))
(add-to-list 'load-path name)
(dreamacs-add-subfolders-to-load-path name)))))
;; add Dreamacs's directories to Emacs's `load-path'
(add-to-list 'load-path dreamacs-core-dir)
(add-to-list 'load-path dreamacs-modules-dir)
;; reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
;; OSX specific settings
(when (eq system-type 'darwin)
(require 'dreamacs-osx))
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
(setq enable-recursive-minibuffers t)
(load-file-if-exists 'dreamacs-secrets)
(require 'server)
(unless (server-running-p)
(server-start))
;;; dreamacs.el ends here