summaryrefslogtreecommitdiffstats
path: root/init.el
blob: 0fb0767e769f1fda278e6872335bedcb2d526679 (plain)
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
;; Emacs initialization file

;; Remember the initialization directory
(setq ravi/init-dir (file-name-directory (or load-file-name (buffer-file-name))))
(defun ravi/emacs-file (filename)
  (expand-file-name filename ravi/init-dir)
  )

;; Initialize some customizations early on to avoid flicker
(setq warning-suppress-types nil)
(set-face-background 'default "black")
(set-face-foreground 'default "white")
(add-to-list 'default-frame-alist '(background-mode . dark))
(require 'cl)
(defun font-candidate (&rest fonts)
  "Return existing font which first match."
  (find-if (lambda (f) (find-font (font-spec :name f))) fonts))
(let ((fontval (font-candidate '"Inconsolata" "Source Code Pro" "Anonymous Pro")))
  (when fontval (set-face-attribute 'default nil :font fontval)))
(when window-system
  (tooltip-mode -1)
  (tool-bar-mode -1))
(menu-bar-mode -1)
(setq custom-file (concat ravi/init-dir "custom.el"))

;; Initialize package handling: currently using only the official repository and MELPA
(setq package-archives
      '(("gnu"         . "http://elpa.gnu.org/packages/")
        ;("original"    . "http://tromey.com/elpa/")
        ;("org"         . "http://orgmode.org/elpa/")
        ;("marmalade"   . "http://marmalade-repo.org/packages/")
        ("melpa"       . "http://melpa.milkbox.net/packages/")))
(add-to-list 'load-path ravi/init-dir)
(add-to-list 'load-path (ravi/emacs-file "site-lisp/"))
(setq autoload-file (concat ravi/init-dir "loaddefs.el"))
(setq package-user-dir (concat ravi/init-dir "elpa"))

(package-initialize)

(defvar ravi/default-install-packages
  (list 'yasnippet 'use-package 'bind-key 'diminish)
  "Libraries that should be installed by default.")

(unless package-archive-contents
  (package-refresh-contents))
(dolist (package ravi/default-install-packages)
  (unless (package-installed-p package)
    (package-install package)))

;; Settings from M-x customize
(load custom-file 'noerror)

(require 'bind-key)
(require 'use-package)
(require 'diminish)

;; Show full frame windows for certain commands
(use-package fullframe
  :ensure t
  )

;; ---------------------------------------------------------------------
;; Stolen from purcell/emacs.d/init-utils.el
(defmacro after-load (feature &rest body)
  "After FEATURE is loaded, evaluate BODY."
  (declare (indent defun))
  `(eval-after-load ,feature
     '(progn ,@body)))

(defun sanityinc/string-all-matches (regex str &optional group)
  "Find all matches for `REGEX' within `STR', returning the full match string or group `GROUP'."
  (let ((result nil)
        (pos 0)
        (group (or group 0)))
    (while (string-match regex str pos)
      (push (match-string group str) result)
      (setq pos (match-end group)))
    result))
;; ---------------------------------------------------------------------

(when (file-exists-p (ravi/emacs-file "local.el"))
  (load-file (ravi/emacs-file "local.el"))
  )

;; Auto indent mode must be enabled before autopair and yasnippet
(use-package auto-indent-mode
  :config (auto-indent-global-mode)
  :diminish auto-indent-mode
  :disabled t ;; this mode tries to do way too much
  :ensure t
  )

(require 'ravi-init-ido)
(require 'ravi-init-marks)
(require 'ravi-init-appearance)
(require 'ravi-init-files)
(require 'ravi-init-vc)
(require 'ravi-init-function)
(require 'ravi-init-insertion)
(require 'ravi-init-navigation)
(require 'ravi-init-cpp)
(require 'ravi-init-python)

;; Temporary key-bindings
(bind-key "<f9>" 'ido-find-file)
(bind-key "<f8>" 'ido-switch-buffer)
(bind-key "<f12>" 'undo-tree-undo)