;; 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 "" 'helm-find-files) (bind-key "" 'helm-mini)) (progn (bind-key "" 'ido-find-file) (bind-key "" 'ido-switch-buffer))) (bind-key "" '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)