summaryrefslogtreecommitdiffstats
path: root/init.el
blob: 19edbd679c7775ba8cdc4f39dace364f0f92c724 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
;; 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
(when window-system
  (tooltip-mode -1)
  (tool-bar-mode -1))
;; Open in full-screen of possible
(when (fboundp 'toggle-frame-maximized)
  (setq frame-resize-pixelwise t)
  (toggle-frame-maximized))
(menu-bar-mode -1)
(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 "Source Code Pro")))
  (when fontval (set-face-attribute 'default nil :font fontval :height 110)))
(when (find-font (font-spec :name "Symbola"))
  (set-fontset-font "fontset-default" nil
                    (font-spec :size 20 :name "Symbola")))
(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/")
        ("org"         . "http://orgmode.org/elpa/")
        ("melpa"       . "http://melpa.org/packages/")))
(add-to-list 'load-path (ravi/emacs-file "lisp/"))
(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)
(setq use-package-always-ensure t)

(defvar ravi/use-helm-instead-of-ido t
  "Prefer helm to ido")

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

(use-package s)
(use-package dash)
(require 's)
(require 'ravi-ergodox-mode)
(let* ((xinput-string (shell-command-to-string "xinput"))
       (xorg-ergodox (s-contains? "Ergodox" xinput-string))
       (under-xming (or xorg-ergodox
                        (s-contains? "vendor string:    Colin Harrison"
                                     (shell-command-to-string "xdpyinfo")))))
  (if (or xorg-ergodox under-xming)
      (progn
        (ravi-ergodox-mode)
        (diminish 'ravi-ergodox-mode)
        (unless xorg-ergodox
          ;; We are in Windows remote desktop with XMing
          (setq x-meta-keysym 'meta)
          (setq x-super-keysym 'super)
          (setq x-alt-keysym 'hyper)
          (setq x-hyper-keysym 'alt)))
    (progn
      ;; Temporary key-bindings
      (if (bound-and-true-p ravi/use-helm-instead-of-ido)
          (progn
            (bind-key "<f9>" 'helm-find-files)
            (bind-key "<f8>" 'helm-mini))
        (progn
          (bind-key "<f9>" 'ido-find-file)
          (bind-key "<f8>" 'ido-switch-buffer)))
      (bind-key "<f12>" 'undo-tree-undo))))

(use-package free-keys
  :commands free-keys)

(defun ravi/add-variables-from-dir-locals (varname hack-varname &optional make-it-local)
  "Add variable from dir-locals.el to an existing variable as a buffer-local variable"
  (let ((basic-var (symbol-value varname)))
    (when (and (boundp hack-varname)
               (listp (symbol-value hack-varname)))
      (when make-it-local
        (make-local-variable varname))
      (set varname (append basic-var (symbol-value hack-varname))))))

(require 'ravi-init-maps)
(require 'ravi-init-ido)
(require 'ravi-init-helm)
(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)
(require 'ravi-init-layouts)
(require 'ravi-init-org)
(require 'ravi-init-tex)
(require 'ravi-init-repl)
(require 'ravi-init-dired)
(require 'ravi-init-mu)
(require 'ravi-init-web)