--- /dev/null
+;; save session on exit
+;(global-unset-key (kbd "RET"))
+;(global-unset-key (kbd "<return>"))
+
+;; Added by Package.el. This must come before configurations of
+;; installed packages. Don't delete this line. If you don't want it,
+;; just comment it out by adding a semicolon to the start of the line.
+;; You may delete these explanatory comments.
+(package-initialize)
+(require 'package)
+(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
+
+;Load scripts from lisp directory
+(add-to-list 'load-path "~/.emacs.d/lisp/")
+
+;(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/color-theme-sanityinc-tomorrow-master")
+;(load-theme 'color-theme-sanityinc-tomorrow t)
+;(load-theme 'solarized t)
+;(set-frame-parameter nil 'background-mode 'dark)
+;(set-terminal-parameter nil 'background-mode 'dark)
+(color-theme-sanityinc-tomorrow-night)
+
+;; ---------------------------------------
+;; load elscreen
+;; ---------------------------------------
+(load "elscreen" "ElScreen" t)
+
+; Text completion
+;(require 'completion)
+;(initialize-completions)
+
+; Configure sr-speedbar sidebar navigation
+(require 'sr-speedbar)
+(sr-speedbar-open)
+(setq speedbar-initial-expansion-list-name "quick buffers")
+(setq sr-speedbar-skip-other-window-p t)
+
+;; Configure uniquify buffer naming styles
+(require 'uniquify)
+(setq uniquify-buffer-name-style 'reverse)
+
+;; Save session on exit
+(desktop-save-mode 1)
+
+;; Additional Session saving
+;; psession.el
+(require 'psession)
+(psession-mode 1)
+(psession-autosave-mode 1)
+
+;; elscreen session saving
+(defvar emacs-configuration-directory
+ "~/.emacs.d/"
+ "The directory where the emacs configuration files are stored.")
+
+(defvar elscreen-tab-configuration-store-filename
+ (concat emacs-configuration-directory ".elscreen")
+ "The file where the elscreen tab configuration is stored.")
+
+(defun elscreen-store ()
+ "Store the elscreen tab configuration."
+ (interactive)
+ (if (desktop-save emacs-configuration-directory)
+ (with-temp-file elscreen-tab-configuration-store-filename
+ (insert (prin1-to-string (elscreen-get-screen-to-name-alist))))))
+(push #'elscreen-store kill-emacs-hook)
+(defun elscreen-restore ()
+ "Restore the elscreen tab configuration."
+ (interactive)
+ (if (desktop-read)
+ (let ((screens (reverse
+ (read
+ (with-temp-buffer
+ (insert-file-contents elscreen-tab-configuration-store-filename)
+ (buffer-string))))))
+ (while screens
+ (setq screen (car (car screens)))
+ (setq buffers (split-string (cdr (car screens)) ":"))
+ (if (eq screen 0)
+ (switch-to-buffer (car buffers))
+ (elscreen-find-and-goto-by-buffer (car buffers) t t))
+ (while (cdr buffers)
+ (switch-to-buffer-other-window (car (cdr buffers)))
+ (setq buffers (cdr buffers)))
+ (setq screens (cdr screens))))))
+(elscreen-restore)
+
+;; Remember (and allow undo) of window config
+(setq winner-mode t)
+
+;; Window follow mouse pointer focus
+(setq mouse-autoselect-window t)
+
+;; Helper function for generating empty buffers (for C-n)
+; From: https://stackoverflow.com/questions/25791605/emacs-how-do-i-create-a-new-empty-buffer-whenever-creating-a-new-frame
+(defun lunaryorn-new-buffer-frame ()
+ "Create a new frame with a new empty buffer."
+ (interactive)
+ (let ((buffer (generate-new-buffer "untitled")))
+ (set-buffer-major-mode buffer)
+ (display-buffer buffer '(display-buffer-pop-up-frame . nil))))
+
+;; SHOW FILE PATH IN FRAME TITLE
+;(setq-default frame-title-format "%b (%f)")
+
+;(setq frame-title-format
+; '(:eval
+; (if buffer-file-name
+; (replace-regexp-in-string
+; "\\\\" "/"
+; (replace-regexp-in-string
+; (regexp-quote (getenv "HOME")) "~"
+; (convert-standard-filename buffer-file-name)))
+; (buffer-name))))
+
+;; MOVEMENT HELPER FUNCTION
+(defun resize-window ()
+ (interactive)
+ (catch 'exit
+ (while (setq direction (read-key-sequence "Arrow keys to resize; b to balance; any other key to exit"))
+ (cond ((equal direction (kbd "<right>")) (enlarge-window-horizontally 1))
+ ((equal direction (kbd "<left>")) (shrink-window-horizontally 1))
+ ((equal direction (kbd "<up>")) (enlarge-window 1))
+ ((equal direction (kbd "<down>")) (shrink-window 1))
+ ((equal direction (kbd "b")) (balance-windows))
+ (throw 'exit 0))))
+ )
+
+(defun split-window-left ()
+ "Split-window-right then windmove-left"
+ (interactive)
+ (split-window-right)
+ (windmove-left))
+
+;; Skip scratch buffers when using next/previous buffers
+; from: https://stackoverflow.com/questions/14323516/make-emacs-next-buffer-skip-messages-buffer
+(defun next-code-buffer ()
+ (interactive)
+ (let ((bread-crumb (buffer-name) ))
+ (next-buffer)
+ (while
+ (and
+ (string-match-p "^\*" (buffer-name))
+ (not (equal bread-crumb (buffer-name) )) )
+ (next-buffer))))
+(global-set-key [remap next-buffer] 'next-code-buffer)
+
+(defun previous-code-buffer ()
+ (interactive)
+ (let ((bread-crumb (buffer-name) ))
+ (previous-buffer)
+ (while
+ (and
+ (string-match-p "^\*" (buffer-name))
+ (not (equal bread-crumb(buffer-name) )) )
+ (previous-buffer))))
+(global-set-key [remap previous-buffer] 'previous-code-buffer)
+
+;; Copy
+(defun simple-copy ()
+ (interactive)
+ (kill-region 0 0 1)
+ (yank))
+
+; Normal return
+(defun open-next-line ()
+ (interactive)
+ (open-line 1)
+ (next-line))
+
+; Initialization function for shit that isn't working right in the .emacs
+;(defun initialize ()
+; (interactive)
+; (global-set-key (kbd "RET") 'open-next-line))
+
+;;;;;;;;;;;;;;;;;;;;
+;; Personal bindings
+;;;;;;;;;;;;;;;;;;;;
+; META KEYS:
+; C- Page
+; M- Buffer
+;;; C-S Window
+; M-S Window / Screen
+; C-M Desktop
+;
+; COMMANDS:
+; l list
+;
+;
+;
+
+;; UNSETS
+; Removing stupid defaults)
+;(global-unset-key (kbd "RET"))
+
+;; CHARACTER COMMANDS
+; Movement
+; (use arrow keys; default bindings)
+; Functions
+;(global-set-key (kbd "<return>") 'open-line)
+(global-set-key (kbd "RET") 'open-next-line)
+
+;; PAGE COMMANDS (C-)
+; Movement
+(global-set-key (kbd "C-<left>") 'move-beginning-of-line)
+(global-set-key (kbd "C-<right>") 'move-end-of-line)
+(global-set-key (kbd "C-<up>") 'scroll-down-command)
+(global-set-key (kbd "C-<down>") 'scroll-up-command)
+; Functions
+(global-set-key (kbd "C-l") 'company-mode)
+;(global-set-key (kbd "C-m") 'set-mark-command)
+;(global-set-key (kbd "C-<space>") 'set-mark-command)
+(global-set-key (kbd "C-g") 'goto-line)
+(global-set-key (kbd "C-z") 'undo)
+(global-set-key (kbd "C-r") 'execute-extended-command)
+; C-o open-browse (?)
+(global-set-key (kbd "C-s") 'set-mark-command)
+(global-set-key (kbd "C-f") 'find-file)
+(global-set-key (kbd "C-w") 'list-matching-lines)
+; C-n new (?)
+(global-set-key (kbd "C-d") 'kill-whole-line)
+
+(global-unset-key (kbd "C-j"))
+(global-set-key (kbd "C-j") 'simple-copy)
+(global-set-key (kbd "C-x") 'kill-region)
+(global-set-key (kbd "C-k") 'yank)
+
+;; BUFFER COMMANDS (M-)
+; Movement
+(global-set-key (kbd "M-<left>") 'next-buffer)
+(global-set-key (kbd "M-<right>") 'previous-buffer)
+; Functions
+(global-set-key (kbd "M-l") 'list-buffers)
+(global-set-key (kbd "M-m") 'buffer-menu)
+(global-set-key (kbd "M-g") 'switch-to-buffer)
+(global-set-key (kbd "M-z") 'reset-buffer)
+(global-set-key (kbd "M-r") 'eval-last-sexp)
+(global-set-key (kbd "M-o") 'dired)
+(global-set-key (kbd "M-s") 'save-buffer)
+(global-set-key (kbd "M-f") 'find-file)
+(global-set-key (kbd "M-w") 'list-matching-lines)
+(global-set-key (kbd "M-n") #'lunaryorn-new-buffer-frame)
+(global-set-key (kbd "M-d") 'kill-buffer)
+
+;; WINDOW COMMANDS (C-S-)
+; Movement
+(global-set-key (kbd "M-S-<right>") 'windmove-right)
+(global-set-key (kbd "M-S-<up>") 'windmove-up)
+(global-set-key (kbd "M-S-<down>") 'windmove-down)
+(global-set-key (kbd "M-S-<left>") 'windmove-left)
+; Functions
+;(global-unset-key (kbd "C-R"))
+;(global-unset-key (kbd "C-N"))
+; C-L list
+; C-M menu
+; C-G goto
+; C-Z undo (winner-mode)
+
+(defvar sc-window-map (make-sparse-keymap)
+ "Window manipulation keymap")
+(define-key sc-window-map "\M-N" 'sc-window-map-prefix)
+(fset 'sc-window-map-prefix sc-window-map)
+(define-key sc-window-map "\C-c" 'help-for-help)
+
+(global-set-key (kbd "M-R") 'resize-window)
+;(global-set-key (kbd "C-R t") 'resize-window)
+;(global-set-key (kbd "C-R b") 'balance-windows)
+;(global-set-key (kbd "C-S-r <right>") 'enlarge-window-horizontally)
+;(global-set-key (kbd "C-S-r <left>") 'shrink-window-horizontally)
+;(global-set-key (kbd "C-S-r <up>") 'enlarge-window)
+;(global-set-key (kbd "C-S-r <down>") 'shrink-window)
+; C-O browse
+; C-S save
+; C-F find
+; C-W where
+(global-set-key (kbd "M-N <right>") 'split-window-right)
+(global-set-key (kbd "M-N <up>") 'split-window-above)
+(global-set-key (kbd "M-N <down>") 'split-window-below)
+(global-set-key (kbd "M-N <left>") 'split-window-left)
+(global-set-key (kbd "M-D") 'delete-window)
+
+;; SCREEN COMMANDS (M-S-)
+;(global-set-key (kbd "M-S-<right>") 'elscreen-next)
+;(global-set-key (kbd "M-S-<left>") 'elscreen-previous)
+;(global-set-key (kbd "M-D") 'elscreen-kill)
+;(global-set-key (kbd "M-N") 'elscreen-create)
+
+;; DESKTOP COMMANDS (C-M-)
+; Configure in window manager as required
+; M-M : buffer-menu
+; C-S-o <down> scroll-other-window
+(global-set-key (kbd "C-M-c") 'save-buffers-kill-terminal)
+(global-set-key (kbd "C-M-b") 'shell)
+;(global-set-key (kbd "C-M-q") 'kill-emacs)
+
+
+;(global-set-key (kbd "C-x b") 'shell)
+;(global-set-key (kbd "S-C-<right>") 'elscreen-next)
+;(global-set-key (kbd "S-C-<left>") 'elscreen-previous)
+;(global-set-key (kbd "S-<right>") 'next-buffer)
+;(global-set-key (kbd "S-<left>") 'previous-buffer)
+;(global-set-key (kbd "M-<right>") 'windmove-right)
+;(global-set-key (kbd "M-<left>") 'windmove-left)
+;(global-set-key (kbd "M-<up>") 'windmove-up)
+;(global-set-key (kbd "M-<down>") 'windmove-down)
+;(global-set-key (kbd "C-N") 'elscreen-create)
+;(global-set-key (kbd "C-D") 'elscreen-kill)
+;(global-set-key (kbd "C-f") 'find-file)
+;(global-set-key (kbd "C-s") 'save-buffer)
+;(global-set-key (kbd "C-z") 'undo)
+;(global-set-key (kbd "C-w") 'list-matching-lines)
+
+;(global-set-key (kbd "M-d") 'delete-window)
+;(global-set-key (kbd "M-n <down>") 'split-window-below)
+;(global-set-key (kbd "M-n <right>") 'split-window-right)
+;(global-set-key (kbd "M-n <left>") 'split-window-left)
+;(global-set-key (kbd "M-n <up>") 'split-window-above)
+;(global-set-key (kbd "M-n o") 'other-window)
+
+;; ---------------------------------------
+;; load elscreen
+;; ---------------------------------------
+;(load "elscreen" "ElScreen" t)
+
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(custom-enabled-themes '(sanityinc-tomorrow-night))
+ '(custom-safe-themes
+ '("06f0b439b62164c6f8f84fdda32b62fb50b6d00e8b01c2208e55543a6337433a" default))
+ '(package-selected-packages '(color-theme-sanityinc-tomorrow company ## async)))
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ )
+
+;(global-unset-key (kbd "<return>"))
+;(global-unset-key (kbd "RET"))
+
+(setq tab-width 2)
+(setq-default tab-width 2)
+(setq default-tab-width 2)
+(defvaralias 'c-basic-offset 'tab-width)
+(defvaralias 'cperl-indent-level 'tab-width)
+(setq-default indent-tabs-mode nil)