-
Notifications
You must be signed in to change notification settings - Fork 59
/
init.el
67 lines (52 loc) · 2.32 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
;;; init.el --- Where all the magic begins
;;
;;; Commentary:
;;
;; This is a starter kit for jmax. This package provides a customized setup for
;; emacs that we use daily for scientific programming and publication.
;;
;;; Code:
(when (version< emacs-version "24.4")
(warn "You probably need Emacs 24.4. You should upgrade. You may need to install leuven-theme manually."))
;; remember this directory
(defconst starter-kit-dir (file-name-directory (or load-file-name (buffer-file-name)))
"Directory where the starterkit is installed.")
(defvar user-dir (expand-file-name "user" starter-kit-dir)
"User directory for personal code.")
(defvar jmax-load-user-dir t
"Load the user directory files.")
(add-to-list 'load-path starter-kit-dir)
(add-to-list 'load-path user-dir)
(defvar jmax-auto-update t
"Determines if jmax will automatically update itself.")
;; we load the user/preload.el file if it exists. This lets users define
;; variables that might affect packages when they are loaded, e.g. key-bindings,
;; etc... In particular, this is needed for setting some key-bindings in
;; jmax-bibtex. Also, you can turn off jmax-auto-update here.
(let ((preload (expand-file-name "user/preload.el" starter-kit-dir)))
(when (file-exists-p preload)
(load preload)))
;; check status of jmax, and update if needed. This is not super
;; robust if the user has changed jmax, since we do not check if your
;; repo is clean.
(if jmax-auto-update
(let ((default-directory starter-kit-dir))
(shell-command "git fetch origin master")
(shell-command "git submodule init")
(shell-command "git submodule update")
(let ((output (shell-command-to-string
"git rev-list --count --left-right HEAD...origin/master"))
(local-changes) (remote-changes))
(setq local-changes (string-to-number (nth 0 (split-string output))))
(setq remote-changes (string-to-number (nth 1 (split-string output))))
(when (> remote-changes 0)
(when (let ((last-nonmenu-event nil))
(y-or-n-p "jmax is not up to date. Update now?"))
(message "updating jmax now")
(shell-command "git pull origin master")
(shell-command "git submodule init")
(shell-command "git submodule update"))))))
(require 'packages)
(require 'jmax)
(provide 'init)
;;; init.el ends here