-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit.el
130 lines (111 loc) · 4.02 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
;;; init.el --- Through victory, my chains are broken
;; When I was a child, I spake as a child,
;; I understood as a child, I thought as a child:
;; but when I became a man, I put away childish things.
;; -- 1 Corinthians, 13:11
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
(when (fboundp mode) (funcall mode -1)))
;; Always ALWAYS use UTF-8
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(load-library "iso-transl")
;; Automatically save buffers before compiling
(setq compilation-ask-about-save nil)
;; Setup exec-path and PATH environment variable, in case shell has failed to do so
(let ((paths (mapcar (lambda (i) (concat (getenv "HOME") "/" i))
'("bin" "emacs/bin" ".cabal/bin" "node/bin"))))
(setenv "PATH" (apply 'concat
(append (mapcar (lambda (i) (concat i ":")) paths)
(list (getenv "PATH")))))
(dolist (path paths) (when (file-directory-p path)
(add-to-list 'exec-path path))))
;; Always ask for y/n keypress instead of typing out 'yes' or 'no'
(defalias 'yes-or-no-p 'y-or-n-p)
;; Get hostname
(setq hostname (replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" (with-output-to-string (call-process "hostname" nil standard-output))))
;; Add .emacs.d/bodil to load-path
(setq dotfiles-dir (file-name-directory
(or (buffer-file-name) load-file-name)))
(add-to-list 'load-path (concat dotfiles-dir "bodil"))
;; Add every subdirectory of ~/.emacs.d/site-lisp to the load path
(dolist
(project (directory-files (concat dotfiles-dir "site-lisp") t "\\w+"))
(when (file-directory-p project)
(add-to-list 'load-path project)))
;; Set paths to custom.el and loaddefs.el
(setq autoload-file (concat dotfiles-dir "loaddefs.el"))
(setq custom-file (concat dotfiles-dir "custom.el"))
;; Detect online status, from ESK
(require 'cl)
(defun esk-online? ()
(if (and (functionp 'network-interface-list)
(network-interface-list))
(some (lambda (iface) (unless (equal "lo" (car iface))
(member 'up (first (last (network-interface-info
(car iface)))))))
(network-interface-list))
t))
;; ELPA
(setq package-user-dir (concat dotfiles-dir "elpa"))
(require 'package)
(dolist (source '(("melpa" . "http://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("elpa" . "http://tromey.com/elpa/")))
(add-to-list 'package-archives source t))
(package-initialize)
(when (esk-online?)
(unless package-archive-contents (package-refresh-contents)))
(defun package-require (pkg)
"Install a package only if it's not already installed."
(when (not (package-installed-p pkg))
(package-install pkg)))
;; Write backup files to own directory
(setq backup-directory-alist
`(("." . ,(expand-file-name (concat dotfiles-dir "bak")))))
;; Macro for X specific code
(defmacro Xlaunch (&rest x)
(list 'if (eq window-system 'x) (cons 'progn x)))
;; Define subpackages by platform
(setq bodil-pkg-full
'(bodil-defuns
bodil-session
bodil-theme
bodil-powerline
bodil-nav
bodil-editing
bodil-snippets
bodil-complete
bodil-ido
bodil-lisp
;; bodil-paredit
bodil-smartparens
bodil-js
bodil-markup
;; bodil-c
bodil-markdown
;; bodil-python
;; bodil-erlang
bodil-haskell
bodil-purescript
bodil-magit
bodil-terminal
bodil-orgmode
bodil-flycheck
bodil-codestyle
bodil-dired
bodil-helm
bodil-project
bodil-misc-modes
bodil-multimodes
bodil-revealjs
bodil-eshell
;; bodil-mail
bodil-ohai
))
;; Now load other things
(dolist (file bodil-pkg-full)
(require file))
(Xlaunch (require 'bodil-x11))
;; Load custom settings
(load custom-file 'noerror)