f93ecbacdbd671d3933135219d0e65060c0d7698
[emacs.git] / .emacs.d / init.el
1 ;; Ganneff's emacs config
2
3 ;; Emacs can not read its config directly from org-mode files.
4 ;; But as my config nearly completly is inside an org-mode file,
5 ;; emacs need to be told to deal with it.
6 ;; Meet org-tangle/org-babel-load-file, which extracts the emacs-lisp
7 ;; source parts of my config files, writes them into .el files
8 ;; and then lets emacs load those.
9
10 ;; That way I have a nice environment to edit and comment - and easily export
11 ;; to web or elsewhere - while emacs has its elisp. The initial run after
12 ;; a config change takes longer, but as that only happens when I change
13 ;; something in the .org files - I don't care.
14
15 ;; Go go go
16 (message "Emacs is powering up... Be patient, Master %s!" (getenv "USER"))
17
18 ;; I like to see how long it takes to "boot" emacs (usually one or two
19 ;; seconds), so save the start time
20 (setq emacs-load-start-time (current-time))
21
22 ;; We will need a set of directories for stuff
23 ;; Lets define some variables for them
24
25 ;; I might have special configuration based on various states
26 ;; First we set an own variable, as system-type from emacs directly is
27 ;; useless. gnu/linux and gnu/kfreebsd have extra /, which is plenty annoying
28 ;; when you want to use them in a path entry.
29 (defun jj-system-type ()
30 "Return a string depending on the OS we use"
31 (interactive)
32 (cond
33 ((eq system-type 'darwin) "macosx")
34 ((eq system-type 'gnu/linux) "linux")
35 ((eq system-type 'gnu/kfreebsd) "kfreebsd")
36 ((eq system-type 'cygwin) "cygwin")
37 ((eq system-type 'windows-nt) "windows")))
38
39
40 (defvar jj-dir (file-name-directory (or load-file-name (buffer-file-name)))
41 "The master directory for Ganneffs emacs configuration and storage.
42 Usually ~/.emacs.d/")
43 (defvar jj-config-dir (expand-file-name "config" jj-dir)
44 "Ganneffs main emacs configuration can be found here.")
45 (defvar jj-emacs-config (expand-file-name "emacs.org" jj-config-dir)
46 "Ganneffs main emacs configuration file.")
47 (defvar jj-sys-config (expand-file-name (concat system-name ".org") jj-config-dir)
48 "Ganneffs System/Host specific emacs configiraton file")
49 (defvar jj-os-config (expand-file-name (concat (jj-system-type) ".org") jj-config-dir)
50 "Ganneffs Operating system specific emacs configuration file")
51 (defvar jj-user-config (expand-file-name (concat user-login-name ".org") jj-config-dir)
52 "Ganneffs username specific emacs configuration file")
53 (defvar jj-elisp-dir (expand-file-name "elisp" jj-dir)
54 "This directory stores subdirs for packages locally put into Ganneffs emacs config")
55 (defvar jj-elisp-local-dir (expand-file-name "local" jj-elisp-dir)
56 "This directory stores extra elisp files for Ganneffs emacs config")
57 (defvar jj-custom-file (expand-file-name "customized.el" jj-config-dir)
58 "Where do changes from the customization interface end in Ganneffs emacs config")
59
60 ;; Set path to (my, recent) Org-Mode version
61 (add-to-list 'load-path (concat jj-elisp-dir "/org/"))
62 ;; Have use-package/bindkey in here wich are needed for startup
63 (add-to-list 'load-path jj-elisp-local-dir)
64
65 ;; As we use org-mode/org-babel/org-tangle to extract the real emacs
66 ;; config out of the org-mode files, we have to load that first.
67 (setq org-modules (quote
68 (org-bbdb org-bibtex org-crypt org-docview org-gnus
69 org-id org-info org-jsinfo org-habit org-inlinetask
70 org-irc org-protocol org-w3m org-mouse org-checklist
71 org-notmuch icalendar)))
72 (require 'org-install)
73 (require 'ob-tangle)
74
75 ;; Now read my config
76 ;; Note that those files *can* include further files.
77
78 ;; The basic config is always loaded, no matter where we start emacs.
79 (org-babel-load-file jj-emacs-config)
80
81 ;; All the others are optional. We try the order of os, system, user
82 ;; specific files and load them, should they be there
83 (if (file-exists-p jj-os-config) (org-babel-load-file jj-os-config ))
84 (if (file-exists-p jj-sys-config) (org-babel-load-file jj-sys-config))
85 (if (file-exists-p jj-user-config) (org-babel-load-file jj-user-config))
86
87 ;; Lets get a message about startup time out
88 (when (require 'time-date nil t)
89 (message "Emacs startup time: %d seconds."
90 (time-to-seconds (time-since emacs-load-start-time)))
91 )
92 ; (message (concat "Emacs startup time: " (emacs-init-time)))
93
94