     ad-do-it))
 (ad-activate 'align)
 
-
 ; elisp mode settings
 (add-hook 'emacs-lisp-mode-hook
-	(lambda ()
-		(setq lisp-body-indent 3)))                           ; indent elisp by 3
+          (lambda ()
+            (setq tab-width 2
+                  standard-indent 2
+                  indent-tabs-mode nil                           ; no tabs
+                  lisp-body-indent 2)))                           ; indent elisp by 2
 
 (use-package whitespace
-	:init
-		(setq whitespace-line-column 80)                      ; highlight columns past 80
-		(setq whitespace-style '(face trailing tabs tab-mark lines-tail space-before-tab))
-		(setq  whitespace-display-mappings '((tab-mark 9 [9657 9] [92 9])))
-		(global-whitespace-mode t)
-	:diminish global-whitespace-mode)
+  :init
+  (progn
+    (setq whitespace-line-column 80                      ; highlight columns past 80
+          whitespace-style '(face trailing tabs tab-mark lines-tail space-before-tab)
+          whitespace-display-mappings '((tab-mark 9 [9657 9] [92 9])))
+    (global-whitespace-mode t))
+  :diminish global-whitespace-mode)
 
 (use-package fill-column-indicator
-	:config
-		(setq fci-rule-color "white smoke")
-		(add-hook 'after-change-major-mode-hook (lambda () (if buffer-file-name (fci-mode 1)))))
+  :config
+  (progn
+    (add-hook 'after-change-major-mode-hook (lambda () (if buffer-file-name (fci-mode 1))))
+    (setq fci-rule-color "white smoke")))
 
 (use-package leuven-theme
-	:config
-		(set-face-attribute 'whitespace-tab nil :foreground "gainsboro" :background "white" )
-		(set-face-attribute 'whitespace-trailing nil :foreground "black" :background "red" )
-	)
-
-(defun switch-to-previous-buffer ()
-	(interactive)
-	(switch-to-buffer (other-buffer (current-buffer) 1)))
+  :config
+  (progn
+    (set-face-attribute 'whitespace-tab nil :foreground "gainsboro" :background "white" )
+    (set-face-attribute 'whitespace-trailing nil :foreground "black" :background "red" )))
+
+(defun me:switch-to-previous-buffer ()
+  (interactive)
+  (switch-to-buffer (other-buffer (current-buffer) 1)))
 
 ;(use-package semantic
 ;  :config

;  :defer 3)

(use-package helm
	:init
		(setq helm-split-window-in-side-p        t
			helm-apropos-fuzzy-match              t
			helm-bookmark-show-location           t
			helm-buffers-fuzzy-matching           t
			helm-completion-in-region-fuzzy-match t
			helm-ff-search-library-in-sexp        t
			helm-file-cache-fuzzy-match           t
			helm-imenu-fuzzy-match                t
			helm-locate-fuzzy-match               nil          ; not useful
			helm-mode-fuzzy-match                 t
			helm-move-to-line-cycle-in-source     t
			helm-M-x-fuzzy-match                  t
			helm-quick-update                     nil          ; ui flashing occurs
			helm-recentf-fuzzy-match              t
			helm-semantic-fuzzy-match             t
			helm-input-idle-delay                 0.1
			helm-idle-delay                       0.0
			helm-buffer-max-length                40
			helm-scroll-amount                    8)
		;; set the sources for helm-for-files
		(setq helm-for-files-preferred-list '(
			helm-source-recentf
			helm-source-buffers-list
			helm-source-files-in-current-dir
			helm-source-locate))
	:config
		(define-key helm-map [escape] 'helm-keyboard-quit)
	:bind
		("M-x" . helm-M-x)
		("C-x b" . helm-mini)
		("<f2>"   . helm-mini)
		("<f3>" . helm-for-files)
		("<S-f3>" . dired-jump)
		("<f4> a" . helm-apropos)
		("<f4> j" . helm-all-mark-ring)
		("<f4> i" . helm-info-at-point)
		("<f4> k" . helm-show-kill-ring)
		("<f4> m" . helm-man-woman)
		("<f4> p" . helm-list-elisp-packages-no-fetch)
		("<f4> x" . helm-top)
		("<f4> l" . helm-locate)
		("<f4> <f4>" . helm-resume)
	:defer 2
	)

(use-package projectile
	:init
		(setq projectile-completion-system 'helm)
		(setq projectile-enable-caching t)
		(setq projectile-use-git-grep t)
		(setq projectile-mode-line '(:eval (format " [%s]" (projectile-project-name))))
	:config
		(use-package helm-projectile
			:config
				(helm-projectile-on)
				(setq projectile-switch-project-action 'helm-for-files)
			)
		(use-package ag)
		(use-package helm-ag)
		(use-package grep)
		(setq helm-for-files-preferred-list '(
			helm-source-projectile-files-list
			helm-source-projectile-recentf-list
			helm-source-recentf
			helm-source-buffers-list
			helm-source-projectile-projects
			helm-source-files-in-current-dir
			helm-source-locate))
		(projectile-global-mode 1)
	:defer 3
	:bind
		("<f5>" . helm-projectile-find-other-file)
		("<f7> <f7>" . helm-projectile-switch-project)
		("<f7> c" . projectile-compile-project)
		("<f7> o" . projectile-multi-occur)
		("<f7> u" . projectile-invalidate-cache)
		("<f7> k" . projectile-kill-buffers)
		("<f7> f" . helm-projectile-ag)
	)

(defun update-all-tags ( )
	(interactive)
	(let ((current-prefix-arg 4)) (call-interactively 'helm-gtags-update-tags)))

(use-package helm-gtags
	:init
		(setq helm-gtags-auto-update t)
		(setq helm-gtags-use-input-at-cursor t)
		(setq helm-gtags-ignore-case t)
	:config
		(add-hook 'dired-mode-hook 'helm-gtags-mode)
		(add-hook 'eshell-mode-hook 'helm-gtags-mode)
		(add-hook 'c-mode-hook 'helm-gtags-mode)
		(add-hook 'c++-mode-hook 'helm-gtags-mode)
		(add-hook 'asm-mode-hook 'helm-gtags-mode)
	:bind
		("<f6> <f6>" . helm-gtags-dwim)
		("<f6> d" . helm-gtags-find-tag)
		("<f6> r" . helm-gtags-find-rtag)
		("<f6> u" . update-all-tags )
		("<f6> m" . helm-semantic-or-imenu)
	:diminish helm-gtags-mode)

(use-package markdown-mode
	:mode
		("\\.markdown\\'" . markdown-mode)
		("\\.md\\'" . markdown-mode)
	)

(use-package cmake-mode
	:init
		(setq cmake-tab-width 3)
	:mode
		("CMakeLists\\.txt\\'" . cmake-mode)
		("\\.cmake\\'" . cmake-mode)
	)

(use-package smart-tabs-mode
	:config
		(smart-tabs-insinuate 'c 'c++)
	)

(use-package cc-mode
	:init
		(setq show-paren-mode 0)
		(setq c-default-style "ellemtel")                           ; similar to allman style
		(setq c-electric-pound-behavior (quote (alignleft)))        ; cpp directives aligned to left

   :config
	(add-hook 'c-mode-common-hook
		(lambda ()
			(setq c-basic-offset 3)))
	(add-hook 'c++-mode-hook
		(lambda ()
			(c-set-offset 'innamespace [0])))                        ; no indentation in namespace

	:mode
		("\\.c\\'" . cc-mode)
		("\\.cpp\\'" . c++-mode)
		("\\.cxx\\'" . c++-mode)
		("\\.h\\'" . c++-mode)
		("\\.hpp\\'" . c++-mode)
	)

(use-package python-mode
	:config
		(smart-tabs-advice py-indent-line py-indent-offset)
		(smart-tabs-advice py-newline-and-indent py-indent-offset)
		(smart-tabs-advice py-indent-region py-indent-offset)
		(add-hook 'python-mode-hook 'guess-style-guess-tabs-mode)
		(add-hook 'python-mode-hook
			(lambda ()
				(semantic-mode t)
				(setq tab-width 4)))
	:defer 3)

(use-package git-gutter
	:config
		(global-git-gutter-mode t)
	:defer 3
	:diminish git-gutter-mode)

(use-package deft
	:init
		(setq deft-directory "~/Dropbox/Notes")
		(setq deft-recursive t)
		(setq deft-use-filter-string-for-filename t)
		(setq deft-file-naming-rules '((nospace . "_")
												 (noslash . "_")
												 (case-fn . downcase)))
		(setq deft-text-mode 'markdown-mode)
		; first extension in list seems to be used for new files.  Not sure
		; what deft-default-extesion does
		(setq deft-default-extension "md")
		(setq deft-extensions '("md" "txt" "text" "markdown" "mmd" "org"))
		; deft auto-save interferes with whitespace-butler, so disable
		(setq deft-auto-save-interval 0)

	:bind
		("<f4> n" . deft)

	:config
	(add-hook 'deft-mode-hook
		(lambda ()
			(define-key deft-mode-map (kbd "<C-return>") 'deft-new-file)
			(define-key deft-mode-map (kbd "<C-backspace>") 'deft-filter-clear)))
	)

(use-package company
	:config
		(add-hook 'after-init-hook 'global-company-mode)
	:diminish company-mode
	)

; enable code folding (evil has bindings)
(use-package hideshow
  :config
		(add-hook 'c-mode-common-hook   'hs-minor-mode)
		(add-hook 'c++-mode-hook        'hs-minor-mode)
		(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
		(add-hook 'sh-mode-hook         'hs-minor-mode)
		(add-hook 'python-mode-hook     'hs-minor-mode)
	:diminish hs-minor-mode
	)


;broken due to changes in helm
;(use-package helm-company
;	:requires company
;	:requires helm)


(defun use-evil-selection-register ()
	(interactive)
	(evil-execute-macro 1 "\"*"))

(defun use-evil-clipboard-register ()
	(interactive)
	(evil-execute-macro 1 "\"+"))


(defun me/evil-shift-left-visual ()
  (interactive)
  (evil-shift-left (region-beginning) (region-end))
  (evil-normal-state)
  (evil-visual-restore))

(defun me/evil-shift-right-visual ()
  (interactive)
  (evil-shift-right (region-beginning) (region-end))
  (evil-normal-state)


(require 'package)

(setq package-archives '(("melpa" . "http://melpa.milkbox.net/packages/")
                         ("org"   . "http://orgmode.org/elpa/")
                         ("gnu"   . "http://elpa.gnu.org/packages/")))

(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(when (not (package-installed-p 'use-package ))
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))
(require 'diminish)                ;; if you use :diminish
(require 'bind-key)                ;; if you use any :bind variant
(setq use-package-always-ensure t
      use-package-minimum-reported-time 0.03
      use-package-verbose t)

;; configure the chrome
(set-default-font "DejaVu Sans Mono 9")
