 ;; PACKAGES :: MISC
 ;; ---------------------------------- ;;
 
+;; https://github.com/jwiegley/emacs-async
+(use-package async
+  :ensure t
+  :config
+  (async-bytecomp-package-mode 1))
+
+;; http://pragmaticemacs.com/emacs/super-efficient-movement-using-avy/
+(use-package avy
+  :ensure t
+  :config
+  (avy-setup-default)
+  :bind ("M-s" . avy-goto-char))
+
+(use-package company
+  :ensure t
+  :config
+  (add-hook 'after-init-hook 'global-company-mode))
+
 (use-package chicken-scheme
   :ensure t
   :config
-    (setq inferior-lisp-program "/usr/bin/sbcl"))
+  (setq inferior-lisp-program "/usr/bin/sbcl"))
+
+(use-package desktop
+  :ensure t
+  :config 
+  ;; save sessions
+  ;; https://www.emacswiki.org/emacs?action=browse;oldid=DeskTop;id=Desktop
+  (setq desktop-path '("~/.emacs.d/"))
+  (setq desktop-dirname "~/.emacs.d/")
+  (desktop-save-mode 1)
+  (defun my-desktop-save ()
+    (interactive)
+    ;; Don't call desktop-save-in-desktop-dir, as it prints a message.
+    (if (eq (desktop-owner) (emacs-pid))
+        (desktop-save desktop-dirname)))
+  (add-hook 'auto-save-hook 'my-desktop-save))
+
 
 (use-package dracula-theme
   :ensure t
   :config
-    (load-theme 'dracula t))
+  (load-theme 'dracula t))
+;; https://draculatheme.com/emacs/
+(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
+                                        ;(load-theme 'blacula t)
+
+(use-package elmacro
+  :ensure t)
+
+(use-package eyebrowse
+  :ensure t
+  :config
+  (eyebrowse-mode t))
+
+(use-package flycheck
+  :ensure t)
 
 (use-package geiser
   :ensure t
   :config
-    (setq geiser-default-implementation 'guile)
-    (setq geiser-repl-use-other-window nil))
+  (setq geiser-default-implementation 'guile)
+  (setq geiser-repl-use-other-window nil))
 
 (use-package haskell-mode
-    :ensure t)
-    
+  :ensure t)
+
+(use-package htmlize
+  :ensure t)
+
 ;; https://github.com/abo-abo/swiper
 (use-package ivy
   :ensure t
   :config
-    (ivy-mode 1)
-    (setq ivy-use-virtual-buffers t)
-    (setq enable-recursive-minibuffers t))
+  (ivy-mode 1)
+
+  ;; recent buffers
+  (setq ivy-use-virtual-buffers t)
+  
+  (setq enable-recursive-minibuffers t))
 
 ;; https://github.com/Yevgnen/ivy-rich
 (use-package ivy-rich
   :ensure t
   :config
-    (ivy-rich-mode 1)
-    (setq ivy-virtual-abbreviate 'full
+  (ivy-rich-mode 1)
+  (setq ivy-virtual-abbreviate 'full
         ivy-rich-switch-buffer-align-virtual-buffer t)
-    (setq ivy-rich-path-style 'abbrev))
+  (setq ivy-rich-path-style 'abbrev))
+
+(use-package pdf-tools
+  :ensure t)
+
+(use-package projectile
+  :ensure t)
+
+;; http://cachestocaches.com/2015/8/getting-started-use-package/
+(use-package tex
+  :ensure auctex
+  :config
+  ;; https://tex.stackexchange.com/questions/207889/how-to-set-up-forward-inverse-searches-with-auctex-and-zathura
+  ;;(add-to-list 'TeX-view-program-selection
+  ;;             '(output-pdf "Zathura"))
+
+  ;; https://www.emacswiki.org/emacs/AUCTeX#toc5
+  (setq TeX-PDF-mode t)
+
+  ;; to use pdfview with auctex
+  (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
+        TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
+
+  ;; https://emacs.stackexchange.com/questions/19472/how-to-let-auctex-open-pdf-with-pdf-tools
+  ;; Update PDF buffers after successful LaTeX runs
+  (add-hook 'TeX-after-compilation-finished-functions
+            #'TeX-revert-document-buffer)
+
+  (setq TeX-source-correlate-method (quote synctex))
+  (setq TeX-source-correlate-start-server t)
+  (setq TeX-source-correlate-mode t))
 
 ;; https://www.emacswiki.org/emacs/RainbowDelimiters
 (use-package rainbow-delimiters
   :ensure t
   :config
-    (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
+  (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
 
 (use-package rotate
   :ensure t)
-  
+
 ;; http://pragmaticemacs.com/emacs/pop-up-a-quick-shell-with-shell-pop/
 (use-package shell-pop
   :bind (("C-t" . shell-pop))
   :config
   (setq shell-pop-shell-type (quote ("ansi-term" "*ansi-term*" (lambda nil (ansi-term shell-pop-term-shell)))))
   (setq shell-pop-term-shell "/bin/zsh")
+  (setq shell-pop-window-position "right")
+  (setq shell-pop-window-size 50)
   ;; need to do this manually or not picked up by `shell-pop'
   (shell-pop--set-shell-type 'shell-pop-shell-type shell-pop-shell-type))
 
 (use-package slime
   :ensure t
   :config
-    (setq inferior-lisp-program "/usr/bin/sbcl")
-    (require 'slime-autoloads)
-    (slime-setup '(slime-fancy)))
+  (setq inferior-lisp-program "/usr/bin/sbcl")
+  (require 'slime-autoloads)
+  (slime-setup '(slime-fancy)))
+
+(use-package smartparens
+  :ensure t)
+
+;; https://www.emacswiki.org/emacs/SmartTabs
+(use-package smart-tabs-mode
+  :ensure t
+  :config
+  (smart-tabs-insinuate 'c 'javascript))
 
 ;; https://github.com/nonsequitur/smex/
 (use-package smex
   :ensure t
   :config
-    (smex-initialize)
-    (global-set-key (kbd "M-x") 'smex)
-    (global-set-key (kbd "M-X") 'smex-major-mode-commands))
+  (smex-initialize)
+  (global-set-key (kbd "M-x") 'smex)
+  (global-set-key (kbd "M-X") 'smex-major-mode-commands))
 
 (use-package which-key
   :ensure t
   :config
-    (which-key-mode))
+  (which-key-mode))
+
+(use-package ws-butler
+  :ensure t)
 
 
 ;; ---------------------------------- ;;


;; https://www.emacswiki.org/emacs/BackupDirectory#toc2
(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.emacs.d/backups/"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

;; https://stackoverflow.com/questions/2985050/is-there-any-way-to-have-emacs-save-your-undo-history-between-sessions
(global-undo-tree-mode)
(setq undo-tree-auto-save-history t)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))

;; https://www.emacswiki.org/emacs/TransparentEmacs
 (set-frame-parameter (selected-frame) 'alpha '(85 . 50))
 (add-to-list 'default-frame-alist '(alpha . (85 . 50)))
 (defun toggle-transparency ()
   (interactive)
   (let ((alpha (frame-parameter nil 'alpha)))
     (set-frame-parameter
      nil 'alpha
      (if (eql (cond ((numberp alpha) alpha)
                     ((numberp (cdr alpha)) (cdr alpha))
                     ;; Also handle undocumented (<active> <inactive>) form.
                     ((numberp (cadr alpha)) (cadr alpha)))
               100)
          '(85 . 75) '(100 . 100)))))
 (global-set-key (kbd "C-c t") 'toggle-transparency)

;; https://stackoverflow.com/questions/19054228/emacs-disable-theme-background-color-in-terminal
;; has to be client (emacsclient -c -a "" -nw), not (emacs -nw)

(savehist-mode 1)

;; spell checker
(setq ispell-program-name "aspell")
(setq ispell-dictionary "en")

;; change all prompts to y or n
;; http://pragmaticemacs.com/emacs/make-all-prompts-y-or-n/
