 ;; undoes all meta keys otherwise
 (amap "<escape>" 'evil-normal-state)
 
-(nmap "SPC 1" 'delete-other-windows
-      "SPC 2" 'ivy-switch-buffer
-      "SPC 3" 'counsel-find-file
-      "SPC 4" 'zsh-terminal)
-
-(defun flycheck-mode-and-check ()
+(nmap "SPC w f" 'delete-other-windows
+      "SPC b b" 'ivy-switch-buffer
+      "SPC f f" 'counsel-find-file
+      "SPC f t" 'zsh-terminal)
+
+(defun edit-emacs-rc ()
+  "Go to emacsrc."
+  (interactive)
+  (find-file "~/.emacs"))
+(nmap "SPC f e" 'edit-emacs-rc)
+
+(defun flycheck-toggle-and-check ()
+  "Toggle flycheck mode and check if it was previously off."
   (interactive)
   (flycheck-mode 'toggle)
-  (flycheck-buffer))
-(nmap "SPC 5" 'flycheck-mode-and-check)
-
-(amap
- "C-<right>" 'sp-forward-sexp
- "C-<left>" 'sp-backward-sexp
- "C-<up>" 'sp-up-sexp
- "C-<down>" 'sp-down-sexp
- "C-S-<right>" 'sp-forward-slurp-sexp
- "C-S-<left>" 'sp-forward-barf-sexp
- "C-S-<up>" 'sp-backward-slurp-sexp
- "C-S-<down>" 'sp-backward-barf-sexp
- "C-M-t" 'sp-transpose-sexp
- "C-M-w" 'sp-unwrap-sexp)
-
-
-(nmap "SPC SPC" 'evil-emacs-state)
-(nmap "SPC q" 'evil-delete-buffer)
+  (if (bound-and-true-p flycheck-mode) (flycheck-buffer)))
+
+(nmap "SPC t" 'flycheck-toggle-and-check)
+
+(nmap "SPC SPC" 'counsel-M-x)
 (nmap "SPC g" 'magit-status)
-(amap "C-s" 'swiper)
+(nmap "SPC b d" 'evil-delete-buffer)
+(nmap "SPC s" 'swiper)
 
 (setq python-shell-completion-native-enable nil)
 

  :config
  (progn
    (which-key-mode)
    (setq which-key-idle-delay 0.2))
  :diminish which-key-mode)

(use-package undo-tree
  :config (global-undo-tree-mode)
  :diminish undo-tree-mode)

(use-package smartparens
  :config (progn
            (require 'smartparens-config)
            (smartparens-global-mode)))

(use-package rainbow-delimiters
  :init (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))

(use-package magit)


  (defun add-map-list (map l)
    "Perform add-map using MAP on all of list L."
    (mapcar (lambda (x) (add-map map x)) (pair-list l)))

  (defmacro imap (&rest l)
    "Map the bindings of L with 'evil-insert-state-map."
    `(progn ,@(add-map-list 'evil-insert-state-map l)))
